Skip to content
Merged
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,21 @@ jobs:
env: TESTNG_GROUPS='-DexcludedGroups=batch-index,input-format,input-source,perfect-rollup-parallel-batch-index,kafka-index,query,query-retry,realtime-index,security,s3-deep-storage,gcs-deep-storage,azure-deep-storage,hdfs-deep-storage,s3-ingestion,kinesis-index,kinesis-data-format,kafka-transactional-index,kafka-index-slow,kafka-transactional-index-slow,kafka-data-format,hadoop-s3-to-s3-deep-storage,hadoop-s3-to-hdfs-deep-storage,hadoop-azure-to-azure-deep-storage,hadoop-azure-to-hdfs-deep-storage,hadoop-gcs-to-gcs-deep-storage,hadoop-gcs-to-hdfs-deep-storage,aliyun-oss-deep-storage,append-ingestion,compaction' JVM_RUNTIME='-Djvm.runtime=11' USE_INDEXER='middleManager'
# END - Integration tests for Compile with Java 8 and Run with Java 11

- &integration_batch_index_k8s
name: "(Compile=openjdk8, Run=openjdk8, Cluster Build On K8s) ITNestedQueryPushDownTest integration test"
jdk: openjdk8
services: &integration_test_services_k8s
- docker
env: CONFIG_FILE='k8s_run_config_file.json' IT_TEST='-Dit.test=ITNestedQueryPushDownTest'
before_script: integration-tests/script/build_run_k8s_cluster.sh
script: &run_integration_test_k8s
- ${MVN} verify -pl integration-tests -P int-tests-config-file ${IT_TEST} ${MAVEN_SKIP}
after_script: integration-tests/script/stop_k8s_cluster.sh
after_failure: &integration_test_diags_k8s
- for v in broker middlemanager router coordinator historical ; do
echo "------------------------druid-tiny-cluster-"$v"s-0-------------------------";
sudo /usr/local/bin/kubectl logs --tail 1000 druid-tiny-cluster-"$v"s-0;
done
- name: "security vulnerabilities"
stage: cron
install: skip
Expand Down
62 changes: 62 additions & 0 deletions distribution/docker/DockerfileBuildTarAdvanced
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this looks mostly a copy of other Dockerfile , it would be nice to reuse same if possible.

Copy link
Copy Markdown
Contributor Author

@zhangyue19921010 zhangyue19921010 Dec 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also. There are some changes between DockerfileBuildTarAdvanced and original Dockerfile, such as :

  1. Prepare test data.
  2. Move mvn package out of Dockerfile.
  3. Mkdir necessary for IT.

So that we can't use the original Dockerfile here.

# 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.
#

# Using For IT on K8s
FROM maven:3-jdk-8-slim as builder

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get -qq update \
&& apt-get -qq -y install --no-install-recommends python3 python3-yaml

COPY . /src
WORKDIR /src

RUN VERSION=$(mvn -B -q org.apache.maven.plugins:maven-help-plugin:3.1.1:evaluate \
-Dexpression=project.version -DforceStdout=true \
) \
&& tar -zxf ./distribution/target/apache-druid-${VERSION}-bin.tar.gz -C /opt \
&& ln -s /opt/apache-druid-${VERSION} /opt/druid

FROM amd64/busybox:1.30.0-glibc as busybox

FROM gcr.io/distroless/java:8
LABEL maintainer="Apache Druid Developers <dev@druid.apache.org>"

COPY --from=busybox /bin/busybox /busybox/busybox
RUN ["/busybox/busybox", "--install", "/bin"]

RUN mkdir -p /shared/wikiticker-it

COPY examples/quickstart/tutorial/wikiticker-2015-09-12-sampled.json.gz /shared/wikiticker-it/wikiticker-2015-09-12-sampled.json.gz
COPY integration-tests/docker/wiki-simple-lookup.json /shared/wikiticker-it/wiki-simple-lookup.json

RUN addgroup -S -g 1000 druid \
&& adduser -S -u 1000 -D -H -h /opt/druid -s /bin/sh -g '' -G druid druid \
&& mkdir -p /opt/druid/var \
&& chown -R druid:druid /opt \
&& chmod 775 /opt/druid/var

COPY --chown=druid:druid --from=builder /opt /opt
COPY distribution/docker/druid.sh /druid.sh

USER druid
VOLUME /opt/druid/var
WORKDIR /opt/druid

ENTRYPOINT ["/druid.sh"]
16 changes: 16 additions & 0 deletions integration-tests/k8s_run_config_file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"broker_host" : "localhost",
"broker_port" : "30400",
"broker_tls_url" : "http://localhost:30100",
"router_host" : "localhost",
"router_port" : "30400",
"router_tls_url" : "http://localhost:30400",
"indexer_host" : "localhost",
"indexer_port" : "30400",
"historical_host" : "localhost",
"historical_port" : "30300",
"coordinator_host" : "localhost",
"coordinator_port" : "30400",
"middlemanager_host": "localhost",
"zookeeper_hosts": "localhost:30600"
}
84 changes: 84 additions & 0 deletions integration-tests/script/build_run_k8s_cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
# 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.

set -e

export DRUID_OPERATOR_VERSION=0.0.3

# setup client keystore
cd integration-tests
./docker/tls/generate-client-certs-and-keystores.sh
rm -rf docker/client_tls
cp -r client_tls docker/client_tls
cd ..

# Build Docker images for pods
mvn -B -ff -q dependency:go-offline \
install \
-Pdist,bundle-contrib-exts \
-Pskip-static-checks,skip-tests \
-Dmaven.javadoc.skip=true

docker build -t druid/cluster:v1 -f distribution/docker/DockerfileBuildTarAdvanced .

# Set Necessary ENV
export CHANGE_MINIKUBE_NONE_USER=true
export MINIKUBE_WANTUPDATENOTIFICATION=false
export MINIKUBE_WANTREPORTERRORPROMPT=false
export MINIKUBE_HOME=$HOME
export KUBECONFIG=$HOME/.kube/config
sudo apt install -y conntrack

# This tmp dir is used for MiddleManager pod and Historical Pod to cache segments.
mkdir tmp
chmod 777 tmp

# Lacunch K8S cluster
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.18.1/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.8.1/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
sudo /usr/local/bin/minikube start --profile=minikube --vm-driver=none --kubernetes-version=v1.18.1
sudo /usr/local/bin/minikube update-context

# Prepare For Druid-Operator
git clone https://github.com/druid-io/druid-operator.git
cd druid-operator
git checkout -b druid-operator-$DRUID_OPERATOR_VERSION druid-operator-$DRUID_OPERATOR_VERSION
cd ..
sed -i "s|REPLACE_IMAGE|druidio/druid-operator:$DRUID_OPERATOR_VERSION|g" druid-operator/deploy/operator.yaml
cp integration-tests/tiny-cluster.yaml druid-operator/examples/
cp integration-tests/tiny-cluster-zk.yaml druid-operator/examples/
Comment on lines +61 to +62
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not sure why we need to copy, can't we directly use those two files ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes in integration-tests/tiny-cluster.yaml and integration-tests/tiny-cluster-zk.yaml, such as:

  1. New NodeType Service.
  2. Configs changing.
  3. Add MiddleManager configs.

So the original files in druid-operator can't be used directly here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I wasn't clear, in this context "original" meant files in "integration-tests/" i.e. you have

cp integration-tests/tiny-cluster.yaml druid-operator/examples/
cp integration-tests/tiny-cluster-zk.yaml druid-operator/examples/
...
sed -i "s|REPLACE_VOLUMES|`pwd`|g" druid-operator/examples/tiny-cluster.yaml
..
sudo /usr/local/bin/kubectl apply -f druid-operator/examples/tiny-cluster-zk.yaml
sudo /usr/local/bin/kubectl apply -f druid-operator/examples/tiny-cluster.yaml

as opposed to

...
sed -i "s|REPLACE_VOLUMES|`pwd`|g" integration-tests/tiny-cluster.yaml
..
sudo /usr/local/bin/kubectl apply -f integration-tests/tiny-cluster-zk.yaml
sudo /usr/local/bin/kubectl apply -f integration-tests/tiny-cluster.yaml

regardless, it is a nit and doesn't really matter much.

sed -i "s|REPLACE_VOLUMES|`pwd`|g" druid-operator/examples/tiny-cluster.yaml

# Create ZK, Historical, MiddleManager, Overlord-coordiantor, Broker and Router pods using statefulset
sudo /usr/local/bin/kubectl create -f druid-operator/deploy/service_account.yaml
sudo /usr/local/bin/kubectl create -f druid-operator/deploy/role.yaml
sudo /usr/local/bin/kubectl create -f druid-operator/deploy/role_binding.yaml
sudo /usr/local/bin/kubectl create -f druid-operator/deploy/crds/druid.apache.org_druids_crd.yaml
sudo /usr/local/bin/kubectl create -f druid-operator/deploy/operator.yaml
sudo /usr/local/bin/kubectl apply -f druid-operator/examples/tiny-cluster-zk.yaml
sudo /usr/local/bin/kubectl apply -f druid-operator/examples/tiny-cluster.yaml

# Wait 4 * 15 seconds to launch pods.
#count=0
#JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until sudo /usr/local/bin/kubectl -n default get pods -lapp=travis-example -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 4;if [ $count -eq 15 ];then break 2 ;else let "count++";fi;echo $i;echo "waiting for travis-example deployment to be available"; sudo /usr/local/bin/kubectl get pods -n default; done
sleep 120

## Debug And FastFail

sudo /usr/local/bin/kubectl get pod
sudo /usr/local/bin/kubectl get svc
docker images
sudo /usr/local/bin/kubectl describe pod druid-tiny-cluster-middlemanagers-0
19 changes: 19 additions & 0 deletions integration-tests/script/stop_k8s_cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# 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.

set -e
sudo /usr/local/bin/minikube delete
sudo rm -rf `pwd`/tmp
97 changes: 97 additions & 0 deletions integration-tests/tiny-cluster-zk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# 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.
---
apiVersion: v1
kind: Service
metadata:
name: tiny-cluster-zk
spec:
clusterIP: None
ports:
- name: zk-client-port
port: 2181
- name: zk-fwr-port
port: 2888
- name: zk-elec-port
port: 3888
selector:
zk_cluster: tiny-cluster-zk
---
apiVersion: v1
kind: Service
metadata:
name: tiny-cluster-zk-nodeport
spec:
type: NodePort
ports:
- name: zk-service-port
nodePort: 30600
port: 2181
protocol: TCP
targetPort: 2181
selector:
zk_cluster: tiny-cluster-zk
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
zk_cluster: tiny-cluster-zk
name: tiny-cluster-zk
spec:
replicas: 1
selector:
matchLabels:
zk_cluster: tiny-cluster-zk
serviceName: tiny-cluster-zk
template:
metadata:
labels:
zk_cluster: tiny-cluster-zk
spec:
containers:
- env:
- name: ZOO_SERVERS
value: server.0=tiny-cluster-zk-0.tiny-cluster-zk:2888:3888
- name: SERVER_JVMFLAGS
value: -Xms256m -Xmx256m
image: zookeeper:3.4.13
name: tiny-cluster-zk
command: ["/bin/sh"]
args: ["-c", "ZOO_MY_ID=$(echo `hostname` | cut -d '-' -f2) /docker-entrypoint.sh zkServer.sh start-foreground"]
ports:
- containerPort: 2181
name: zk-client-port
- containerPort: 2888
name: zk-fwr-port
- containerPort: 3888
name: zk-elec-port
resources:
limits:
cpu: 1
memory: 512Mi
requests:
cpu: 1
memory: 512Mi
volumeMounts:
- mountPath: /data
name: druid-test-zk-data
- mountPath: /datalog
name: druid-test-zk-data-log
volumes:
- name: druid-test-zk-data
emptyDir: {}
- name: druid-test-zk-data-log
emptyDir: {}
Loading