This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new e6888819a feat(ci): implement image caching to reduce ci build time. 
(#8735)
e6888819a is described below

commit e6888819a27c488b0dba6121e5b62bdc92a20a78
Author: Abhishek Choudhary <[email protected]>
AuthorDate: Thu Feb 16 07:58:29 2023 +0530

    feat(ci): implement image caching to reduce ci build time. (#8735)
---
 .github/workflows/build.yml      | 55 ++++++++++++++++++++++-------------
 .github/workflows/centos7-ci.yml | 25 ++++------------
 .github/workflows/fips.yml       | 27 ++++-------------
 .github/workflows/gm-cron.yaml   | 26 ++++-------------
 ci/backup-docker-images.sh       | 50 ++++++++++++++++++++++++++++++++
 ci/free_disk_space.sh            | 31 ++++++++++++++++++++
 ci/init-last-test-service.sh     | 37 +++++++++++++++++-------
 ci/init-plugin-test-service.sh   | 62 +++++++++++++++++++++++++---------------
 8 files changed, 197 insertions(+), 116 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c28469183..94a4b8d5e 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -99,30 +99,36 @@ jobs:
           rm -rf $(ls -1 --ignore=*.tgz --ignore=ci --ignore=t --ignore=utils 
--ignore=.github)
           tar zxvf ${{ steps.branch_env.outputs.fullname }}
 
-      - name: Start CI env (FIRST_TEST)
-        if: steps.test_env.outputs.type == 'first'
-        run: |
-          # launch deps env
-          make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
+      - name: Cache images
+        id: cache-images
+        uses: actions/cache@v3
+        env:
+          cache-name: cache-apisix-docker-images
+        with:
+          path: docker-images-backup
+          key: ${{ runner.os }}-${{ env.cache-name }}-${{ 
steps.test_env.outputs.type }}-${{ matrix.os_name }}-${{ 
hashFiles(format('./ci/pod/docker-compose.{0}.yml', steps.test_env.outputs.type 
)) }}
 
-      - name: Start CI env (PLUGIN_TEST)
-        if: steps.test_env.outputs.type == 'plugin'
+      - if: ${{ steps.cache-images.outputs.cache-hit == 'true' }}
+        name: Load saved docker images
         run: |
-          # download keycloak cas provider
-          sudo wget 
https://github.com/jacekkow/keycloak-protocol-cas/releases/download/18.0.2/keycloak-protocol-cas-18.0.2.jar
 -O /opt/keycloak-protocol-cas-18.0.2.jar
-
-          ./ci/pod/openfunction/build-function-image.sh
-          make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
-          sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh
-
-      - name: Start CI env (LAST_TEST)
-        if: steps.test_env.outputs.type == 'last'
+          if [[ -f docker-images-backup/apisix-images.tar ]]; then
+            [[ ${{ steps.test_env.outputs.type }} != first ]] && sudo 
./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh before
+            docker load --input docker-images-backup/apisix-images.tar
+            rm docker-images-backup/apisix-images.tar
+            make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
+            echo "loaded docker images"
+            if [[ ${{ steps.test_env.outputs.type }} != first ]]; then
+              sudo ./ci/init-${{ steps.test_env.outputs.type 
}}-test-service.sh after
+            fi
+          fi
+      - if: ${{ steps.cache-images.outputs.cache-hit != 'true' }}
+        name: Linux launch services
         run: |
-          # generating SSL certificates for Kafka
-          sudo keytool -genkeypair -keyalg RSA -dname "CN=127.0.0.1" -alias 
127.0.0.1 -keystore ./ci/pod/kafka/kafka-server/selfsigned.jks -validity 365 
-keysize 2048 -storepass changeit
+          [[ ${{ steps.test_env.outputs.type }} != first ]] && sudo 
./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh before
+          [[ ${{ steps.test_env.outputs.type }} == plugin ]] && 
./ci/pod/openfunction/build-function-image.sh
           make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
-          sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh
-
+          [[ ${{ steps.test_env.outputs.type }} != first ]] && sudo 
./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh after
+          echo "Linux launch services, done."
       - name: Start Dubbo Backend
         if: matrix.os_name == 'linux_openresty' && steps.test_env.outputs.type 
== 'plugin'
         run: |
@@ -158,3 +164,12 @@ jobs:
         env:
           TEST_FILE_SUB_DIR: ${{ matrix.test_dir }}
         run: sudo -E ./ci/${{ matrix.os_name }}_runner.sh script
+
+      - if: ${{ steps.cache-images.outputs.cache-hit != 'true' }}
+        name: Save docker images
+        run: |
+          # free disk space
+          bash ./ci/free_disk_space.sh
+          echo "start backing up, $(date)"
+          bash ./ci/backup-docker-images.sh ${{ steps.test_env.outputs.type }}
+          echo "backup done, $(date)"
diff --git a/.github/workflows/centos7-ci.yml b/.github/workflows/centos7-ci.yml
index 9d22f78db..3bce341b8 100644
--- a/.github/workflows/centos7-ci.yml
+++ b/.github/workflows/centos7-ci.yml
@@ -103,28 +103,13 @@ jobs:
         docker run -itd -v /home/runner/work/apisix/apisix:/apisix --env 
TEST_FILE_SUB_DIR="$TEST_FILE_SUB_DIR" --name centos7Instance --net="host" 
--dns 8.8.8.8 --dns-search apache.org docker.io/centos:7 /bin/bash
         # docker exec centos7Instance bash -c "cp -r /tmp/apisix ./"
 
-    - name: Start CI env (FIRST_TEST)
-      if: steps.test_env.outputs.type == 'first'
+    - name: Linux launch services
       run: |
+        [[ ${{ steps.test_env.outputs.type }} != first ]] && sudo 
./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh before
+        [[ ${{ steps.test_env.outputs.type }} == plugin ]] && 
./ci/pod/openfunction/build-function-image.sh
         make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
-
-    - name: Start CI env (PLUGIN_TEST)
-      if: steps.test_env.outputs.type == 'plugin'
-      run: |
-        # download keycloak cas provider
-        sudo wget 
https://github.com/jacekkow/keycloak-protocol-cas/releases/download/18.0.2/keycloak-protocol-cas-18.0.2.jar
 -O /opt/keycloak-protocol-cas-18.0.2.jar
-
-        ./ci/pod/openfunction/build-function-image.sh
-        make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
-        ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh
-
-    - name: Start CI env (LAST_TEST)
-      if: steps.test_env.outputs.type == 'last'
-      run: |
-        # generating SSL certificates for Kafka
-        keytool -genkeypair -keyalg RSA -dname "CN=127.0.0.1" -alias 127.0.0.1 
-keystore ./ci/pod/kafka/kafka-server/selfsigned.jks -validity 365 -keysize 
2048 -storepass changeit
-        make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
-        ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh
+        [[ ${{ steps.test_env.outputs.type }} != first ]] && sudo 
./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh after
+        echo "Linux launch services, done"
 
     - name: Install dependencies
       run: |
diff --git a/.github/workflows/fips.yml b/.github/workflows/fips.yml
index 979cf4ba6..0324c5552 100644
--- a/.github/workflows/fips.yml
+++ b/.github/workflows/fips.yml
@@ -89,29 +89,14 @@ jobs:
         run: |
           make ci-env-up project_compose_ci=ci/pod/docker-compose.common.yml
 
-      - name: Start CI env (FIRST_TEST)
-        if: steps.test_env.outputs.type == 'first'
+      - name: Linux launch services
         run: |
-          # launch deps env
+          [[ ${{ steps.test_env.outputs.type }} != first ]] && sudo 
./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh before
+          [[ ${{ steps.test_env.outputs.type }} == plugin ]] && 
./ci/pod/openfunction/build-function-image.sh
           make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
-
-      - name: Start CI env (PLUGIN_TEST)
-        if: steps.test_env.outputs.type == 'plugin'
-        run: |
-          # download keycloak cas provider
-          sudo wget 
https://github.com/jacekkow/keycloak-protocol-cas/releases/download/18.0.2/keycloak-protocol-cas-18.0.2.jar
 -O /opt/keycloak-protocol-cas-18.0.2.jar
-
-          ./ci/pod/openfunction/build-function-image.sh
-          make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
-          sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh
-
-      - name: Start CI env (LAST_TEST)
-        if: steps.test_env.outputs.type == 'last'
-        run: |
-          # generating SSL certificates for Kafka
-          sudo keytool -genkeypair -keyalg RSA -dname "CN=127.0.0.1" -alias 
127.0.0.1 -keystore ./ci/pod/kafka/kafka-server/selfsigned.jks -validity 365 
-keysize 2048 -storepass changeit
-          make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
-          sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh
+          echo "make ci-env-up, done"
+          [[ ${{ steps.test_env.outputs.type }} != first ]] && sudo 
./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh after
+          echo "Linux launch services, done"
 
       - name: Linux Before install
         run: sudo ./ci/${{ matrix.os_name }}_runner.sh before_install
diff --git a/.github/workflows/gm-cron.yaml b/.github/workflows/gm-cron.yaml
index c0fcfa587..1cd9ef66b 100644
--- a/.github/workflows/gm-cron.yaml
+++ b/.github/workflows/gm-cron.yaml
@@ -86,29 +86,13 @@ jobs:
           make ci-env-up project_compose_ci=ci/pod/docker-compose.common.yml
           sudo ./ci/init-common-test-service.sh
 
-      - name: Start CI env (FIRST_TEST)
-        if: steps.test_env.outputs.type == 'first'
+      - name: Linux launch services
         run: |
-          # launch deps env
+          [[ ${{ steps.test_env.outputs.type }} != first ]] && sudo 
./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh before
+          [[ ${{ steps.test_env.outputs.type }} == plugin ]] && 
./ci/pod/openfunction/build-function-image.sh
           make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
-
-      - name: Start CI env (PLUGIN_TEST)
-        if: steps.test_env.outputs.type == 'plugin'
-        run: |
-          # download keycloak cas provider
-          sudo wget 
https://github.com/jacekkow/keycloak-protocol-cas/releases/download/18.0.2/keycloak-protocol-cas-18.0.2.jar
 -O /opt/keycloak-protocol-cas-18.0.2.jar
-
-          ./ci/pod/openfunction/build-function-image.sh
-          make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
-          sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh
-
-      - name: Start CI env (LAST_TEST)
-        if: steps.test_env.outputs.type == 'last'
-        run: |
-          # generating SSL certificates for Kafka
-          sudo keytool -genkeypair -keyalg RSA -dname "CN=127.0.0.1" -alias 
127.0.0.1 -keystore ./ci/pod/kafka/kafka-server/selfsigned.jks -validity 365 
-keysize 2048 -storepass changeit
-          make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ 
steps.test_env.outputs.type }}.yml
-          sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh
+          [[ ${{ steps.test_env.outputs.type }} != first ]] && sudo 
./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh after
+          echo "Linux launch services, done."
 
       - name: Start Dubbo Backend
         if: steps.test_env.outputs.type == 'plugin'
diff --git a/ci/backup-docker-images.sh b/ci/backup-docker-images.sh
new file mode 100644
index 000000000..bc87987a1
--- /dev/null
+++ b/ci/backup-docker-images.sh
@@ -0,0 +1,50 @@
+#!/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.
+#
+
+test_type=$1
+
+echo "started backing up, time: $(date)"
+mkdir docker-images-backup
+sum=$(cat ci/pod/docker-compose.$test_type.yml | grep image | wc -l)
+special_tag=$(cat ci/pod/docker-compose.$test_type.yml | grep image: | awk 
'{print $2}' | awk 'ORS=NR%"'$sum'"?" ":"\n"{print}')
+echo special: $special_tag
+openwhisk_tag="openwhisk/action-nodejs-v14:nightly 
openwhisk/standalone:nightly"
+echo
+echo special_tag: $special_tag
+echo openwhisk_tag: $openwhisk_tag
+echo
+all_tags="${special_tag} ${openwhisk_tag}"
+to_pull=""
+
+for tag in $all_tags
+do
+    if ! ( docker inspect $tag &> /dev/null )
+    then
+        to_pull="${to_pull} ${tag}"
+    fi
+done
+
+echo to pull : $to_pull
+
+if [[ -n $to_pull ]]
+then
+    echo "$to_pull" | xargs -P10 -n1 docker pull
+fi
+
+docker save $special_tag $openwhisk_tag -o 
docker-images-backup/apisix-images.tar
+echo "docker save done, time: $(date)"
diff --git a/ci/free_disk_space.sh b/ci/free_disk_space.sh
new file mode 100644
index 000000000..b385016fa
--- /dev/null
+++ b/ci/free_disk_space.sh
@@ -0,0 +1,31 @@
+#!/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.
+#
+
+# GitHub Action CI runner comes with a limited disk space, due to several 
reasons
+# it may become full. For example, caching docker images creates an archive of
+# several GBs of size, this sometimes leads to disk usage becoming full.
+# To keep CI functional, we delete large directories that we do not need.
+
+echo 
"=============================================================================="
+echo "Freeing up disk space on CI system"
+echo 
"=============================================================================="
+
+df -h
+echo "Removing unnecessary large directories"
+sudo rm -rf /usr/local/lib/android /usr/share/dotnet /usr/share/swift
+df -h
diff --git a/ci/init-last-test-service.sh b/ci/init-last-test-service.sh
index f49d4a747..5c3feeec7 100755
--- a/ci/init-last-test-service.sh
+++ b/ci/init-last-test-service.sh
@@ -16,15 +16,30 @@
 # limitations under the License.
 #
 
-docker exec -i apache-apisix_kafka-server1_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server1:2181 --replication-factor 1 --partitions 1 --topic test2
-docker exec -i apache-apisix_kafka-server1_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server1:2181 --replication-factor 1 --partitions 3 --topic test3
-docker exec -i apache-apisix_kafka-server2_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server2:2181 --replication-factor 1 --partitions 1 --topic test4
-docker exec -i apache-apisix_kafka-server1_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server1:2181 --replication-factor 1 --partitions 1 --topic 
test-consumer
+before() {
+    # generating SSL certificates for Kafka
+    sudo keytool -genkeypair -keyalg RSA -dname "CN=127.0.0.1" -alias 
127.0.0.1 -keystore ./ci/pod/kafka/kafka-server/selfsigned.jks -validity 365 
-keysize 2048 -storepass changeit
+}
 
-# create messages for test-consumer
-for i in `seq 30`
-do
-    docker exec -i apache-apisix_kafka-server1_1 bash -c "echo "testmsg$i" | 
/opt/bitnami/kafka/bin/kafka-console-producer.sh --bootstrap-server 
127.0.0.1:9092 --topic test-consumer"
-    echo "Produces messages to the test-consumer topic, msg: testmsg$i"
-done
-echo "Kafka service initialization completed"
+after() {
+    docker exec -i apache-apisix_kafka-server1_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server1:2181 --replication-factor 1 --partitions 1 --topic test2
+    docker exec -i apache-apisix_kafka-server1_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server1:2181 --replication-factor 1 --partitions 3 --topic test3
+    docker exec -i apache-apisix_kafka-server2_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server2:2181 --replication-factor 1 --partitions 1 --topic test4
+    docker exec -i apache-apisix_kafka-server1_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server1:2181 --replication-factor 1 --partitions 1 --topic 
test-consumer
+    # create messages for test-consumer
+    for i in `seq 30`
+    do
+        docker exec -i apache-apisix_kafka-server1_1 bash -c "echo "testmsg$i" 
| /opt/bitnami/kafka/bin/kafka-console-producer.sh --bootstrap-server 
127.0.0.1:9092 --topic test-consumer"
+        echo "Produces messages to the test-consumer topic, msg: testmsg$i"
+    done
+    echo "Kafka service initialization completed"
+}
+
+case $1 in
+    'after')
+        after
+        ;;
+    'before')
+        before
+        ;;
+esac
diff --git a/ci/init-plugin-test-service.sh b/ci/init-plugin-test-service.sh
index fd090441e..978b93543 100755
--- a/ci/init-plugin-test-service.sh
+++ b/ci/init-plugin-test-service.sh
@@ -16,30 +16,46 @@
 # limitations under the License.
 #
 
-docker exec -i apache-apisix_kafka-server1_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server1:2181 --replication-factor 1 --partitions 1 --topic test2
-docker exec -i apache-apisix_kafka-server1_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server1:2181 --replication-factor 1 --partitions 3 --topic test3
-docker exec -i apache-apisix_kafka-server2_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server2:2181 --replication-factor 1 --partitions 1 --topic test4
+after() {
+    docker exec -i apache-apisix_kafka-server1_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server1:2181 --replication-factor 1 --partitions 1 --topic test2
+    docker exec -i apache-apisix_kafka-server1_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server1:2181 --replication-factor 1 --partitions 3 --topic test3
+    docker exec -i apache-apisix_kafka-server2_1 
/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper 
zookeeper-server2:2181 --replication-factor 1 --partitions 1 --topic test4
 
-# prepare openwhisk env
-docker pull openwhisk/action-nodejs-v14:nightly
-docker run --rm -d --name openwhisk -p 3233:3233 -p 3232:3232 -v 
/var/run/docker.sock:/var/run/docker.sock openwhisk/standalone:nightly
-docker exec -i openwhisk waitready
-docker exec -i openwhisk bash -c "wsk package create pkg"
-docker exec -i openwhisk bash -c "wsk action update /guest/pkg/testpkg <(echo 
'function main(args){return {\"hello\": \"world\"}}') --kind nodejs:14"
-docker exec -i openwhisk bash -c "wsk action update test <(echo 'function 
main(args){return {\"hello\": \"test\"}}') --kind nodejs:14"
-docker exec -i openwhisk bash -c "wsk action update test-params <(echo 
'function main(args){return {\"hello\": args.name || \"test\"}}') --kind 
nodejs:14"
-docker exec -i openwhisk bash -c "wsk action update test-statuscode <(echo 
'function main(args){return {\"statusCode\": 407}}') --kind nodejs:14"
-docker exec -i openwhisk bash -c "wsk action update test-headers <(echo 
'function main(args){return {\"headers\": {\"test\":\"header\"}}}') --kind 
nodejs:14"
-docker exec -i openwhisk bash -c "wsk action update test-body <(echo 'function 
main(args){return {\"body\": {\"test\":\"body\"}}}') --kind nodejs:14"
+    # prepare openwhisk env
+    docker pull openwhisk/action-nodejs-v14:nightly
+    docker run --rm -d --name openwhisk -p 3233:3233 -p 3232:3232 -v 
/var/run/docker.sock:/var/run/docker.sock openwhisk/standalone:nightly
+    docker exec -i openwhisk waitready
+    docker exec -i openwhisk bash -c "wsk package create pkg"
+    docker exec -i openwhisk bash -c "wsk action update /guest/pkg/testpkg 
<(echo 'function main(args){return {\"hello\": \"world\"}}') --kind nodejs:14"
+    docker exec -i openwhisk bash -c "wsk action update test <(echo 'function 
main(args){return {\"hello\": \"test\"}}') --kind nodejs:14"
+    docker exec -i openwhisk bash -c "wsk action update test-params <(echo 
'function main(args){return {\"hello\": args.name || \"test\"}}') --kind 
nodejs:14"
+    docker exec -i openwhisk bash -c "wsk action update test-statuscode <(echo 
'function main(args){return {\"statusCode\": 407}}') --kind nodejs:14"
+    docker exec -i openwhisk bash -c "wsk action update test-headers <(echo 
'function main(args){return {\"headers\": {\"test\":\"header\"}}}') --kind 
nodejs:14"
+    docker exec -i openwhisk bash -c "wsk action update test-body <(echo 
'function main(args){return {\"body\": {\"test\":\"body\"}}}') --kind nodejs:14"
 
 
-docker exec -i rmqnamesrv rm /home/rocketmq/rocketmq-4.6.0/conf/tools.yml
-docker exec -i rmqnamesrv /home/rocketmq/rocketmq-4.6.0/bin/mqadmin 
updateTopic -n rocketmq_namesrv:9876 -t test -c DefaultCluster
-docker exec -i rmqnamesrv /home/rocketmq/rocketmq-4.6.0/bin/mqadmin 
updateTopic -n rocketmq_namesrv:9876 -t test2 -c DefaultCluster
-docker exec -i rmqnamesrv /home/rocketmq/rocketmq-4.6.0/bin/mqadmin 
updateTopic -n rocketmq_namesrv:9876 -t test3 -c DefaultCluster
-docker exec -i rmqnamesrv /home/rocketmq/rocketmq-4.6.0/bin/mqadmin 
updateTopic -n rocketmq_namesrv:9876 -t test4 -c DefaultCluster
+    docker exec -i rmqnamesrv rm /home/rocketmq/rocketmq-4.6.0/conf/tools.yml
+    docker exec -i rmqnamesrv /home/rocketmq/rocketmq-4.6.0/bin/mqadmin 
updateTopic -n rocketmq_namesrv:9876 -t test -c DefaultCluster
+    docker exec -i rmqnamesrv /home/rocketmq/rocketmq-4.6.0/bin/mqadmin 
updateTopic -n rocketmq_namesrv:9876 -t test2 -c DefaultCluster
+    docker exec -i rmqnamesrv /home/rocketmq/rocketmq-4.6.0/bin/mqadmin 
updateTopic -n rocketmq_namesrv:9876 -t test3 -c DefaultCluster
+    docker exec -i rmqnamesrv /home/rocketmq/rocketmq-4.6.0/bin/mqadmin 
updateTopic -n rocketmq_namesrv:9876 -t test4 -c DefaultCluster
 
-# wait for keycloak ready
-bash -c 'while true; do curl -s localhost:8080 &>/dev/null; ret=$?; [[ $ret 
-eq 0 ]] && break; sleep 3; done'
-docker cp ci/kcadm_configure_cas.sh apisix_keycloak_new:/tmp/
-docker exec apisix_keycloak_new bash /tmp/kcadm_configure_cas.sh
+    # wait for keycloak ready
+    bash -c 'while true; do curl -s localhost:8080 &>/dev/null; ret=$?; [[ 
$ret -eq 0 ]] && break; sleep 3; done'
+    docker cp ci/kcadm_configure_cas.sh apisix_keycloak_new:/tmp/
+    docker exec apisix_keycloak_new bash /tmp/kcadm_configure_cas.sh
+}
+
+before() {
+    # download keycloak cas provider
+    sudo wget 
https://github.com/jacekkow/keycloak-protocol-cas/releases/download/18.0.2/keycloak-protocol-cas-18.0.2.jar
 -O /opt/keycloak-protocol-cas-18.0.2.jar
+}
+
+case $1 in
+    'after')
+        after
+        ;;
+    'before')
+        before
+        ;;
+esac

Reply via email to