Skip to content

Commit

Permalink
fix SolrTest failure when using CloundContainer apache#2967
Browse files Browse the repository at this point in the history
  • Loading branch information
ffang committed Aug 20, 2021
1 parent aa7bbd1 commit 716df28
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import org.apache.camel.util.CollectionHelper;
import org.apache.commons.lang3.SystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.BindMode;
Expand Down Expand Up @@ -111,10 +112,17 @@ private void createSslContainer() {
* creates a cloud container with zookeeper
*/
private void createCloudContainer() {
cloudContainer = new DockerComposeContainer(new File("src/test/resources/cloud-docker-compose.yml"))
.withExposedService("solr1", SOLR_PORT)
.withExposedService("zoo1", ZOOKEEPER_PORT)
.waitingFor("create-collection", Wait.forLogMessage(".*Created collection 'collection1'.*", 1));
if (SystemUtils.IS_OS_LINUX) {
cloudContainer = new DockerComposeContainer(new File("src/test/resources/cloud-docker-compose.yml"))
.withExposedService("solr1", SOLR_PORT)
.withExposedService("zoo1", ZOOKEEPER_PORT)
.waitingFor("create-collection", Wait.forLogMessage(".*Created collection 'collection1'.*", 1));
} else {
cloudContainer = new DockerComposeContainer(new File("src/test/resources/cloud-docker-compose_nonlinux.yml"))
.withExposedService("solr1", SOLR_PORT)
.withExposedService("zoo1", ZOOKEEPER_PORT)
.waitingFor("create-collection", Wait.forLogMessage(".*Created collection 'collection1'.*", 1));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# based on https://raw.githubusercontent.com/docker-solr/docker-solr-examples/master/docker-compose/docker-compose.yml
version: '3.7'
services:
solr1:
image: solr:8.7.0
ports:
- "8983:8983"
environment:
- ZK_HOST=zoo1:2181
- SOLR_PORT=8983
- SOLR_HOST=localhost
networks:
- solr
depends_on:
- zoo1

zoo1:
image: zookeeper:3.6.2
restart: always
hostname: zoo1
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zoo1:2888:3888;2181
networks:
- solr

create-collection:
image: solr:8.7.0
environment:
- SOLR_HOST=solr1
networks:
- solr
command:
- bash
- "-e"
- "-x"
- "-c"
- "wait-for-solr.sh --max-attempts 10 --wait-seconds 5 --solr-url http://$$SOLR_HOST:8983/; solr create_collection -c collection1 -p 8983"

networks:
solr:

0 comments on commit 716df28

Please sign in to comment.