Skip to content

Commit 2b47840

Browse files
capistrantcecemei
andauthored
Use openjdk:17-slim as base image for IT (#18251) (#18256)
Co-authored-by: Cece Mei <yingqian.mei@gmail.com>
1 parent 07d3df2 commit 2b47840

File tree

6 files changed

+54
-41
lines changed

6 files changed

+54
-41
lines changed

integration-tests/docker/Dockerfile

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
ARG JDK_VERSION=17-slim-buster
16+
ARG JDK_VERSION=17-slim-bullseye
1717
FROM openjdk:$JDK_VERSION as druidbase
1818

1919
# Bundle everything into one script so cleanup can reduce image size.
@@ -27,7 +27,6 @@ ARG ZK_VERSION
2727
ARG APACHE_ARCHIVE_MIRROR_HOST=https://downloads.apache.org
2828
RUN APACHE_ARCHIVE_MIRROR_HOST=${APACHE_ARCHIVE_MIRROR_HOST} /root/base-setup.sh && rm -f /root/base-setup.sh
2929

30-
3130
FROM druidbase
3231
ARG MYSQL_VERSION
3332
ARG MARIA_VERSION
@@ -37,14 +36,6 @@ ARG CONFLUENT_VERSION
3736
# Verify Java version
3837
RUN java -version
3938

40-
RUN echo "[mysqld]\ncharacter-set-server=utf8\ncollation-server=utf8_bin\n" >> /etc/mysql/my.cnf
41-
42-
# Setup metadata store
43-
# touch is needed because OverlayFS's copy-up operation breaks POSIX standards. See https://github.com/docker/for-linux/issues/72.
44-
RUN find /var/lib/mysql -type f -exec touch {} \; && /etc/init.d/mysql start \
45-
&& echo "CREATE USER 'druid'@'%' IDENTIFIED BY 'diurd'; GRANT ALL ON druid.* TO 'druid'@'%'; CREATE database druid DEFAULT CHARACTER SET utf8mb4;" | mysql -u root \
46-
&& /etc/init.d/mysql stop
47-
4839
# Add Druid scripts and jars
4940
ADD bin/* /usr/local/druid/bin/
5041
ADD lib/* /usr/local/druid/lib/
@@ -65,11 +56,17 @@ RUN if [ "$MYSQL_DRIVER_CLASSNAME" = "com.mysql.jdbc.Driver" ] ; \
6556
RUN wget -q "https://packages.confluent.io/maven/io/confluent/kafka-protobuf-provider/$CONFLUENT_VERSION/kafka-protobuf-provider-$CONFLUENT_VERSION.jar" \
6657
-O /usr/local/druid/lib/kafka-protobuf-provider.jar
6758

68-
# Add sample data
69-
# touch is needed because OverlayFS's copy-up operation breaks POSIX standards. See https://github.com/docker/for-linux/issues/72.
70-
RUN find /var/lib/mysql -type f -exec touch {} \; && service mysql start \
71-
&& /usr/local/druid/bin/run-java -cp "/usr/local/druid/lib/*" -Ddruid.extensions.directory=/usr/local/druid/extensions -Ddruid.extensions.loadList='["mysql-metadata-storage"]' -Ddruid.metadata.storage.type=mysql -Ddruid.metadata.mysql.driver.driverClassName=$MYSQL_DRIVER_CLASSNAME org.apache.druid.cli.Main tools metadata-init --connectURI="jdbc:mysql://localhost:3306/druid" --user=druid --password=diurd \
72-
&& /etc/init.d/mysql stop
59+
# Setup metadata store
60+
ADD run-mysql.sh /run-mysql.sh
61+
RUN echo "[mysqld]\ncharacter-set-server=utf8\ncollation-server=utf8_bin\n" >> /etc/mysql/my.cnf
62+
RUN mkdir -p /run/mysqld && chown mysql:mysql /run/mysqld
63+
RUN ( \
64+
bash /run-mysql.sh; \
65+
echo "CREATE USER 'druid'@'%' IDENTIFIED BY 'diurd'; GRANT ALL ON druid.* TO 'druid'@'%'; CREATE database druid DEFAULT CHARACTER SET utf8mb4;" | mysql -u root; \
66+
/usr/local/druid/bin/run-java -cp "/usr/local/druid/lib/*" -Ddruid.extensions.directory=/usr/local/druid/extensions -Ddruid.extensions.loadList='["mysql-metadata-storage"]' -Ddruid.metadata.storage.type=mysql -Ddruid.metadata.mysql.driver.driverClassName=$MYSQL_DRIVER_CLASSNAME org.apache.druid.cli.Main tools metadata-init --connectURI="jdbc:mysql://localhost:3306/druid" --user=druid --password=diurd; \
67+
mysqladmin shutdown \
68+
)
69+
7370
ADD test-data /test-data
7471

7572
# Setup supervisord
@@ -78,9 +75,6 @@ ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
7875
# Add druid configuration setup script
7976
ADD druid.sh /druid.sh
8077

81-
# mysql
82-
ADD run-mysql.sh /run-mysql.sh
83-
8478
# internal docker_ip:9092 endpoint is used to access Kafka from other Docker containers
8579
# external docker ip:9093 endpoint is used to access Kafka from test code
8680
# run this last to avoid rebuilding the image every time the ip changes

integration-tests/docker/druid.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,30 +78,31 @@ setupConfig()
7878
var=$(echo "$evar" | sed -e 's?^\([^=]*\)=.*?\1?g' -e 's?_?.?g')
7979
setKey $DRUID_SERVICE "$var" "$val"
8080
done
81+
if [ "$MYSQL_DRIVER_CLASSNAME" != "com.mysql.jdbc.Driver" ] ; then
82+
setKey $DRUID_SERVICE druid.metadata.mysql.driver.driverClassName $MYSQL_DRIVER_CLASSNAME
83+
fi
8184
}
8285

8386
setupData()
8487
{
88+
# note: this function exists for legacy reasons, ideally we should do data insert in IT's setup method.
89+
if [ -n "$DRUID_SERVICE" ]; then
90+
echo "DRUID_SERVICE is set, skipping data setup"
91+
return
92+
fi
93+
# note: this function exists for legacy reasons, ideally we should do data insert in IT's setup method.
94+
95+
bash /run-mysql.sh
8596
# The "query" and "security" test groups require data to be setup before running the tests.
8697
# In particular, they requires segments to be download from a pre-existing s3 bucket.
8798
# This is done by using the loadSpec put into metadatastore and s3 credientials set below.
8899
if [ "$DRUID_INTEGRATION_TEST_GROUP" = "query" ] || [ "$DRUID_INTEGRATION_TEST_GROUP" = "query-retry" ] || [ "$DRUID_INTEGRATION_TEST_GROUP" = "query-error" ] || [ "$DRUID_INTEGRATION_TEST_GROUP" = "high-availability" ] || [ "$DRUID_INTEGRATION_TEST_GROUP" = "security" ] || [ "$DRUID_INTEGRATION_TEST_GROUP" = "ldap-security" ] || [ "$DRUID_INTEGRATION_TEST_GROUP" = "upgrade" ] || [ "$DRUID_INTEGRATION_TEST_GROUP" = "centralized-datasource-schema" ] || [ "$DRUID_INTEGRATION_TEST_GROUP" = "cds-task-schema-publish-disabled" ] || [ "$DRUID_INTEGRATION_TEST_GROUP" = "cds-coordinator-metadata-query-disabled" ]; then
89-
# touch is needed because OverlayFS's copy-up operation breaks POSIX standards. See https://github.com/docker/for-linux/issues/72.
90-
find /var/lib/mysql -type f -exec touch {} \; && service mysql start \
91-
&& cat /test-data/${DRUID_INTEGRATION_TEST_GROUP}-sample-data.sql | mysql -u root druid \
92-
&& /etc/init.d/mysql stop
93-
fi
94-
95-
if [ "$MYSQL_DRIVER_CLASSNAME" != "com.mysql.jdbc.Driver" ] ; then
96-
setKey $DRUID_SERVICE druid.metadata.mysql.driver.driverClassName $MYSQL_DRIVER_CLASSNAME
100+
cat /test-data/${DRUID_INTEGRATION_TEST_GROUP}-sample-data.sql | mysql -u root druid
97101
fi
98102

99103
# The SqlInputSource tests in the "input-source" test group require data to be setup in MySQL before running the tests.
100104
if [ "$DRUID_INTEGRATION_TEST_GROUP" = "input-source" ] ; then
101-
# touch is needed because OverlayFS's copy-up operation breaks POSIX standards. See https://github.com/docker/for-linux/issues/72.
102-
find /var/lib/mysql -type f -exec touch {} \; && service mysql start \
103-
&& echo "GRANT ALL ON sqlinputsource.* TO 'druid'@'%'; CREATE database sqlinputsource DEFAULT CHARACTER SET utf8mb4;" | mysql -u root druid \
104-
&& cat /test-data/sql-input-source-sample-data.sql | mysql -u root druid \
105-
&& /etc/init.d/mysql stop
105+
echo "GRANT ALL ON sqlinputsource.* TO 'druid'@'%'; CREATE database sqlinputsource DEFAULT CHARACTER SET utf8mb4;" | mysql -u root druid
106+
cat /test-data/sql-input-source-sample-data.sql | mysql -u root druid
106107
fi
107108
}

integration-tests/docker/run-mysql.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,13 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18-
find /var/lib/mysql -type f -exec touch {} \; && /usr/bin/pidproxy /var/run/mysqld/mysqld.pid /usr/bin/mysqld_safe --bind-address=0.0.0.0
18+
(mysqld --bind-address=0.0.0.0 || true) & # there might already be a mysqld running, so we ignore the error
19+
/usr/bin/pidproxy /var/run/mysqld/mysqld.pid /usr/bin/mysqld_safe --bind-address=0.0.0.0
20+
echo "Waiting for MySQL to be ready...";
21+
for i in {30..0}; do
22+
mysqladmin ping --silent && break;
23+
sleep 1; \
24+
done; \
25+
if [ "$i" = 0 ]; then
26+
echo "MySQL did not start"; exit 1;
27+
fi;

integration-tests/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@
569569
<start.hadoop.docker>false</start.hadoop.docker>
570570
<docker.run.skip>false</docker.run.skip>
571571
<docker.build.skip>false</docker.build.skip>
572+
<docker.build.skipMavenBuild>false</docker.build.skipMavenBuild>
572573
<docker.build.hadoop>false</docker.build.hadoop>
573574
<it.indexer>middleManager</it.indexer>
574575
<override.config.path />
@@ -598,6 +599,7 @@
598599
<DRUID_INTEGRATION_TEST_OVERRIDE_CONFIG_PATH>${override.config.path}</DRUID_INTEGRATION_TEST_OVERRIDE_CONFIG_PATH>
599600
<DRUID_INTEGRATION_TEST_RESOURCE_FILE_DIR_PATH>${resource.file.dir.path}</DRUID_INTEGRATION_TEST_RESOURCE_FILE_DIR_PATH>
600601
<DRUID_INTEGRATION_TEST_SKIP_BUILD_DOCKER>${docker.build.skip}</DRUID_INTEGRATION_TEST_SKIP_BUILD_DOCKER>
602+
<DRUID_INTEGRATION_TEST_SKIP_MAVEN_BUILD_DOCKER>${docker.build.skipMavenBuild}</DRUID_INTEGRATION_TEST_SKIP_MAVEN_BUILD_DOCKER>
601603
<DRUID_INTEGRATION_TEST_SKIP_RUN_DOCKER>${docker.run.skip}</DRUID_INTEGRATION_TEST_SKIP_RUN_DOCKER>
602604
<DRUID_INTEGRATION_TEST_INDEXER>${it.indexer}</DRUID_INTEGRATION_TEST_INDEXER>
603605
<MYSQL_VERSION>${mysql.version}</MYSQL_VERSION>

integration-tests/script/copy_resources_template.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,21 @@ rm -rf $SHARED_DIR/docker
2828
mkdir -p $SHARED_DIR
2929
cp -R docker $SHARED_DIR/docker
3030

31-
pushd ../
32-
rm -rf distribution/target/apache-druid-$DRUID_VERSION-integration-test-bin
33-
# using parallel build here may not yield significant speedups
34-
mvn -B -Pskip-static-checks,skip-tests -Dweb.console.skip=true install -Pintegration-test
35-
mv distribution/target/apache-druid-$DRUID_VERSION-integration-test-bin/bin $SHARED_DIR/docker/bin
36-
mv distribution/target/apache-druid-$DRUID_VERSION-integration-test-bin/lib $SHARED_DIR/docker/lib
37-
mv distribution/target/apache-druid-$DRUID_VERSION-integration-test-bin/extensions $SHARED_DIR/docker/extensions
38-
popd
31+
if [ -z "$DRUID_INTEGRATION_TEST_SKIP_MAVEN_BUILD_DOCKER" ] || [ "$DRUID_INTEGRATION_TEST_SKIP_MAVEN_BUILD_DOCKER" = "false" ]
32+
then
33+
pushd ../
34+
rm -rf distribution/target/apache-druid-$DRUID_VERSION-integration-test-bin
35+
# using parallel build here may not yield significant speedups
36+
mvn -B -Pskip-static-checks,skip-tests -Dweb.console.skip=true install -Pintegration-test
37+
mv distribution/target/apache-druid-$DRUID_VERSION-integration-test-bin/bin $SHARED_DIR/docker/bin
38+
mv distribution/target/apache-druid-$DRUID_VERSION-integration-test-bin/lib $SHARED_DIR/docker/lib
39+
mv distribution/target/apache-druid-$DRUID_VERSION-integration-test-bin/extensions $SHARED_DIR/docker/extensions
40+
popd
41+
else
42+
cp -R ../distribution/target/apache-druid-$DRUID_VERSION-integration-test-bin/bin $SHARED_DIR/docker/bin
43+
cp -R ../distribution/target/apache-druid-$DRUID_VERSION-integration-test-bin/lib $SHARED_DIR/docker/lib
44+
cp -R ../distribution/target/apache-druid-$DRUID_VERSION-integration-test-bin/extensions $SHARED_DIR/docker/extensions
45+
fi
3946

4047
# Make directoriess if they dont exist
4148
mkdir -p $SHARED_DIR/hadoop_xml

integration-tests/script/docker_build_containers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ else
2929
11 | 17 | 21)
3030
echo "Build druid-cluster with Java $DRUID_INTEGRATION_TEST_JVM_RUNTIME"
3131
docker build -t druid/cluster \
32-
--build-arg JDK_VERSION=$DRUID_INTEGRATION_TEST_JVM_RUNTIME-slim-buster \
32+
--build-arg JDK_VERSION=$DRUID_INTEGRATION_TEST_JVM_RUNTIME-slim-bullseye \
3333
--build-arg ZK_VERSION \
3434
--build-arg KAFKA_VERSION \
3535
--build-arg CONFLUENT_VERSION \

0 commit comments

Comments
 (0)