Search in sources :

Example 61 with Reference

use of io.crate.metadata.Reference in project crate by crate.

the class SysNodesExpressionsOnHandlerTest method testNetwork.

@Test
public void testNetwork() throws Exception {
    Reference refInfo = refInfo("sys.nodes.network", DataTypes.OBJECT, RowGranularity.NODE);
    collectExpression = resolver.getImplementation(refInfo);
    collectExpression.setNextRow(CONTEXT);
    Map<String, Object> networkStats = (Map<String, Object>) collectExpression.value();
    assertThat(mapToSortedString(networkStats), is("probe_timestamp=0, tcp={" + "connections={accepted=42, curr_established=42, dropped=42, embryonic_dropped=42, initiated=42}, " + "packets={errors_received=42, received=42, retransmitted=42, rst_sent=42, sent=42}" + "}"));
}
Also used : Reference(io.crate.metadata.Reference) TestingHelpers.mapToSortedString(io.crate.testing.TestingHelpers.mapToSortedString) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 62 with Reference

use of io.crate.metadata.Reference in project crate by crate.

the class SysNodesExpressionsOnHandlerTest method testId.

@Test
public void testId() throws Exception {
    Reference refInfo = refInfo("sys.nodes.id", DataTypes.STRING, RowGranularity.NODE);
    collectExpression = resolver.getImplementation(refInfo);
    collectExpression.setNextRow(CONTEXT);
    assertThat(BytesRefs.toBytesRef("93c7ff92-52fa-11e6-aad8-3c15c2d3ad18"), is(collectExpression.value()));
}
Also used : Reference(io.crate.metadata.Reference) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 63 with Reference

use of io.crate.metadata.Reference in project crate by crate.

the class SysNodesExpressionsOnHandlerTest method testOsInfo.

@Test
public void testOsInfo() throws Exception {
    Reference refInfo = refInfo("sys.nodes.os_info", DataTypes.OBJECT, RowGranularity.NODE);
    collectExpression = resolver.getImplementation(refInfo);
    collectExpression.setNextRow(CONTEXT);
    Map<String, Object> v = (Map<String, Object>) collectExpression.value();
    assertThat(v.get("available_processors"), is(4));
}
Also used : Reference(io.crate.metadata.Reference) TestingHelpers.mapToSortedString(io.crate.testing.TestingHelpers.mapToSortedString) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 64 with Reference

use of io.crate.metadata.Reference in project crate by crate.

the class SysNodesExpressionsOnHandlerTest method testPorts.

@Test
public void testPorts() throws Exception {
    Reference refInfo = refInfo("sys.nodes.port", DataTypes.OBJECT, RowGranularity.NODE);
    collectExpression = resolver.getImplementation(refInfo);
    collectExpression.setNextRow(CONTEXT);
    Map<String, Object> v = (Map<String, Object>) collectExpression.value();
    assertThat(v.get("http"), is(4200));
    assertThat(v.get("transport"), is(4300));
}
Also used : Reference(io.crate.metadata.Reference) TestingHelpers.mapToSortedString(io.crate.testing.TestingHelpers.mapToSortedString) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 65 with Reference

use of io.crate.metadata.Reference in project crate by crate.

the class SysNodesExpressionsOnHandlerTest method testVersion.

@Test
public void testVersion() throws Exception {
    Reference refInfo = refInfo("sys.nodes.version", DataTypes.OBJECT, RowGranularity.NODE);
    collectExpression = resolver.getImplementation(refInfo);
    collectExpression.setNextRow(CONTEXT);
    Map<String, Object> v = (Map<String, Object>) collectExpression.value();
    assertThat(v.get("number"), is(Version.CURRENT.number()));
    assertThat(v.get("build_hash"), is(Build.CURRENT.hash()));
    assertThat(v.get("build_snapshot"), is(Version.CURRENT.snapshot()));
}
Also used : Reference(io.crate.metadata.Reference) TestingHelpers.mapToSortedString(io.crate.testing.TestingHelpers.mapToSortedString) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

Reference (io.crate.metadata.Reference)84 Test (org.junit.Test)57 CrateUnitTest (io.crate.test.integration.CrateUnitTest)55 TestingHelpers.mapToSortedString (io.crate.testing.TestingHelpers.mapToSortedString)27 HashMap (java.util.HashMap)20 Map (java.util.Map)20 NestedObjectExpression (io.crate.operation.reference.NestedObjectExpression)17 ColumnIdent (io.crate.metadata.ColumnIdent)15 Symbol (io.crate.analyze.symbol.Symbol)14 BytesRef (org.apache.lucene.util.BytesRef)11 TableIdent (io.crate.metadata.TableIdent)9 ReferenceIdent (io.crate.metadata.ReferenceIdent)8 InputColumn (io.crate.analyze.symbol.InputColumn)6 RoutedCollectPhase (io.crate.planner.node.dql.RoutedCollectPhase)6 ShardId (org.elasticsearch.index.shard.ShardId)5 Routing (io.crate.metadata.Routing)4 UUID (java.util.UUID)4 OrderBy (io.crate.analyze.OrderBy)3 ShardResponse (io.crate.executor.transport.ShardResponse)3 ShardUpsertRequest (io.crate.executor.transport.ShardUpsertRequest)3