Search in sources :

Example 1 with DefaultTelemetryConfig

use of org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig in project onos by opennetworkinglab.

the class DefaultGrpcTelemetryConfigTest method testPropsExtraction.

/**
 * Tests props extraction.
 */
@Test
public void testPropsExtraction() {
    Map<String, String> props = Maps.newConcurrentMap();
    props.put(ADDRESS, IP_ADDRESS_1);
    props.put(PORT, String.valueOf(PORT_1));
    props.put(MAX_INBOUND_MSG_SIZE, String.valueOf(MSG_SIZE_1));
    props.put(USE_PLAINTEXT, String.valueOf(USE_PLAIN_TEXT_1));
    TelemetryConfig config = new DefaultTelemetryConfig(DUMMY, GRPC, ImmutableList.of(), DUMMY, DUMMY, ENABLED, props);
    GrpcTelemetryConfig grpcConfig = fromTelemetryConfig(config);
    assertThat(grpcConfig.address(), is(IP_ADDRESS_1));
    assertThat(grpcConfig.port(), is(PORT_1));
    assertThat(grpcConfig.maxInboundMsgSize(), is(MSG_SIZE_1));
    assertThat(grpcConfig.usePlaintext(), is(USE_PLAIN_TEXT_1));
}
Also used : DefaultTelemetryConfig(org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig) GrpcTelemetryConfig(org.onosproject.openstacktelemetry.api.config.GrpcTelemetryConfig) TelemetryConfig(org.onosproject.openstacktelemetry.api.config.TelemetryConfig) GrpcTelemetryConfig(org.onosproject.openstacktelemetry.api.config.GrpcTelemetryConfig) DefaultTelemetryConfig(org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig) DefaultGrpcTelemetryConfig.fromTelemetryConfig(org.onosproject.openstacktelemetry.config.DefaultGrpcTelemetryConfig.fromTelemetryConfig) Test(org.junit.Test)

Example 2 with DefaultTelemetryConfig

use of org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig in project onos by opennetworkinglab.

the class DefaultPrometheusTelemetryConfigTest method testPropsExtraction.

/**
 * Tests props extraction.
 */
@Test
public void testPropsExtraction() {
    Map<String, String> props = Maps.newConcurrentMap();
    props.put(ADDRESS, IP_ADDRESS_1);
    props.put(PORT, String.valueOf(PORT_1));
    TelemetryConfig config = new DefaultTelemetryConfig(DUMMY, PROMETHEUS, ImmutableList.of(), DUMMY, DUMMY, DISABLED, props);
    PrometheusTelemetryConfig prometheusConfig = fromTelemetryConfig(config);
    assertThat(prometheusConfig.address(), is(IP_ADDRESS_1));
    assertThat(prometheusConfig.port(), is(PORT_1));
}
Also used : DefaultTelemetryConfig(org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig) PrometheusTelemetryConfig(org.onosproject.openstacktelemetry.api.config.PrometheusTelemetryConfig) PrometheusTelemetryConfig(org.onosproject.openstacktelemetry.api.config.PrometheusTelemetryConfig) TelemetryConfig(org.onosproject.openstacktelemetry.api.config.TelemetryConfig) DefaultPrometheusTelemetryConfig.fromTelemetryConfig(org.onosproject.openstacktelemetry.config.DefaultPrometheusTelemetryConfig.fromTelemetryConfig) DefaultTelemetryConfig(org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig) Test(org.junit.Test)

Example 3 with DefaultTelemetryConfig

use of org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig in project onos by opennetworkinglab.

the class DefaultRestTelemetryConfigTest method testPropsExtraction.

/**
 * Tests props extraction.
 */
@Test
public void testPropsExtraction() {
    Map<String, String> props = Maps.newConcurrentMap();
    props.put(ADDRESS, IP_ADDRESS_1);
    props.put(PORT, String.valueOf(PORT_1));
    props.put(ENDPOINT, ENDPOINT_1);
    props.put(METHOD, METHOD_1);
    props.put(REQUEST_MEDIA_TYPE, REQUEST_MEDIA_TYPE_1);
    props.put(RESPONSE_MEDIA_TYPE, RESPONSE_MEDIA_TYPE_1);
    TelemetryConfig config = new DefaultTelemetryConfig(DUMMY, REST, ImmutableList.of(), DUMMY, DUMMY, DISABLED, props);
    RestTelemetryConfig restConfig = DefaultRestTelemetryConfig.fromTelemetryConfig(config);
    assertThat(restConfig.address(), is(IP_ADDRESS_1));
    assertThat(restConfig.port(), is(PORT_1));
    assertThat(restConfig.endpoint(), is(ENDPOINT_1));
    assertThat(restConfig.method(), is(METHOD_1));
    assertThat(restConfig.requestMediaType(), is(REQUEST_MEDIA_TYPE_1));
    assertThat(restConfig.responseMediaType(), is(RESPONSE_MEDIA_TYPE_1));
}
Also used : DefaultTelemetryConfig(org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig) RestTelemetryConfig(org.onosproject.openstacktelemetry.api.config.RestTelemetryConfig) TelemetryConfig(org.onosproject.openstacktelemetry.api.config.TelemetryConfig) RestTelemetryConfig(org.onosproject.openstacktelemetry.api.config.RestTelemetryConfig) DefaultTelemetryConfig(org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig) Test(org.junit.Test)

Example 4 with DefaultTelemetryConfig

use of org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig in project onos by opennetworkinglab.

the class TelemetryConfigCodecTest method testTelemetryConfigEncode.

/**
 * Tests the telemetry config encoding.
 */
@Test
public void testTelemetryConfigEncode() {
    String name = "grpc";
    TelemetryConfig.ConfigType type = TelemetryConfig.ConfigType.GRPC;
    String manufacturer = "grpc.io";
    String swVersion = "1.0";
    TelemetryConfig.Status status = ENABLED;
    Map<String, String> properties = Maps.newConcurrentMap();
    properties.put("key1", "value1");
    properties.put("key2", "value2");
    TelemetryConfig config = new DefaultTelemetryConfig(name, type, ImmutableList.of(), manufacturer, swVersion, status, properties);
    ObjectNode configJson = telemetryConfigCodec.encode(config, context);
    assertThat(configJson, matchesTelemetryConfig(config));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultTelemetryConfig(org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig) DefaultTelemetryConfig(org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig) TelemetryConfig(org.onosproject.openstacktelemetry.api.config.TelemetryConfig) TelemetryConfigJsonMatcher.matchesTelemetryConfig(org.onosproject.openstacktelemetry.codec.rest.TelemetryConfigJsonMatcher.matchesTelemetryConfig) Test(org.junit.Test)

Example 5 with DefaultTelemetryConfig

use of org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig in project onos by opennetworkinglab.

the class OpenstackTelemetryConfigWebResourceTest method setUpTest.

/**
 * Sets up the global values for all the tests.
 */
@Before
public void setUpTest() {
    ServiceDirectory testDirectory = new TestServiceDirectory().add(TelemetryConfigAdminService.class, mockConfigAdminService);
    setServiceDirectory(testDirectory);
    PROP.put(PROP_KEY_1, PROP_VALUE_1);
    PROP.put(PROP_KEY_2, PROP_VALUE_2);
    telemetryConfig = new DefaultTelemetryConfig(NAME, TYPE, null, MANUFACTURER, SW_VERSION, STATUS, PROP);
}
Also used : ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) DefaultTelemetryConfig(org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) Before(org.junit.Before)

Aggregations

DefaultTelemetryConfig (org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig)10 TelemetryConfig (org.onosproject.openstacktelemetry.api.config.TelemetryConfig)7 Test (org.junit.Test)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)1 Before (org.junit.Before)1 ServiceDirectory (org.onlab.osgi.ServiceDirectory)1 TestServiceDirectory (org.onlab.osgi.TestServiceDirectory)1 GrpcTelemetryConfig (org.onosproject.openstacktelemetry.api.config.GrpcTelemetryConfig)1 InfluxDbTelemetryConfig (org.onosproject.openstacktelemetry.api.config.InfluxDbTelemetryConfig)1 KafkaTelemetryConfig (org.onosproject.openstacktelemetry.api.config.KafkaTelemetryConfig)1 PrometheusTelemetryConfig (org.onosproject.openstacktelemetry.api.config.PrometheusTelemetryConfig)1 RestTelemetryConfig (org.onosproject.openstacktelemetry.api.config.RestTelemetryConfig)1 TelemetryConfigJsonMatcher.matchesTelemetryConfig (org.onosproject.openstacktelemetry.codec.rest.TelemetryConfigJsonMatcher.matchesTelemetryConfig)1 DefaultGrpcTelemetryConfig.fromTelemetryConfig (org.onosproject.openstacktelemetry.config.DefaultGrpcTelemetryConfig.fromTelemetryConfig)1 DefaultInfluxDbTelemetryConfig.fromTelemetryConfig (org.onosproject.openstacktelemetry.config.DefaultInfluxDbTelemetryConfig.fromTelemetryConfig)1 DefaultKafkaTelemetryConfig.fromTelemetryConfig (org.onosproject.openstacktelemetry.config.DefaultKafkaTelemetryConfig.fromTelemetryConfig)1 DefaultPrometheusTelemetryConfig.fromTelemetryConfig (org.onosproject.openstacktelemetry.config.DefaultPrometheusTelemetryConfig.fromTelemetryConfig)1