Skip to content

Commit

Permalink
PlaytikaOSS#1063 cleanup generics handling around GenericContainer (P…
Browse files Browse the repository at this point in the history
  • Loading branch information
klu2 committed Dec 5, 2022
1 parent 9c7dc58 commit 20f0189
Show file tree
Hide file tree
Showing 42 changed files with 98 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class AerospikeTestOperations {

private final ExpiredDocumentsCleaner expiredDocumentsCleaner;
private final NetworkTestOperations networkTestOperations;
private final GenericContainer aerospikeContainer;
private final GenericContainer<?> aerospikeContainer;

/**
* @deprecated instead use {@link NetworkTestOperations} directly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public AerospikeWaitStrategy aerospikeStartupCheckStrategy(AerospikeProperties p
@Bean
@ConditionalOnToxiProxyEnabled(module = "aerospike")
ToxiproxyContainer.ContainerProxy aerospikeContainerProxy(ToxiproxyContainer toxiproxyContainer,
GenericContainer aerospike,
GenericContainer<?> aerospike,
AerospikeProperties properties,
ConfigurableEnvironment environment) {
ToxiproxyContainer.ContainerProxy proxy = toxiproxyContainer.getProxy(aerospike, properties.port);
Expand All @@ -67,7 +67,7 @@ ToxiproxyContainer.ContainerProxy aerospikeContainerProxy(ToxiproxyContainer tox


@Bean(name = AEROSPIKE_BEAN_NAME, destroyMethod = "stop")
public GenericContainer aerospike(AerospikeWaitStrategy aerospikeWaitStrategy,
public GenericContainer<?> aerospike(AerospikeWaitStrategy aerospikeWaitStrategy,
ConfigurableEnvironment environment,
AerospikeProperties properties,
Optional<Network> network) {
Expand All @@ -76,7 +76,7 @@ public GenericContainer aerospike(AerospikeWaitStrategy aerospikeWaitStrategy,
.withStrategy(new HostPortWaitStrategy())
.withStartupTimeout(properties.getTimeoutDuration());

GenericContainer aerospike =
GenericContainer<?> aerospike =
new GenericContainer<>(ContainerUtils.getDockerImageName(properties))
.withExposedPorts(properties.port)
// see https://github.com/aerospike/aerospike-server.docker/blob/develop/aerospike.template.conf
Expand All @@ -100,7 +100,7 @@ public GenericContainer aerospike(AerospikeWaitStrategy aerospikeWaitStrategy,
return aerospike;
}

private void registerAerospikeEnvironment(GenericContainer aerospike,
private void registerAerospikeEnvironment(GenericContainer<?> aerospike,
ConfigurableEnvironment environment,
AerospikeProperties properties) {
Integer mappedPort = aerospike.getMappedPort(properties.port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public InstallPackageProperties aerospikePackageProperties() {
@Bean
public PackageInstaller aerospikePackageInstaller(
InstallPackageProperties aerospikePackageProperties,
@Qualifier(AEROSPIKE_BEAN_NAME) GenericContainer aerospike
@Qualifier(AEROSPIKE_BEAN_NAME) GenericContainer<?> aerospike
) {
return new AptGetPackageInstaller(aerospikePackageProperties, aerospike);
}
Expand Down Expand Up @@ -71,7 +71,7 @@ public void cleanExpiredDocumentsBefore(Instant expireTime) {
@Bean
@ConditionalOnMissingBean(name = "aerospikeNetworkTestOperations")
public NetworkTestOperations aerospikeNetworkTestOperations(
@Qualifier(AEROSPIKE_BEAN_NAME) GenericContainer aerospike
@Qualifier(AEROSPIKE_BEAN_NAME) GenericContainer<?> aerospike
) {
return new DefaultNetworkTestOperations(aerospike);
}
Expand All @@ -80,7 +80,7 @@ public NetworkTestOperations aerospikeNetworkTestOperations(
@ConditionalOnMissingBean
public AerospikeTestOperations aerospikeTestOperations(ExpiredDocumentsCleaner expiredDocumentsCleaner,
NetworkTestOperations aerospikeNetworkTestOperations,
@Qualifier(AEROSPIKE_BEAN_NAME) GenericContainer aerospike) {
@Qualifier(AEROSPIKE_BEAN_NAME) GenericContainer<?> aerospike) {
return new AerospikeTestOperations(expiredDocumentsCleaner, aerospikeNetworkTestOperations, aerospike);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public WaitStrategy artifactoryWaitStrategy(ArtifactoryProperties properties) {
}

@Bean(name = ArtifactoryProperties.ARTIFACTORY_BEAN_NAME, destroyMethod = "stop")
public GenericContainer artifactory(ConfigurableEnvironment environment,
public GenericContainer<?> artifactory(ConfigurableEnvironment environment,
ArtifactoryProperties properties,
WaitStrategy artifactoryWaitStrategy) {

GenericContainer container =
new GenericContainer(ContainerUtils.getDockerImageName(properties))
GenericContainer<?> container =
new GenericContainer<>(ContainerUtils.getDockerImageName(properties))
.withExposedPorts(properties.getRestApiPort(), properties.getGeneralPort())
.withNetwork(Network.SHARED)
.withNetworkAliases(properties.getNetworkAlias())
Expand All @@ -57,7 +57,7 @@ public GenericContainer artifactory(ConfigurableEnvironment environment,
return container;
}

private void registerEnvironment(GenericContainer artifactory,
private void registerEnvironment(GenericContainer<?> artifactory,
ConfigurableEnvironment environment,
ArtifactoryProperties properties) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
public class EmbeddedAzuriteBootstrapConfiguration {

@Bean(name = AzuriteProperties.AZURITE_BEAN_NAME, destroyMethod = "stop")
public GenericContainer azurite(ConfigurableEnvironment environment,
public GenericContainer<?> azurite(ConfigurableEnvironment environment,
AzuriteProperties properties) {
GenericContainer container = new GenericContainer(ContainerUtils.getDockerImageName(properties))
GenericContainer<?> container = new GenericContainer<>(ContainerUtils.getDockerImageName(properties))
.withExposedPorts(properties.getPort());

configureCommonsAndStart(container, properties, log);
Expand All @@ -38,7 +38,7 @@ public GenericContainer azurite(ConfigurableEnvironment environment,
return container;
}

private void registerEnvironment(GenericContainer azurite,
private void registerEnvironment(GenericContainer<?> azurite,
ConfigurableEnvironment environment,
AzuriteProperties properties) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
public class EmbeddedConsulBootstrapConfiguration {

@Bean(name = BEAN_NAME_EMBEDDED_CONSUL, destroyMethod = "stop")
public GenericContainer consulContainer(ConfigurableEnvironment environment, ConsulProperties properties) {
GenericContainer consul = new GenericContainer<>(ContainerUtils.getDockerImageName(properties))
public GenericContainer<?> consulContainer(ConfigurableEnvironment environment, ConsulProperties properties) {
GenericContainer<?> consul = new GenericContainer<>(ContainerUtils.getDockerImageName(properties))
.withExposedPorts(properties.getPort())
.waitingFor(
Wait.forHttp("/v1/status/leader")
Expand All @@ -48,7 +48,7 @@ public GenericContainer consulContainer(ConfigurableEnvironment environment, Con
return consul;
}

private void registerConsulEnvironment(GenericContainer consul, ConfigurableEnvironment environment,
private void registerConsulEnvironment(GenericContainer<?> consul, ConfigurableEnvironment environment,
ConsulProperties properties) {
Integer mappedPort = consul.getMappedPort(properties.getPort());
String host = consul.getHost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class EmbeddedConsulBootstrapConfigurationBaseTest {
protected ConfigurableEnvironment environment;

@Autowired
protected GenericContainer consulContainer;
protected GenericContainer<?> consulContainer;

protected ConsulClient buildClient() {
return new ConsulClient(consulContainer.getHost(), consulContainer.getFirstMappedPort());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public InstallPackageProperties couchbasePackageProperties() {
@Bean
public PackageInstaller couchbasePackageInstaller(
InstallPackageProperties couchbasePackageProperties,
@Qualifier(BEAN_NAME_EMBEDDED_COUCHBASE) GenericContainer couchbase
@Qualifier(BEAN_NAME_EMBEDDED_COUCHBASE) GenericContainer<?> couchbase
) {
return new AptGetPackageInstaller(couchbasePackageProperties, couchbase);
}

@Bean
@ConditionalOnMissingBean(name = "couchbaseNetworkTestOperations")
public NetworkTestOperations couchbaseNetworkTestOperations(
@Qualifier(BEAN_NAME_EMBEDDED_COUCHBASE) GenericContainer couchbase
@Qualifier(BEAN_NAME_EMBEDDED_COUCHBASE) GenericContainer<?> couchbase
) {
return new DefaultNetworkTestOperations(couchbase);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
public class EmbeddedDynamoDBBootstrapConfiguration {

@Bean(name = DynamoDBProperties.BEAN_NAME_EMBEDDED_DYNAMODB, destroyMethod = "stop")
public GenericContainer dynamoDb(ConfigurableEnvironment environment,
public GenericContainer<?> dynamoDb(ConfigurableEnvironment environment,
DynamoDBProperties properties) {

GenericContainer container = new GenericContainer(ContainerUtils.getDockerImageName(properties))
GenericContainer<?> container = new GenericContainer<>(ContainerUtils.getDockerImageName(properties))
.withExposedPorts(properties.port)
.waitingFor(new HostPortWaitStrategy());

Expand All @@ -41,7 +41,7 @@ public GenericContainer dynamoDb(ConfigurableEnvironment environment,
return container;
}

private void registerDynamodbEnvironment(GenericContainer container,
private void registerDynamodbEnvironment(GenericContainer<?> container,
ConfigurableEnvironment environment,
DynamoDBProperties properties) {
Integer mappedPort = container.getMappedPort(properties.port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public class EmbeddedPubsubBootstrapConfiguration {
public static final String BEAN_NAME_EMBEDDED_GOOGLE_PUBSUB_MANAGED_CHANNEL = "embeddedGooglePubsubManagedChannel";

@Bean(name = PubsubProperties.BEAN_NAME_EMBEDDED_GOOGLE_PUBSUB, destroyMethod = "stop")
public GenericContainer pubsub(ConfigurableEnvironment environment,
public GenericContainer<?> pubsub(ConfigurableEnvironment environment,
PubsubProperties properties) {
GenericContainer container = new GenericContainer(ContainerUtils.getDockerImageName(properties))
GenericContainer<?> container = new GenericContainer<>(ContainerUtils.getDockerImageName(properties))
.withExposedPorts(properties.getPort())
.withCommand(
"/bin/sh",
Expand All @@ -55,7 +55,7 @@ public GenericContainer pubsub(ConfigurableEnvironment environment,
return container;
}

private void registerPubsubEnvironment(GenericContainer container,
private void registerPubsubEnvironment(GenericContainer<?> container,
ConfigurableEnvironment environment,
PubsubProperties properties) {
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
Expand All @@ -71,7 +71,7 @@ private void registerPubsubEnvironment(GenericContainer container,
}

@Bean(name = BEAN_NAME_EMBEDDED_GOOGLE_PUBSUB_MANAGED_CHANNEL)
public ManagedChannel managedChannel(@Qualifier(PubsubProperties.BEAN_NAME_EMBEDDED_GOOGLE_PUBSUB) GenericContainer pubsub, PubsubProperties properties) {
public ManagedChannel managedChannel(@Qualifier(PubsubProperties.BEAN_NAME_EMBEDDED_GOOGLE_PUBSUB) GenericContainer<?> pubsub, PubsubProperties properties) {
return ManagedChannelBuilder
.forAddress(pubsub.getHost(), pubsub.getMappedPort(properties.getPort())).usePlaintext()
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void shouldHaveContainerWithExpectedDefaultProperties() {
.isNotNull()
.isInstanceOf(GenericContainer.class)
.satisfies(genericContainer -> {
GenericContainer<?> container = (GenericContainer) genericContainer;
GenericContainer<?> container = (GenericContainer<?>) genericContainer;
assertThat(container.getExposedPorts()).containsExactly(8089);
assertThat(container.getCommandParts())
.containsExactly("/bin/sh", "-c", "gcloud beta emulators pubsub start --project my-project-id --host-port=0.0.0.0:8089");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public WaitStrategy grafanaWaitStrategy(GrafanaProperties properties) {
}

@Bean(name = GrafanaProperties.GRAFANA_BEAN_NAME, destroyMethod = "stop")
public GenericContainer grafana(ConfigurableEnvironment environment,
public GenericContainer<?> grafana(ConfigurableEnvironment environment,
GrafanaProperties properties,
WaitStrategy grafanaWaitStrategy) {

GenericContainer container =
new GenericContainer(ContainerUtils.getDockerImageName(properties))
GenericContainer<?> container =
new GenericContainer<>(ContainerUtils.getDockerImageName(properties))
.withEnv("GF_SECURITY_ADMIN_USER", properties.getUsername())
.withEnv("GF_SECURITY_ADMIN_PASSWORD", properties.getPassword())
.withExposedPorts(properties.getPort())
Expand All @@ -59,7 +59,7 @@ public GenericContainer grafana(ConfigurableEnvironment environment,
return container;
}

private void registerEnvironment(GenericContainer grafana,
private void registerEnvironment(GenericContainer<?> grafana,
ConfigurableEnvironment environment,
GrafanaProperties properties) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class KafkaTopicsConfigurer {
private static final int DEFAULT_PARTITION_COUNT = 1;

private final GenericContainer kafka;
private final GenericContainer<?> kafka;
private final ZookeeperConfigurationProperties zookeeperProperties;
private final KafkaConfigurationProperties kafkaProperties;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public InstallPackageProperties kafkaPackageProperties() {

@Bean
public PackageInstaller kafkaPackageInstaller(InstallPackageProperties kafkaPackageProperties,
@Qualifier(KAFKA_BEAN_NAME) GenericContainer kafka) {
@Qualifier(KAFKA_BEAN_NAME) GenericContainer<?> kafka) {
return new YumPackageInstaller(kafkaPackageProperties, kafka);
}

// Current image doesn't support `tc` command, since kafka is currently based on ubi with microdnf package manager. `iproute2` package is not available here.
// This bean is commented, so that users that expect NetworkTestOperations in the tests are notified that this is not supported anymore.
// @Bean
// @ConditionalOnMissingBean(name = "kafkaNetworkTestOperations")
// public NetworkTestOperations kafkaNetworkTestOperations(@Qualifier(KAFKA_BEAN_NAME) GenericContainer kafka) {
// public NetworkTestOperations kafkaNetworkTestOperations(@Qualifier(KAFKA_BEAN_NAME) GenericContainer<?> kafka) {
// return new DefaultNetworkTestOperations(kafka);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ ToxiproxyContainer.ContainerProxy kafkaContainerSaslProxy(ToxiproxyContainer tox
}

@Bean(name = KAFKA_BEAN_NAME, destroyMethod = "stop")
public GenericContainer kafka(
public GenericContainer<?> kafka(
KafkaStatusCheck kafkaStatusCheck,
KafkaConfigurationProperties kafkaProperties,
ZookeeperConfigurationProperties zookeeperProperties,
Expand Down Expand Up @@ -238,7 +238,7 @@ private void zookeperFileSystemBind(ZookeeperConfigurationProperties zookeeperPr
}
}

private void registerKafkaEnvironment(GenericContainer kafka,
private void registerKafkaEnvironment(GenericContainer<?> kafka,
ConfigurableEnvironment environment,
KafkaConfigurationProperties kafkaProperties) {
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
Expand Down Expand Up @@ -267,7 +267,7 @@ private void registerKafkaEnvironment(GenericContainer kafka,

@Bean
public KafkaTopicsConfigurer kafkaConfigurer(
GenericContainer kafka,
GenericContainer<?> kafka,
KafkaConfigurationProperties kafkaProperties,
ZookeeperConfigurationProperties zookeeperProperties) {
return new KafkaTopicsConfigurer(kafka, zookeeperProperties, kafkaProperties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public class SchemaRegistryContainerConfiguration {
public static final String SCHEMA_REGISTRY_HOST_NAME = "schema-registry.testcontainer.docker";

@Bean(name = SCHEMA_REGISTRY_BEAN_NAME, destroyMethod = "stop")
public GenericContainer schemaRegistry(
public GenericContainer<?> schemaRegistry(
ConfigurableEnvironment environment,
SchemaRegistryConfigurationProperties properties,
@Value("${embedded.kafka.containerBrokerList}") String kafkaContainerBrokerList,
Network network) {

GenericContainer schemaRegistry = new GenericContainer<>(ContainerUtils.getDockerImageName(properties))
GenericContainer<?> schemaRegistry = new GenericContainer<>(ContainerUtils.getDockerImageName(properties))
.withCreateContainerCmdModifier(cmd -> cmd.withHostName(SCHEMA_REGISTRY_HOST_NAME))
.withEnv("SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS", "PLAINTEXT://" + kafkaContainerBrokerList)
.withEnv("SCHEMA_REGISTRY_HOST_NAME", SCHEMA_REGISTRY_HOST_NAME)
Expand All @@ -59,7 +59,7 @@ public GenericContainer schemaRegistry(
return schemaRegistry;
}

private void registerSchemaRegistryEnvironment(GenericContainer schemaRegistry, ConfigurableEnvironment environment,
private void registerSchemaRegistryEnvironment(GenericContainer<?> schemaRegistry, ConfigurableEnvironment environment,
SchemaRegistryConfigurationProperties properties) {

String host = schemaRegistry.getHost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class EmbeddedKafkaWithBindingTest extends EmbeddedKafkaTest {

@AfterAll
public static void afterAll(@Autowired KafkaConfigurationProperties kafkaProperties, @Autowired ZookeeperConfigurationProperties zookeeperProperties, @Qualifier(KAFKA_BEAN_NAME) GenericContainer kafka) throws Exception {
public static void afterAll(@Autowired KafkaConfigurationProperties kafkaProperties, @Autowired ZookeeperConfigurationProperties zookeeperProperties, @Qualifier(KAFKA_BEAN_NAME) GenericContainer<?> kafka) throws Exception {
Path projectDir = projectDir();
Path zookeeperDataFolder = projectDir.resolve(zookeeperProperties.getFileSystemBind().getDataFolder());
Path zookeeperTxnLogsFolder = projectDir.resolve(zookeeperProperties.getFileSystemBind().getTxnLogsFolder());
Expand Down

0 comments on commit 20f0189

Please sign in to comment.