/** * Create an Elasticsearch Container by passing the full docker image name * @param dockerImageName Full docker image name, like: docker.elastic.co/elasticsearch/elasticsearch:6.4.1 */ public ElasticsearchContainer(String dockerImageName) { super(dockerImageName); logger().info("Starting an elasticsearch container using [{}]", dockerImageName); withNetworkAliases("elasticsearch-" + Base58.randomString(6)); withEnv("discovery.type", "single-node"); addExposedPorts(ELASTICSEARCH_DEFAULT_PORT, ELASTICSEARCH_DEFAULT_TCP_PORT); setWaitStrategy(new HttpWaitStrategy() .forPort(ELASTICSEARCH_DEFAULT_PORT) .forStatusCodeMatching(response -> response == HTTP_OK || response == HTTP_UNAUTHORIZED) .withStartupTimeout(Duration.ofMinutes(2))); }
@Test public void testWaitingFails() { final DockerComposeContainer environment = new DockerComposeContainer(new File("src/test/resources/compose-test.yml")) .withExposedService("redis_1", REDIS_PORT, Wait.forHttp("/test").withStartupTimeout(Duration.ofSeconds(10))); VisibleAssertions.assertThrows("waiting on an invalid http path times out", RuntimeException.class, () -> environment.starting(Description.createTestDescription(Object.class, "name"))); }
@BeforeClass public static void setUp() throws Exception { TestUtil.ignoreException(() -> { mongo = new GenericContainer("mongo:3") .withNetworkAliases("mongo-" + Base58.randomString(6)) .withExposedPorts(MONGO_DEFAULT_PORT) .waitingFor(new HttpWaitStrategy() .forPort(MONGO_DEFAULT_PORT) .forStatusCodeMatching(response -> response == HTTP_OK || response == HTTP_UNAUTHORIZED) .withStartupTimeout(Duration.ofMinutes(2))); mongo.start(); }, Exception.class); assumeNotNull(mongo); assumeTrue("Mongo DB must be running", mongo.isRunning()); MongoClient mongoClient = new MongoClient(mongo.getContainerIpAddress(), mongo.getMappedPort(MONGO_DEFAULT_PORT)); HOST = String.format("mongodb://%s:%s", mongo.getContainerIpAddress(), mongo.getMappedPort(MONGO_DEFAULT_PORT)); params = map("host", HOST, "db", "test", "collection", "test"); MongoDatabase database = mongoClient.getDatabase("test"); collection = database.getCollection("test"); collection.deleteMany(new Document()); collection.insertOne(new Document(map("name", "testDocument", "date", currentTime, "longValue", longValue))); db = new TestGraphDatabaseFactory() .newImpermanentDatabaseBuilder() .newGraphDatabase(); TestUtil.registerProcedure(db, MongoDB.class); mongoClient.close(); }
/** * Create an Elasticsearch Container by passing the full docker image name * @param dockerImageName Full docker image name, like: docker.elastic.co/elasticsearch/elasticsearch:6.4.1 */ public ElasticsearchContainer(String dockerImageName) { super(dockerImageName); logger().info("Starting an elasticsearch container using [{}]", dockerImageName); withNetworkAliases("elasticsearch-" + Base58.randomString(6)); withEnv("discovery.type", "single-node"); addExposedPorts(ELASTICSEARCH_DEFAULT_PORT, ELASTICSEARCH_DEFAULT_TCP_PORT); setWaitStrategy(new HttpWaitStrategy() .forPort(ELASTICSEARCH_DEFAULT_PORT) .forStatusCodeMatching(response -> response == HTTP_OK || response == HTTP_UNAUTHORIZED) .withStartupTimeout(Duration.ofMinutes(2))); }
@BeforeClass void before() throws Exception { SvnTestHelper.skipTestIfDockerUnavailable(); String gitlabVersion = System.getenv("GITLAB_VERSION"); if (gitlabVersion == null) { if (System.getenv("TRAVIS") != null) throw new SkipException("Only run gitlab tests on Travis when explicitly asked"); gitlabVersion = "latest"; } final int gitlabPort = 80; gitlab = new GenericContainer<>("gitlab/gitlab-ce:" + gitlabVersion) .withEnv("GITLAB_ROOT_PASSWORD", rootPassword) .withExposedPorts(gitlabPort) .waitingFor(Wait.forHttp("/users/sign_in") .withStartupTimeout(Duration.of(10, ChronoUnit.MINUTES))); gitlab.start(); gitlabUrl = "http://" + gitlab.getContainerIpAddress() + ":" + gitlab.getMappedPort(gitlabPort); rootToken = createToken(root, rootPassword, true); final GitlabAPI rootAPI = GitLabContext.connect(gitlabUrl, rootToken); final GitlabUser gitlabUser = rootAPI.createUser(new CreateUserRequest(user, user, "git-as-svn@localhost").setPassword(userPassword)); Assert.assertNotNull(gitlabUser); final GitlabGroup group = rootAPI.createGroup(new CreateGroupRequest("testGroup").setVisibility(GitlabVisibility.PUBLIC), null); Assert.assertNotNull(group); Assert.assertNotNull(rootAPI.addGroupMember(group.getId(), gitlabUser.getId(), GitlabAccessLevel.Developer)); gitlabProject = createGitlabProject(rootAPI, group, "test", GitlabVisibility.INTERNAL, Collections.singleton("git-as-svn")); gitlabPublicProject = createGitlabProject(rootAPI, group, "publik", GitlabVisibility.PUBLIC, Collections.emptySet()); }
.withExposedPorts(giteaPort, svnPort, sshPort) .waitingFor(Wait.forHttp(path).forPort(giteaPort) .withStartupTimeout(Duration.of(120, ChronoUnit.SECONDS))); Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(log);