org.testcontainers.shaded.com.google.common.collect.ImmutableMap Java Examples

The following examples show how to use org.testcontainers.shaded.com.google.common.collect.ImmutableMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KafkaSourceTester.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, String> produceSourceMessages(int numMessages) throws Exception{
    KafkaProducer<String, String> producer = new KafkaProducer<>(
            ImmutableMap.of(
                    ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers(),
                    ProducerConfig.CLIENT_ID_CONFIG, UUID.randomUUID().toString()
            ),
            new StringSerializer(),
            new StringSerializer()
    );
    LinkedHashMap<String, String> kvs = new LinkedHashMap<>();
    for (int i = 0; i < numMessages; i++) {
        String key = "key-" + i;
        String value = "value-" + i;
        ProducerRecord<String, String> record = new ProducerRecord<>(
            kafkaTopicName,
            key,
            value
        );
        kvs.put(key, value);
        producer.send(record).get();
    }

    log.info("Successfully produced {} messages to kafka topic {}", numMessages, kafkaTopicName);
    return kvs;
}
 
Example #2
Source File: CollisionWhitelistTest.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Test
public void testCool() {
  Properties explicitWhitelist = new Properties();
  explicitWhitelist.setProperty("cool", "2.9.8,3.1.2");

  // Explicitly whitelisted versions
  assertTrue(CollisionWhitelist.isWhitelisted("cool", explicitWhitelist, ImmutableMap.of(
    "2.9.8", ImmutableList.of(COOL_2_9_8),
    "3.1.2", ImmutableList.of(COOL_3_1_2)
  )));


  // More versions then explicitly whitelisted
  assertFalse(CollisionWhitelist.isWhitelisted("cool", explicitWhitelist, ImmutableMap.of(
    "2.9.8", ImmutableList.of(COOL_2_9_8),
    "3.1.2", ImmutableList.of(COOL_3_1_2),
    "4.4.4", ImmutableList.of(COOL_4_4_4)
  )));
}
 
Example #3
Source File: TestStringEL.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Test
public void testMapJoiner() throws Exception {
  ELEvaluator eval = new ELEvaluator("testJoiner", elDefinitionExtractor, StringEL.class, RecordEL.class);
  ELVariables variables = new ELVariables();
  Record record = mock(Record.class);
  Map<String, Field> mapField = ImmutableMap.of(
      "a",
      Field.create(1),
      "b",
      Field.create(Field.Type.INTEGER, null),
      "c",
      Field.create("xyz")
  );
  when(record.get("/map")).thenReturn(Field.create(mapField));
  RecordEL.setRecordInContext(variables, record);
  Assert.assertEquals(
      "a=1,b=null,c=xyz",
      eval.eval(variables, "${map:join(record:value('/map'), ',', '=')}", String.class)
  );
  Assert.assertEquals("", eval.eval(variables, "${map:join(record:value('/not-there'), ',', '=')}", String.class)
  );
}
 
Example #4
Source File: TestElUtil.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
  CredentialStore cs = new CredentialStore() {
    @Override
    public List<ConfigIssue> init(Context context) {
      return null;
    }

    @Override
    public CredentialValue get(String group, String name, String credentialStoreOptions) throws StageException {
      return () -> "secret";
    }

    @Override
    public void destroy() {

    }
  };
  CredentialEL.setCredentialStores(ImmutableMap.of("cs", cs));
}
 
Example #5
Source File: TestActivationResource.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Test
public void testActivationResourceStatsCollectorOptBasedOnLicenseType() throws Exception {
  Activation activation = Mockito.mock(Activation.class);
  StatsCollector statsCollector = Mockito.mock(StatsCollector.class);
  Mockito.when(statsCollector.isOpted()).thenReturn(false);

  Activation.Info mockInfo = Mockito.mock(Activation.Info.class);
  Mockito.when(mockInfo.getAdditionalInfo()).thenReturn(ImmutableMap.of(ActivationResource.LICENSE_TYPE, "TRIAL"));

  ActivationResource resource = new ActivationResource(activation, statsCollector);
  Mockito.when(activation.isEnabled()).thenReturn(true);

  Mockito.when(activation.getInfo()).thenReturn(mockInfo);
  Response response = resource.updateActivation("");
  Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
  Mockito.verify(activation).setActivationKey(Mockito.anyString());
  Mockito.verify(statsCollector).setActive(Mockito.anyBoolean());
}
 
Example #6
Source File: TestActivationResource.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Test
public void testActivationResourceStatsCollectorNoOptLicenseType() throws Exception {
  Activation activation = Mockito.mock(Activation.class);
  StatsCollector statsCollector = Mockito.mock(StatsCollector.class);
  Mockito.when(statsCollector.isOpted()).thenReturn(false);

  Activation.Info mockInfo = Mockito.mock(Activation.Info.class);
  Mockito.when(mockInfo.getAdditionalInfo()).thenReturn(ImmutableMap.of(ActivationResource.LICENSE_TYPE, "NONTRIAL"));

  ActivationResource resource = new ActivationResource(activation, statsCollector);
  Mockito.when(activation.isEnabled()).thenReturn(true);



  Mockito.when(activation.getInfo()).thenReturn(mockInfo);
  Response response = resource.updateActivation("");
  Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
  Mockito.verify(activation).setActivationKey(Mockito.anyString());
  Mockito.verify(statsCollector, Mockito.never()).setActive(Mockito.anyBoolean());
}
 
Example #7
Source File: TestAmazonS3Executor.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Test
public void testApplyTagsBrokenEL() throws Exception {
  AmazonS3ExecutorConfig config = getConfig();
  config.taskConfig.tags = ImmutableMap.of(
    "${record:value('/ke", "${record:value('/value')}"
  );

  AmazonS3Executor executor = new AmazonS3Executor(config);
  TargetRunner runner = new TargetRunner.Builder(AmazonS3DExecutor.class, executor)
    .setOnRecordError(OnRecordError.TO_ERROR)
    .build();
  runner.runInit();

  try {
    runner.runWrite(ImmutableList.of(getTestRecord()));

    Assert.assertEquals(1, runner.getErrorRecords().size());
  } finally {
    runner.runDestroy();
  }
}
 
Example #8
Source File: KafkaIT.java    From apm-agent-java with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() {
    // confluent versions 5.3.0 correspond Kafka versions 2.3.0 -
    // https://docs.confluent.io/current/installation/versions-interoperability.html#cp-and-apache-ak-compatibility
    kafka = new KafkaContainer("5.3.0");
    kafka.start();
    kafkaPort = kafka.getMappedPort(KafkaContainer.KAFKA_PORT);
    bootstrapServers = kafka.getBootstrapServers();
    consumerThread = new Consumer();
    consumerThread.start();
    replyConsumer = createKafkaConsumer();
    replyConsumer.subscribe(Collections.singletonList(REPLY_TOPIC));
    producer = new KafkaProducer<>(
        ImmutableMap.of(
            ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers,
            ProducerConfig.CLIENT_ID_CONFIG, UUID.randomUUID().toString(),
            // This should guarantee that records are batched, as long as they are sent within the configured duration
            ProducerConfig.LINGER_MS_CONFIG, 50
        ),
        new StringSerializer(),
        new StringSerializer()
    );
}
 
Example #9
Source File: KafkaLegacyClientIT.java    From apm-agent-java with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() {
    // confluent versions 5.3.x correspond Kafka versions 2.3.x -
    // https://docs.confluent.io/current/installation/versions-interoperability.html#cp-and-apache-ak-compatibility
    kafka = new KafkaContainer("5.3.0");
    kafka.start();
    kafkaPort = kafka.getMappedPort(KafkaContainer.KAFKA_PORT);
    bootstrapServers = kafka.getBootstrapServers();
    consumerThread = new Consumer();
    consumerThread.start();
    replyConsumer = createKafkaConsumer();
    replyConsumer.subscribe(Collections.singletonList(REPLY_TOPIC));
    producer = new KafkaProducer<>(
        ImmutableMap.of(
            ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers,
            ProducerConfig.CLIENT_ID_CONFIG, UUID.randomUUID().toString(),
            // This should guarantee that records are batched, as long as they are sent within the configured duration
            ProducerConfig.LINGER_MS_CONFIG, 50
        ),
        new StringSerializer(),
        new StringSerializer()
    );
}
 
Example #10
Source File: KafkaLegacyBrokerIT.java    From apm-agent-java with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() {
    reporter.disableDestinationAddressCheck();

    // confluent versions 3.2.x correspond Kafka versions 0.10.2.2 -
    // https://docs.confluent.io/current/installation/versions-interoperability.html#cp-and-apache-ak-compatibility
    kafka = new KafkaContainer("3.2.2");
    kafka.start();
    bootstrapServers = kafka.getBootstrapServers();
    consumerThread = new Consumer();
    consumerThread.start();
    replyConsumer = createKafkaConsumer();
    replyConsumer.subscribe(Collections.singletonList(REPLY_TOPIC));
    producer = new KafkaProducer<>(
        ImmutableMap.of(
            ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers,
            ProducerConfig.CLIENT_ID_CONFIG, UUID.randomUUID().toString(),
            // This should guarantee that records are batched, as long as they are sent within the configured duration
            ProducerConfig.LINGER_MS_CONFIG, 50
        ),
        new StringSerializer(),
        new StringSerializer()
    );
}
 
Example #11
Source File: Environments.java    From presto with Apache License 2.0 5 votes vote down vote up
public static void pruneEnvironment()
{
    log.info("Shutting down previous containers");
    try (DockerClient dockerClient = DockerClientFactory.lazyClient()) {
        killContainers(
                dockerClient,
                listContainersCmd -> listContainersCmd.withLabelFilter(ImmutableMap.of(PRODUCT_TEST_LAUNCHER_STARTED_LABEL_NAME, PRODUCT_TEST_LAUNCHER_STARTED_LABEL_VALUE)));
        removeNetworks(
                dockerClient,
                listNetworksCmd -> listNetworksCmd.withNameFilter(PRODUCT_TEST_LAUNCHER_NETWORK));
    }
    catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example #12
Source File: KafkaLegacyBrokerIT.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
static KafkaConsumer<String, String> createKafkaConsumer() {
    return new KafkaConsumer<>(
        ImmutableMap.of(
            ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers,
            ConsumerConfig.GROUP_ID_CONFIG, "tc-" + UUID.randomUUID(),
            ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"
        ),
        new StringDeserializer(),
        new StringDeserializer()
    );
}
 
Example #13
Source File: CollisionWhitelistTest.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testJackson() {
  // Normal, but unusual state
  assertTrue(CollisionWhitelist.isWhitelisted("jackson", null, ImmutableMap.of(
    "2.8.9", ImmutableList.of(JACKSON_2_8_9)
  )));

  // Another normal "major" state - 1.x and 2.x can be on the classpath at the same time
  assertTrue(CollisionWhitelist.isWhitelisted("jackson", null, ImmutableMap.of(
    "1.9.13", ImmutableList.of(JACKSON_1_9_13),
    "2.8.9", ImmutableList.of(JACKSON_2_8_9)
  )));

  // Correct Jackson weirdness - 2.8.9 anything depends on 2.8.0 annotations
  assertTrue(CollisionWhitelist.isWhitelisted("jackson", null, ImmutableMap.of(
    "2.8.0", ImmutableList.of(JACKSON_2_8_0_ANN),
    "2.8.9", ImmutableList.of(JACKSON_2_8_9)
  )));

  // Incorrect - only ANN can be 2.8.0 and rest on a different dot-dot version
  assertFalse(CollisionWhitelist.isWhitelisted("jackson", null, ImmutableMap.of(
    "2.8.0", ImmutableList.of(JACKSON_2_8_0),
    "2.8.9", ImmutableList.of(JACKSON_2_8_9)
  )));

  // Correct Jackson weirdness - can also merge multiple major versions ...
  assertTrue(CollisionWhitelist.isWhitelisted("jackson", null, ImmutableMap.of(
    "1.3..0", ImmutableList.of(JACKSON_1_9_13),
    "2.8.0", ImmutableList.of(JACKSON_2_8_0_ANN),
    "2.8.9", ImmutableList.of(JACKSON_2_8_9)
  )));

  // 2.8.0 for API is allowed only, all other versions must match
  assertFalse(CollisionWhitelist.isWhitelisted("jackson", null, ImmutableMap.of(
    "2.8.0", ImmutableList.of(JACKSON_2_8_0_ANN),
    "2.8.9", ImmutableList.of(JACKSON_2_8_9),
    "2.3.5", ImmutableList.of(JACKSON_2_3_5)
  )));
}
 
Example #14
Source File: CollisionWhitelistTest.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testNetty() {
  // Two different major versions should be whitelisted
  assertTrue(CollisionWhitelist.isWhitelisted("netty", null, ImmutableMap.of(
    "3.1.2", ImmutableList.of(NETTY_3_1_2),
    "4.8.0", ImmutableList.of(NETTY_4_8_0)
  )));

  // Different minor on the same major should be an error
  assertFalse(CollisionWhitelist.isWhitelisted("netty", null, ImmutableMap.of(
    "3.1.2", ImmutableList.of(NETTY_3_1_2),
    "3.5.3", ImmutableList.of(NETTY_3_5_3)
  )));

  // Major "2" is not whitelisted at all
  assertFalse(CollisionWhitelist.isWhitelisted("netty", null, ImmutableMap.of(
    "2.9.8", ImmutableList.of(NETTY_2_9_8),
    "3.5.3", ImmutableList.of(NETTY_3_5_3)
  )));

  // Two different minor are wrong regardless how many major versions are whitelisted
  assertFalse(CollisionWhitelist.isWhitelisted("netty", null, ImmutableMap.of(
    "3.1.2", ImmutableList.of(NETTY_3_1_2),
    "3.5.3", ImmutableList.of(NETTY_3_5_3),
    "4.8.0", ImmutableList.of(NETTY_4_8_0)
  )));
}
 
Example #15
Source File: TestMongoDistributedQueries.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
protected QueryRunner createQueryRunner()
        throws Exception
{
    this.server = new MongoServer();
    return createMongoQueryRunner(server, ImmutableMap.of(), TpchTable.getTables());
}
 
Example #16
Source File: TestActivationUtil.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvalidActivationInfo() {
  String maxExecutors = "invalid";
  Activation activation = mock(Activation.class);
  Mockito.when(activation.isEnabled()).thenReturn(true);

  Activation.Info info = mock(Activation.Info.class);
  Mockito.when(info.isValid()).thenReturn(true);
  Mockito.when(info.getAdditionalInfo())
      .thenReturn(ImmutableMap.of(ActivationUtil.sparkMaxExecutorsParamName, maxExecutors));
  Mockito.when(activation.getInfo()).thenReturn(info);

  Assert.assertEquals(ActivationUtil.defaultMaxExecutors, ActivationUtil.getMaxExecutors(activation));
}
 
Example #17
Source File: TestActivationUtil.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testValidActivation() {
  int maxExecutors = 1000;
  Activation activation = mock(Activation.class);
  Mockito.when(activation.isEnabled()).thenReturn(true);

  Activation.Info info = mock(Activation.Info.class);
  Mockito.when(info.isValid()).thenReturn(true);
  Mockito.when(info.getAdditionalInfo())
      .thenReturn(ImmutableMap.of(ActivationUtil.sparkMaxExecutorsParamName, maxExecutors));
  Mockito.when(activation.getInfo()).thenReturn(info);

  Assert.assertEquals(maxExecutors, ActivationUtil.getMaxExecutors(activation));
}
 
Example #18
Source File: KafkaLegacyClientIT.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
static KafkaConsumer<String, String> createKafkaConsumer() {
    return new KafkaConsumer<>(
            ImmutableMap.of(
                    ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers,
                    ConsumerConfig.GROUP_ID_CONFIG, "tc-" + UUID.randomUUID(),
                    ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"
            ),
            new StringDeserializer(),
            new StringDeserializer()
    );
}
 
Example #19
Source File: TestRuleDefinitionValidator.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testInValidConfiguration() {
  List<Config> rulesConfiguration = ImmutableList.of(
      new Config("emailIDs", ImmutableList.of("${USER_EMAIL_ID}"))
  );
  RuleDefinitions ruleDefinitions = new RuleDefinitions(
      FilePipelineStoreTask.RULE_DEFINITIONS_SCHEMA_VERSION,
      RuleDefinitionsConfigBean.VERSION,
      Collections.<MetricsRuleDefinition>emptyList(),
      Collections.<DataRuleDefinition>emptyList(),
      Collections.<DriftRuleDefinition>emptyList(),
      null,
      UUID.randomUUID(),
      rulesConfiguration
  );

  RuleDefinitionValidator ruleDefinitionValidator = new RuleDefinitionValidator(
      "pipelineId",
      ruleDefinitions,
      Collections.emptyMap()
  );

  Assert.assertFalse(ruleDefinitionValidator.validateRuleDefinition());
  Assert.assertNotNull(ruleDefinitions.getConfigIssues());
  Assert.assertEquals(1, ruleDefinitions.getConfigIssues().size());
  Assert.assertEquals("emailIDs", ruleDefinitions.getConfigIssues().get(0).getConfigName());
  Assert.assertTrue(
      ruleDefinitions.getConfigIssues().get(0).getMessage().contains("'USER_EMAIL_ID' cannot be resolved")
  );

  ruleDefinitionValidator = new RuleDefinitionValidator(
      "pipelineId",
      ruleDefinitions,
      ImmutableMap.of("USER_EMAIL_ID", "[email protected]")
  );

  Assert.assertTrue(ruleDefinitionValidator.validateRuleDefinition());
  Assert.assertNotNull(ruleDefinitions.getConfigIssues());
  Assert.assertEquals(0, ruleDefinitions.getConfigIssues().size());
}
 
Example #20
Source File: TestAmazonS3Executor.java    From datacollector with Apache License 2.0 5 votes vote down vote up
private Record getTestRecord() {
  Record record = RecordCreator.create();
  record.getHeader().setAttribute("bucket", BUCKET_NAME);
  record.set(Field.create(Field.Type.MAP, ImmutableMap.of(
    "object", Field.create(objectName),
    "key", Field.create("Owner"),
    "value", Field.create("Earth"),
    "content", Field.create("Secret")
  )));

  return record;
}
 
Example #21
Source File: KafkaSinkTester.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
public void prepareSink() throws Exception {
    ExecResult execResult = serviceContainer.execInContainer(
        "/usr/bin/kafka-topics",
        "--create",
        "--zookeeper",
        "localhost:2181",
        "--partitions",
        "1",
        "--replication-factor",
        "1",
        "--topic",
        kafkaTopicName);
    assertTrue(
        execResult.getStdout().contains("Created topic"),
        execResult.getStdout());

    kafkaConsumer = new KafkaConsumer<>(
        ImmutableMap.of(
            ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, serviceContainer.getBootstrapServers(),
            ConsumerConfig.GROUP_ID_CONFIG, "sink-test-" + randomName(8),
            ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"
        ),
        new StringDeserializer(),
        new StringDeserializer()
    );
    kafkaConsumer.subscribe(Arrays.asList(kafkaTopicName));
    log.info("Successfully subscribe to kafka topic {}", kafkaTopicName);
}
 
Example #22
Source File: KafkaConnectConverterIT.java    From apicurio-registry with Apache License 2.0 5 votes vote down vote up
private KafkaConsumer<byte[], byte[]> getConsumerBytes(KafkaContainer kafkaContainer) {
    return new KafkaConsumer<>(
        ImmutableMap.of(
            ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092",
            ConsumerConfig.GROUP_ID_CONFIG, "tc-" + UUID.randomUUID(),
            ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"),
        new ByteArrayDeserializer(),
        new ByteArrayDeserializer());
}
 
Example #23
Source File: KafkaSourceTester.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
public void prepareSource() throws Exception {
    ExecResult execResult = kafkaContainer.execInContainer(
        "/usr/bin/kafka-topics",
        "--create",
        "--zookeeper",
        "localhost:2181",
        "--partitions",
        "1",
        "--replication-factor",
        "1",
        "--topic",
        kafkaTopicName);
    assertTrue(
        execResult.getStdout().contains("Created topic"),
        execResult.getStdout());

    kafkaConsumer = new KafkaConsumer<>(
        ImmutableMap.of(
            ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers(),
            ConsumerConfig.GROUP_ID_CONFIG, "source-test-" + randomName(8),
            ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"
        ),
        new StringDeserializer(),
        new StringDeserializer()
    );
    kafkaConsumer.subscribe(Arrays.asList(kafkaTopicName));
    log.info("Successfully subscribe to kafka topic {}", kafkaTopicName);
}
 
Example #24
Source File: SlaveFailoverTest.java    From replicator with Apache License 2.0 5 votes vote down vote up
private static boolean initializeSlave(ServicesControl mysqlMaster,
                                        ServicesControl mysqlSlave,
                                        MySQLConfiguration configuration) {
    return MYSQL_RUNNER.runMysqlScript(mysqlSlave,
            configuration,
            new File("src/test/resources/" + SlaveFailoverTest.MYSQL_SLAVE_INIT_SCRIPT).getAbsolutePath(),
            ImmutableMap.of("MASTER_HOSTNAME", mysqlMaster.getContainer().getContainerInfo().getConfig().getHostName(),
                    "MASTER_USER", MYSQL_USERNAME,
                    "MASTER_PASSWORD", MYSQL_PASSWORD),
            true
    );
}
 
Example #25
Source File: HaystackKafkaForwarderTest.java    From pitchfork with Apache License 2.0 5 votes vote down vote up
/**
 * Create consumer and subscribe to spans topic.
 */
private KafkaConsumer<String, byte[]> setupConsumer() {
    KafkaConsumer<String, byte[]> consumer = new KafkaConsumer<>(
            ImmutableMap.of(
                    ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers(),
                    ConsumerConfig.GROUP_ID_CONFIG, "test-group",
                    ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"
            ),
            new StringDeserializer(),
            new ByteArrayDeserializer()
    );
    consumer.subscribe(singletonList("proto-spans"));

    return consumer;
}
 
Example #26
Source File: KafkaIngressTest.java    From pitchfork with Apache License 2.0 5 votes vote down vote up
/**
 * Create consumer and subscribe to spans topic.
 */
private KafkaConsumer<String, byte[]> setupConsumer() {
    KafkaConsumer<String, byte[]> consumer = new KafkaConsumer<>(
            ImmutableMap.of(
                    ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers(),
                    ConsumerConfig.GROUP_ID_CONFIG, "test-group",
                    ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"
            ),
            new StringDeserializer(),
            new ByteArrayDeserializer()
    );
    consumer.subscribe(singletonList("proto-spans"));

    return consumer;
}
 
Example #27
Source File: RabbitMqIngressTest.java    From pitchfork with Apache License 2.0 5 votes vote down vote up
/**
 * Create consumer and subscribe to spans topic.
 */
private KafkaConsumer<String, byte[]> setupConsumer() {
    KafkaConsumer<String, byte[]> consumer = new KafkaConsumer<>(
            ImmutableMap.of(
                    ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers(),
                    ConsumerConfig.GROUP_ID_CONFIG, "test-group",
                    ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"
            ),
            new StringDeserializer(),
            new ByteArrayDeserializer()
    );
    consumer.subscribe(singletonList("proto-spans"));

    return consumer;
}
 
Example #28
Source File: KafkaIT.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
static KafkaConsumer<String, String> createKafkaConsumer() {
    return new KafkaConsumer<>(
        ImmutableMap.of(
            ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers,
            ConsumerConfig.GROUP_ID_CONFIG, "tc-" + UUID.randomUUID(),
            ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"
        ),
        new StringDeserializer(),
        new StringDeserializer()
    );
}
 
Example #29
Source File: ProfileE2E.java    From skywalking with Apache License 2.0 4 votes vote down vote up
private ResponseEntity<String> sendRequest(boolean needProfiling) {
    final Map<String, String> user = ImmutableMap.of(
        "name", "SkyWalking", "enableProfiling", String.valueOf(needProfiling)
    );
    return restTemplate.postForEntity(instrumentedServiceUrl + "/profile/users?e2e=true", user, String.class);
}
 
Example #30
Source File: DatastoreEntityExtension.java    From nomulus with Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, Object> getAttributes() {
  return ImmutableMap.of();
}