use of org.testcontainers.utility.DockerImageName in project testcontainers-java by testcontainers.
the class AuthDelegatingDockerClientConfig method effectiveAuthConfig.
@Override
public AuthConfig effectiveAuthConfig(String imageName) {
// allow docker-java auth config to be used as a fallback
AuthConfig fallbackAuthConfig;
try {
fallbackAuthConfig = super.effectiveAuthConfig(imageName);
} catch (Exception e) {
log.debug("Delegate call to effectiveAuthConfig failed with cause: '{}'. " + "Resolution of auth config will continue using RegistryAuthLocator.", e.getMessage());
fallbackAuthConfig = new AuthConfig();
}
// try and obtain more accurate auth config using our resolution
final DockerImageName parsed = DockerImageName.parse(imageName);
final AuthConfig effectiveAuthConfig = RegistryAuthLocator.instance().lookupAuthConfig(parsed, fallbackAuthConfig);
log.debug("Effective auth config [{}]", toSafeString(effectiveAuthConfig));
return effectiveAuthConfig;
}
use of org.testcontainers.utility.DockerImageName in project drill by apache.
the class TestJdbcPluginWithClickhouse method initClickhouse.
@BeforeClass
public static void initClickhouse() throws Exception {
startCluster(ClusterFixture.builder(dirTestWatcher));
String osName = System.getProperty("os.name").toLowerCase();
DockerImageName imageName;
if (osName.startsWith("linux") && "aarch64".equals(System.getProperty("os.arch"))) {
imageName = DockerImageName.parse(DOCKER_IMAGE_CLICKHOUSE_ARM).asCompatibleSubstituteFor("yandex/clickhouse-server");
} else {
imageName = DockerImageName.parse(DOCKER_IMAGE_CLICKHOUSE_X86);
}
jdbcContainer = new ClickHouseContainer(imageName).withInitScript("clickhouse-test-data.sql");
jdbcContainer.start();
JdbcStorageConfig jdbcStorageConfig = new JdbcStorageConfig("ru.yandex.clickhouse.ClickHouseDriver", jdbcContainer.getJdbcUrl(), jdbcContainer.getUsername(), null, true, false, null, null, 0);
jdbcStorageConfig.setEnabled(true);
cluster.defineStoragePlugin("clickhouse", jdbcStorageConfig);
}
use of org.testcontainers.utility.DockerImageName in project drill by apache.
the class TestJdbcPluginWithMySQLIT method initMysql.
@BeforeClass
public static void initMysql() throws Exception {
startCluster(ClusterFixture.builder(dirTestWatcher));
String osName = System.getProperty("os.name").toLowerCase();
String mysqlDBName = "drill_mysql_test";
DockerImageName imageName;
if (osName.startsWith("linux") && "aarch64".equals(System.getProperty("os.arch"))) {
imageName = DockerImageName.parse(DOCKER_IMAGE_MARIADB).asCompatibleSubstituteFor("mysql");
} else {
imageName = DockerImageName.parse(DOCKER_IMAGE_MYSQL);
}
jdbcContainer = new MySQLContainer<>(imageName).withExposedPorts(3306).withConfigurationOverride("mysql_config_override").withUsername("mysqlUser").withPassword("mysqlPass").withDatabaseName(mysqlDBName).withUrlParam("serverTimezone", "UTC").withUrlParam("useJDBCCompliantTimezoneShift", "true").withInitScript("mysql-test-data.sql");
jdbcContainer.start();
if (osName.startsWith("linux")) {
JdbcDatabaseDelegate databaseDelegate = new JdbcDatabaseDelegate(jdbcContainer, "");
ScriptUtils.runInitScript(databaseDelegate, "mysql-test-data-linux.sql");
}
String jdbcUrl = jdbcContainer.getJdbcUrl();
JdbcStorageConfig jdbcStorageConfig = new JdbcStorageConfig("com.mysql.cj.jdbc.Driver", jdbcUrl, jdbcContainer.getUsername(), jdbcContainer.getPassword(), false, false, null, null, 10000);
jdbcStorageConfig.setEnabled(true);
cluster.defineStoragePlugin("mysql", jdbcStorageConfig);
if (osName.startsWith("linux")) {
// adds storage plugin with case insensitive table names
JdbcStorageConfig jdbcCaseSensitiveStorageConfig = new JdbcStorageConfig("com.mysql.cj.jdbc.Driver", jdbcUrl, jdbcContainer.getUsername(), jdbcContainer.getPassword(), true, false, null, null, 10000);
jdbcCaseSensitiveStorageConfig.setEnabled(true);
cluster.defineStoragePlugin("mysqlCaseInsensitive", jdbcCaseSensitiveStorageConfig);
}
}
use of org.testcontainers.utility.DockerImageName in project testcontainers-java by testcontainers.
the class OutOfPackageImagePullPolicyTest method shouldSupportCustomPoliciesOutOfTestContainersPackage.
@Test
public void shouldSupportCustomPoliciesOutOfTestContainersPackage() {
try (GenericContainer<?> container = new GenericContainer<>(TINY_IMAGE).withImagePullPolicy(new AbstractImagePullPolicy() {
@Override
protected boolean shouldPullCached(DockerImageName imageName, ImageData localImageData) {
return false;
}
})) {
container.withStartupCheckStrategy(new OneShotStartupCheckStrategy());
container.start();
}
}
use of org.testcontainers.utility.DockerImageName in project testcontainers-java by testcontainers.
the class ImagePullPolicyTest method shouldSupportCustomPolicies.
@Test
public void shouldSupportCustomPolicies() {
try (// custom_image_pull_policy {
GenericContainer<?> container = new GenericContainer<>(imageName).withImagePullPolicy(new AbstractImagePullPolicy() {
@Override
protected boolean shouldPullCached(DockerImageName imageName, ImageData localImageData) {
return System.getenv("ALWAYS_PULL_IMAGE") != null;
}
})) // }
{
container.withStartupCheckStrategy(new OneShotStartupCheckStrategy());
container.start();
}
}
Aggregations