Skip to content

Commit 2a3d1b1

Browse files
authored
feat(ci): add support for spark and hive engine integration tests (#5287)
1 parent 7a63e0f commit 2a3d1b1

File tree

9 files changed

+243
-29
lines changed

9 files changed

+243
-29
lines changed

.github/workflows/integration-test.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ jobs:
152152
sleep 20
153153
done
154154
155+
bash ./linkis-dist/helm/scripts/prepare-for-spark.sh
156+
155157
#show linkis pod logs
156158
#POD_NAME=`kubectl get pods -n linkis -l app.kubernetes.io/instance=linkis-demo-cg-linkismanager -o jsonpath='{.items[0].metadata.name}'`
157159
#kubectl logs -n linkis ${POD_NAME} -f --tail=10000
@@ -170,16 +172,15 @@ jobs:
170172
171173
# Execute test by linkis-cli
172174
POD_NAME=`kubectl get pods -n linkis -l app.kubernetes.io/instance=linkis-demo-mg-gateway -o jsonpath='{.items[0].metadata.name}'`
173-
kubectl exec -it -n linkis ${POD_NAME} -- bash -c " \
175+
kubectl exec -n linkis ${POD_NAME} -- bash -c " \
174176
sh /opt/linkis/bin/linkis-cli -engineType shell-1 -codeType shell -code \"pwd\" ";
175177
176-
kubectl exec -it -n linkis ${POD_NAME} -- bash -c " \
178+
kubectl exec -n linkis ${POD_NAME} -- bash -c " \
177179
sh /opt/linkis/bin/linkis-cli -engineType python-python2 -codeType python -code 'print(\"hello\")' "
178180
179-
#todo
180-
#kubectl exec -it -n linkis ${POD_NAME} -- bash -c " \
181-
#sh /opt/linkis/bin/linkis-cli -engineType hive-3.1.3 -codeType hql -code 'show databases' "
181+
kubectl exec -n linkis ${POD_NAME} -- bash -c " \
182+
sh /opt/linkis/bin/linkis-cli -engineType hive-3.1.3 -codeType hql -code 'show databases' "
182183
183-
#kubectl exec -it -n linkis ${POD_NAME} -- bash -c " \
184-
#sh /opt/linkis/bin/linkis-cli -engineType spark-3.2.1 -codeType sql -code 'show databases' "
184+
kubectl exec -n linkis ${POD_NAME} -- bash -c " \
185+
sh /opt/linkis/bin/linkis-cli -engineType spark-3.2.1 -codeType sql -code 'show databases' "
185186
shell: bash

linkis-dist/bin/install-linkis-to-kubernetes.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ tag(){
8686
make_linkis_image_with_mysql_jdbc(){
8787
${ROOT_DIR}/docker/scripts/make-linkis-image-with-mysql-jdbc.sh
8888
docker tag linkis:with-jdbc linkis:dev
89+
${ROOT_DIR}/docker/scripts/make-ldh-image-with-mysql-jdbc.sh
90+
docker tag linkis-ldh:with-jdbc linkis-ldh:dev
8991
}
9092
#creating a kind cluster
9193
create_kind_cluster(){
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
ARG LINKIS_IMAGE=linkis-ldh:dev
19+
20+
######################################################################
21+
# linkis-ldh image with mysql jdbc
22+
######################################################################
23+
FROM ${LINKIS_IMAGE}
24+
25+
ARG LDH_HOME=/opt/ldh/current
26+
ARG MYSQL_JDBC_VERSION=8.0.28
27+
28+
COPY mysql-connector-java-${MYSQL_JDBC_VERSION}.jar ${LDH_HOME}/hive/lib/
29+
COPY mysql-connector-java-${MYSQL_JDBC_VERSION}.jar ${LDH_HOME}/spark/lib/

linkis-dist/docker/ldh.Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ ADD ldh-tars/spark-${SPARK_VERSION}-bin-hadoop${SPARK_HADOOP_VERSION}.tgz /opt/l
7575
ADD ldh-tars/flink-${FLINK_VERSION}-bin-scala_2.11.tgz /opt/ldh/${LINKIS_VERSION}/
7676
ADD ldh-tars/apache-zookeeper-${ZOOKEEPER_VERSION}-bin.tar.gz /opt/ldh/${LINKIS_VERSION}/
7777

78+
RUN ln -s /opt/ldh/${LINKIS_VERSION}/spark-${SPARK_VERSION}-bin-hadoop${SPARK_HADOOP_VERSION} /opt/ldh/current/spark \
79+
&& ln -s /opt/ldh/${LINKIS_VERSION}/hadoop-${HADOOP_VERSION} /opt/ldh/current/hadoop \
80+
&& ln -s /opt/ldh/${LINKIS_VERSION}/apache-hive-${HIVE_VERSION}-bin /opt/ldh/current/hive
81+
7882
RUN mkdir -p /etc/ldh \
7983
&& mkdir -p /var/log/hadoop && chmod 777 -R /var/log/hadoop \
8084
&& mkdir -p /var/log/hive && chmod 777 -R /var/log/hive \
@@ -91,9 +95,10 @@ RUN mkdir -p /etc/ldh \
9195
#ADD ldh-tars/mysql-connector-java-${MYSQL_JDBC_VERSION}.jar /opt/ldh/current/hive/lib/
9296
#ADD ldh-tars/mysql-connector-java-${MYSQL_JDBC_VERSION}.jar /opt/ldh/current/spark/jars/
9397

94-
ENV JAVA_HOME /etc/alternatives/jre
95-
ENV PATH /opt/ldh/current/hadoop/bin:/opt/ldh/current/hive/bin:/opt/ldh/current/spark/bin:/opt/ldh/current/flink/bin:/opt/ldh/current/zookeeper/bin:$PATH
98+
ENV JAVA_HOME=/etc/alternatives/jre
99+
ENV PATH=/opt/ldh/current/hadoop/bin:/opt/ldh/current/hive/bin:/opt/ldh/current/spark/bin:/opt/ldh/current/flink/bin:/opt/ldh/current/zookeeper/bin:$PATH
96100
ENV HADOOP_CONF_DIR=/etc/ldh/hadoop
101+
ENV YARN_CONF_DIR=/etc/ldh/hadoop
97102
ENV HIVE_CONF_DIR=/etc/ldh/hive
98103
ENV SPARK_CONF_DIR=/etc/ldh/spark
99104
ENV FLINK_CONF_DIR=/etc/ldh/flink
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
#
17+
18+
WORK_DIR=`cd $(dirname $0); pwd -P`
19+
20+
. ${WORK_DIR}/utils.sh
21+
22+
IMAGE_NAME=${IMAGE_NAME:-linkis-ldh:with-jdbc}
23+
LINKIS_IMAGE=${LINKIS_IMAGE:-linkis-ldh:dev}
24+
LINKIS_HOME=${LINKIS_HOME:-/opt/ldh/current}
25+
MYSQL_JDBC_VERSION=${MYSQL_JDBC_VERSION:-8.0.28}
26+
MYSQL_JDBC_FILENAME=mysql-connector-java-${MYSQL_JDBC_VERSION}.jar
27+
MYSQL_JDBC_URL="https://repo1.maven.org/maven2/mysql/mysql-connector-java/${MYSQL_JDBC_VERSION}/${MYSQL_JDBC_FILENAME}"
28+
29+
BUILD_DIR=`mktemp -d -t linkis-build-XXXXX`
30+
31+
echo "# build dir: ${BUILD_DIR}"
32+
echo "# base image: ${LINKIS_IMAGE}"
33+
echo "# mysql jdbc version: ${MYSQL_JDBC_VERSION}"
34+
35+
download ${MYSQL_JDBC_URL} ${MYSQL_JDBC_FILENAME} ${BUILD_DIR}
36+
37+
echo "try to exec: docker build -f ${WORK_DIR}/../ldh-with-mysql-jdbc.Dockerfile \
38+
-t ${IMAGE_NAME} \
39+
--build-arg LINKIS_IMAGE=${LINKIS_IMAGE} \
40+
--build-arg LINKIS_HOME=${LINKIS_HOME} \
41+
--build-arg MYSQL_JDBC_VERSION=${MYSQL_JDBC_VERSION} \
42+
${BUILD_DIR}"
43+
44+
docker build -f ${WORK_DIR}/../ldh-with-mysql-jdbc.Dockerfile \
45+
-t ${IMAGE_NAME} \
46+
--build-arg LINKIS_IMAGE=${LINKIS_IMAGE} \
47+
--build-arg LINKIS_HOME=${LINKIS_HOME} \
48+
--build-arg MYSQL_JDBC_VERSION=${MYSQL_JDBC_VERSION} \
49+
${BUILD_DIR}
50+
51+
echo "# done, image: ${IMAGE_NAME}"

linkis-dist/helm/charts/linkis/templates/jobs.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ spec:
2828
command:
2929
- /bin/bash
3030
- -ecx
31-
- >-
31+
- |-
32+
sed -i 's#@YARN_RESTFUL_URL#{{ .Values.linkis.deps.yarn.restfulUrl }}#g' {{ .Values.linkis.locations.homeDir }}/db/linkis_dml.sql
33+
sed -i 's#@HADOOP_VERSION#{{ .Values.linkis.deps.hadoop.version }}#g' {{ .Values.linkis.locations.homeDir }}/db/linkis_dml.sql
34+
sed -i 's#@YARN_AUTH_ENABLE#{{ .Values.linkis.deps.yarn.authEnable }}#g' {{ .Values.linkis.locations.homeDir }}/db/linkis_dml.sql
35+
sed -i 's#@YARN_AUTH_USER#{{ .Values.linkis.deps.yarn.authUser }}#g' {{ .Values.linkis.locations.homeDir }}/db/linkis_dml.sql
36+
sed -i 's#@YARN_AUTH_PWD#{{ .Values.linkis.deps.yarn.authPassword }}#g' {{ .Values.linkis.locations.homeDir }}/db/linkis_dml.sql
37+
sed -i 's#@YARN_KERBEROS_ENABLE#{{ .Values.linkis.deps.yarn.kerberosEnable }}#g' {{ .Values.linkis.locations.homeDir }}/db/linkis_dml.sql
38+
sed -i 's#@YARN_PRINCIPAL_NAME#{{ .Values.linkis.deps.yarn.principal }}#g' {{ .Values.linkis.locations.homeDir }}/db/linkis_dml.sql
39+
sed -i 's#@YARN_KEYTAB_PATH#{{ .Values.linkis.deps.yarn.keytab }}#g' {{ .Values.linkis.locations.homeDir }}/db/linkis_dml.sql
40+
sed -i 's#@YARN_KRB5_PATH#{{ .Values.linkis.deps.yarn.krb5 }}#g' {{ .Values.linkis.locations.homeDir }}/db/linkis_dml.sql
3241
mysql -h{{ .Values.linkis.datasource.host }} -P{{ .Values.linkis.datasource.port }} -u{{ .Values.linkis.datasource.username }} -p{{ .Values.linkis.datasource.password }} --default-character-set=utf8 -e "CREATE DATABASE IF NOT EXISTS {{ .Values.linkis.datasource.database }} DEFAULT CHARSET utf8 COLLATE utf8_general_ci";
3342
mysql -h{{ .Values.linkis.datasource.host }} -P{{ .Values.linkis.datasource.port }} -u{{ .Values.linkis.datasource.username }} -p{{ .Values.linkis.datasource.password }} -D{{ .Values.linkis.datasource.database }} --default-character-set=utf8 -e "source {{ .Values.linkis.locations.homeDir }}/db//linkis_ddl.sql";
3443
mysql -h{{ .Values.linkis.datasource.host }} -P{{ .Values.linkis.datasource.port }} -u{{ .Values.linkis.datasource.username }} -p{{ .Values.linkis.datasource.password }} -D{{ .Values.linkis.datasource.database }} --default-character-set=utf8 -e "source {{ .Values.linkis.locations.homeDir }}/db//linkis_dml.sql"

linkis-dist/helm/scripts/install-ldh.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717

1818
WORK_DIR=`cd $(dirname $0); pwd -P`
19-
19+
ROOT_DIR=${WORK_DIR}/../..
2020
. ${WORK_DIR}/common.sh
2121

2222
set -e
@@ -27,6 +27,9 @@ echo "# LDH version: ${LINKIS_IMAGE_TAG}"
2727

2828
# load image
2929
if [[ "X${USING_KIND}" == "Xtrue" ]]; then
30+
echo "# Preparing LDH image ..."
31+
${ROOT_DIR}/docker/scripts/make-ldh-image-with-mysql-jdbc.sh
32+
docker tag linkis-ldh:with-jdbc linkis-ldh:dev
3033
echo "# Loading LDH image ..."
3134
kind load docker-image linkis-ldh:${LINKIS_IMAGE_TAG} --name ${KIND_CLUSTER_NAME}
3235
fi

linkis-dist/helm/scripts/prepare-for-spark.sh

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,16 @@ WORK_DIR=`cd $(dirname $0); pwd -P`
2121

2222
## copy spark resource from ldh to linkis-cg-engineconnmanager
2323

24-
LDH_POD_NAME=`kubectl get pods -n ldh -l app=ldh -o jsonpath='{.items[0].metadata.name}'`
25-
kubectl cp -n ldh ${LDH_POD_NAME}:/opt/ldh/ ./ldh
26-
24+
LDH_POD_NAME=`kubectl get pods -n ldh -l app=ldh -o jsonpath='{.items[0].metadata.name}'`
2725
ECM_POD_NAME=`kubectl get pods -n linkis -l app.kubernetes.io/instance=linkis-demo-cg-engineconnmanager -o jsonpath='{.items[0].metadata.name}'`
28-
kubectl cp ./ldh -n linkis ${ECM_POD_NAME}:/opt/ ;
29-
30-
31-
kubectl exec -it -n linkis ${ECM_POD_NAME} -- bash -c "chmod +x /opt/ldh/1.3.0/spark-3.2.1-bin-hadoop3.2/bin/*"
32-
kubectl exec -it -n linkis ${ECM_POD_NAME} -- bash -c "ln -s /opt/ldh/1.3.0/spark-3.2.1-bin-hadoop3.2 /opt/ldh/current/spark"
33-
kubectl exec -it -n linkis ${ECM_POD_NAME} -- bash -c "ln -s /opt/ldh/1.3.0/hadoop-3.3.4 /opt/ldh/current/hadoop"
34-
kubectl exec -it -n linkis ${ECM_POD_NAME} -- bash -c "ln -s /opt/ldh/1.3.0/apache-hive-3.1.3-bin /opt/ldh/current/hive"
3526

27+
kubectl exec -n ldh ${LDH_POD_NAME} -- tar -C /opt -cf - ldh | \
28+
kubectl exec -i -n linkis ${ECM_POD_NAME} -- tar -C /opt -xf - --no-same-owner
3629

37-
kubectl exec -it -n linkis ${ECM_POD_NAME} -- bash -c "echo 'export SPARK_HOME=/opt/ldh/current/spark' |sudo tee --append /etc/profile"
38-
kubectl exec -it -n linkis ${ECM_POD_NAME} -- bash -c "echo 'export PATH=\$SPARK_HOME/bin:\$PATH' |sudo tee --append /etc/profile"
39-
kubectl exec -it -n linkis ${ECM_POD_NAME} -- bash -c "source /etc/profile"
30+
kubectl exec -n linkis ${ECM_POD_NAME} -- bash -c "sudo mkdir -p /appcom/Install && sudo chmod 0777 /appcom/Install && ln -s /opt/ldh/current/spark /appcom/Install/spark"
31+
kubectl exec -n linkis ${ECM_POD_NAME} -- bash -c "echo 'export SPARK_HOME=/opt/ldh/current/spark' |sudo tee --append /etc/profile"
32+
kubectl exec -n linkis ${ECM_POD_NAME} -- bash -c "echo 'export PATH=\$SPARK_HOME/bin:\$PATH' |sudo tee --append /etc/profile"
33+
kubectl exec -n linkis ${ECM_POD_NAME} -- bash -c "source /etc/profile"
4034

4135
# add ecm dns for ldh pod
4236
ECM_POD_IP=`kubectl get pods -n linkis -l app.kubernetes.io/instance=linkis-demo-cg-engineconnmanager -o jsonpath='{.items[0].status.podIP}'`
@@ -45,7 +39,4 @@ ECM_POD_SUBDOMAIN=`kubectl get pods -n linkis -l app.kubernetes.io/instance=link
4539

4640
ECM_DNS="${ECM_POD_IP} ${ECM_POD_NAME}.${ECM_POD_SUBDOMAIN}.linkis.svc.cluster.local"
4741

48-
kubectl exec -it -n ldh ${LDH_POD_NAME} -- bash -c "echo ${ECM_DNS} |sudo tee --append /etc/hosts"
49-
50-
51-
rm -rf ldh;
42+
kubectl exec -n ldh ${LDH_POD_NAME} -- bash -c "echo ${ECM_DNS} |sudo tee --append /etc/hosts"

linkis-dist/helm/scripts/resources/ldh/configmaps/configmap-hadoop.yaml

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,4 +591,127 @@ data:
591591
<aclAdministerApps>*</aclAdministerApps>
592592
</queue>
593593
</queue>
594-
</allocations>
594+
</allocations>
595+
capacity-scheduler.xml: |
596+
<!--
597+
Licensed under the Apache License, Version 2.0 (the "License");
598+
you may not use this file except in compliance with the License.
599+
You may obtain a copy of the License at
600+
601+
http://www.apache.org/licenses/LICENSE-2.0
602+
603+
Unless required by applicable law or agreed to in writing, software
604+
distributed under the License is distributed on an "AS IS" BASIS,
605+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
606+
See the License for the specific language governing permissions and
607+
limitations under the License. See accompanying LICENSE file.
608+
-->
609+
<configuration>
610+
611+
<property>
612+
<name>yarn.scheduler.capacity.maximum-applications</name>
613+
<value>4</value>
614+
<description>
615+
Maximum number of applications that can be pending and running.
616+
</description>
617+
</property>
618+
619+
<property>
620+
<name>yarn.scheduler.capacity.maximum-am-resource-percent</name>
621+
<value>0.5</value>
622+
<description>
623+
Maximum percent of resources in the cluster which can be used to run
624+
application masters i.e. controls number of concurrent running
625+
applications.
626+
</description>
627+
</property>
628+
629+
<property>
630+
<name>yarn.scheduler.capacity.resource-calculator</name>
631+
<value>org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator</value>
632+
<description>
633+
The ResourceCalculator implementation to be used to compare
634+
Resources in the scheduler.
635+
The default i.e. DefaultResourceCalculator only uses Memory while
636+
DominantResourceCalculator uses dominant-resource to compare
637+
multi-dimensional resources such as Memory, CPU etc.
638+
</description>
639+
</property>
640+
641+
<property>
642+
<name>yarn.scheduler.capacity.root.queues</name>
643+
<value>default</value>
644+
<description>
645+
The queues at the this level (root is the root queue).
646+
</description>
647+
</property>
648+
649+
<property>
650+
<name>yarn.scheduler.capacity.root.default.capacity</name>
651+
<value>100</value>
652+
<description>Default queue target capacity.</description>
653+
</property>
654+
655+
<property>
656+
<name>yarn.scheduler.capacity.root.default.user-limit-factor</name>
657+
<value>1</value>
658+
<description>
659+
Default queue user limit a percentage from 0.0 to 1.0.
660+
</description>
661+
</property>
662+
663+
<property>
664+
<name>yarn.scheduler.capacity.root.default.maximum-capacity</name>
665+
<value>100</value>
666+
<description>
667+
The maximum capacity of the default queue.
668+
</description>
669+
</property>
670+
671+
<property>
672+
<name>yarn.scheduler.capacity.root.default.state</name>
673+
<value>RUNNING</value>
674+
<description>
675+
The state of the default queue. State can be one of RUNNING or STOPPED.
676+
</description>
677+
</property>
678+
679+
<property>
680+
<name>yarn.scheduler.capacity.root.default.acl_submit_applications</name>
681+
<value>*</value>
682+
<description>
683+
The ACL of who can submit jobs to the default queue.
684+
</description>
685+
</property>
686+
687+
<property>
688+
<name>yarn.scheduler.capacity.root.default.acl_administer_queue</name>
689+
<value>*</value>
690+
<description>
691+
The ACL of who can administer jobs on the default queue.
692+
</description>
693+
</property>
694+
695+
<property>
696+
<name>yarn.scheduler.capacity.node-locality-delay</name>
697+
<value>40</value>
698+
<description>
699+
Number of missed scheduling opportunities after which the CapacityScheduler
700+
attempts to schedule rack-local containers.
701+
Typically this should be set to number of nodes in the cluster, By default is setting
702+
approximately number of nodes in one rack which is 40.
703+
</description>
704+
</property>
705+
706+
<property>
707+
<name>yarn.scheduler.capacity.queue-mappings-override.enable</name>
708+
<value>false</value>
709+
<description>
710+
If a queue mapping is present, will it override the value specified
711+
by the user? This can be used by administrators to place jobs in queues
712+
that are different than the one specified by the user.
713+
The default is false.
714+
</description>
715+
</property>
716+
717+
</configuration>

0 commit comments

Comments
 (0)