You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2022/05/23 01:46:06 UTC

[apisix] branch master updated: chore(ci): move set_dns.sh to ci dir (#7089)

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 3f0e2ebe6 chore(ci): move set_dns.sh to ci dir (#7089)
3f0e2ebe6 is described below

commit 3f0e2ebe6c8c144cbd689c78b3594100f9655f3a
Author: soulbird <zh...@outlook.com>
AuthorDate: Mon May 23 09:46:02 2022 +0800

    chore(ci): move set_dns.sh to ci dir (#7089)
    
    Co-authored-by: soulbird <zh...@gmail.com>
---
 ci/centos7-ci.sh                           |  2 +-
 ci/common.sh                               | 42 +++++++++++++++++++++
 ci/linux_apisix_current_luarocks_runner.sh |  2 +-
 ci/linux_openresty_common_runner.sh        |  2 +-
 t/cli/test_admin_mtls.sh                   |  2 +-
 t/cli/test_etcd_mtls.sh                    |  2 +-
 utils/set-dns.sh                           | 60 ------------------------------
 7 files changed, 47 insertions(+), 65 deletions(-)

diff --git a/ci/centos7-ci.sh b/ci/centos7-ci.sh
index d6cc7fab7..0f066e6c1 100755
--- a/ci/centos7-ci.sh
+++ b/ci/centos7-ci.sh
@@ -86,7 +86,7 @@ install_dependencies() {
 run_case() {
     export_or_prefix
     make init
-    ./utils/set-dns.sh
+    set_coredns
     # run test cases
     FLUSH_ETCD=1 prove -Itest-nginx/lib -I./ -r ${TEST_FILE_SUB_DIR} | tee /tmp/test.result
     rerun_flaky_tests /tmp/test.result
diff --git a/ci/common.sh b/ci/common.sh
index fd5575c0f..8184bea0a 100644
--- a/ci/common.sh
+++ b/ci/common.sh
@@ -79,6 +79,48 @@ install_nodejs () {
     ln -s ${NODEJS_PREFIX}/bin/npm /usr/local/bin/npm
 }
 
+set_coredns() {
+    # test a domain name is configured as upstream
+    echo "127.0.0.1 test.com" | sudo tee -a /etc/hosts
+    echo "::1 ipv6.local" | sudo tee -a /etc/hosts
+    # test certificate verification
+    echo "127.0.0.1 admin.apisix.dev" | sudo tee -a /etc/hosts
+    cat /etc/hosts # check GitHub Action's configuration
+
+    # override DNS configures
+    if [ -f "/etc/netplan/50-cloud-init.yaml" ]; then
+        sudo pip3 install yq
+
+        tmp=$(mktemp)
+        yq -y '.network.ethernets.eth0."dhcp4-overrides"."use-dns"=false' /etc/netplan/50-cloud-init.yaml | \
+        yq -y '.network.ethernets.eth0."dhcp4-overrides"."use-domains"=false' | \
+        yq -y '.network.ethernets.eth0.nameservers.addresses[0]="8.8.8.8"' | \
+        yq -y '.network.ethernets.eth0.nameservers.search[0]="apache.org"' > $tmp
+        mv $tmp /etc/netplan/50-cloud-init.yaml
+        cat /etc/netplan/50-cloud-init.yaml
+        sudo netplan apply
+        sleep 3
+
+        sudo mv /etc/resolv.conf /etc/resolv.conf.bak
+        sudo ln -s /run/systemd/resolve/resolv.conf /etc/
+    fi
+    cat /etc/resolv.conf
+
+    mkdir -p build-cache
+
+    if [ ! -f "build-cache/coredns_1_8_1" ]; then
+        wget https://github.com/coredns/coredns/releases/download/v1.8.1/coredns_1.8.1_linux_amd64.tgz
+        tar -xvf coredns_1.8.1_linux_amd64.tgz
+        mv coredns build-cache/
+
+        touch build-cache/coredns_1_8_1
+    fi
+
+    pushd t/coredns || exit 1
+    ../../build-cache/coredns -dns.port=1053 &
+    popd || exit 1
+}
+
 GRPC_SERVER_EXAMPLE_VER=20210819
 
 linux_get_dependencies () {
diff --git a/ci/linux_apisix_current_luarocks_runner.sh b/ci/linux_apisix_current_luarocks_runner.sh
index 3989d0df0..7fa165fb7 100755
--- a/ci/linux_apisix_current_luarocks_runner.sh
+++ b/ci/linux_apisix_current_luarocks_runner.sh
@@ -60,7 +60,7 @@ script() {
     cd ..
 
     # apisix cli test
-    ./utils/set-dns.sh
+    set_coredns
 
     # install test dependencies
     sudo pip install requests
diff --git a/ci/linux_openresty_common_runner.sh b/ci/linux_openresty_common_runner.sh
index 16579d527..02e5ea471 100755
--- a/ci/linux_openresty_common_runner.sh
+++ b/ci/linux_openresty_common_runner.sh
@@ -68,7 +68,7 @@ script() {
     export_or_prefix
     openresty -V
 
-    ./utils/set-dns.sh
+    set_coredns
 
     ./t/grpc_server_example/grpc_server_example \
         -grpc-address :50051 -grpcs-address :50052 -grpcs-mtls-address :50053 \
diff --git a/t/cli/test_admin_mtls.sh b/t/cli/test_admin_mtls.sh
index aa90e5053..7bdb06e43 100755
--- a/t/cli/test_admin_mtls.sh
+++ b/t/cli/test_admin_mtls.sh
@@ -19,7 +19,7 @@
 
 . ./t/cli/common.sh
 
-# The 'admin.apisix.dev' is injected by utils/set-dns.sh
+# The 'admin.apisix.dev' is injected by ci/common.sh@set_coredns
 
 echo '
 apisix:
diff --git a/t/cli/test_etcd_mtls.sh b/t/cli/test_etcd_mtls.sh
index ebceef6a4..6741ea178 100755
--- a/t/cli/test_etcd_mtls.sh
+++ b/t/cli/test_etcd_mtls.sh
@@ -21,7 +21,7 @@
 
 exit_if_not_customed_nginx
 
-# The 'admin.apisix.dev' is injected by utils/set-dns.sh
+# The 'admin.apisix.dev' is injected by ci/common.sh@set_coredns
 
 # etcd mTLS verify
 echo '
diff --git a/utils/set-dns.sh b/utils/set-dns.sh
deleted file mode 100755
index 021278fb8..000000000
--- a/utils/set-dns.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/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 -ex
-
-# test a domain name is configured as upstream
-echo "127.0.0.1 test.com" | sudo tee -a /etc/hosts
-echo "::1 ipv6.local" | sudo tee -a /etc/hosts
-# test certificate verification
-echo "127.0.0.1 admin.apisix.dev" | sudo tee -a /etc/hosts
-cat /etc/hosts # check GitHub Action's configuration
-
-# override DNS configures
-if [ -f "/etc/netplan/50-cloud-init.yaml" ]; then
-    sudo pip3 install yq
-
-    tmp=$(mktemp)
-    yq -y '.network.ethernets.eth0."dhcp4-overrides"."use-dns"=false' /etc/netplan/50-cloud-init.yaml | \
-    yq -y '.network.ethernets.eth0."dhcp4-overrides"."use-domains"=false' | \
-    yq -y '.network.ethernets.eth0.nameservers.addresses[0]="8.8.8.8"' | \
-    yq -y '.network.ethernets.eth0.nameservers.search[0]="apache.org"' > $tmp
-    mv $tmp /etc/netplan/50-cloud-init.yaml
-    cat /etc/netplan/50-cloud-init.yaml
-    sudo netplan apply
-    sleep 3
-
-    sudo mv /etc/resolv.conf /etc/resolv.conf.bak
-    sudo ln -s /run/systemd/resolve/resolv.conf /etc/
-fi
-cat /etc/resolv.conf
-
-mkdir -p build-cache
-
-if [ ! -f "build-cache/coredns_1_8_1" ]; then
-    wget https://github.com/coredns/coredns/releases/download/v1.8.1/coredns_1.8.1_linux_amd64.tgz
-    tar -xvf coredns_1.8.1_linux_amd64.tgz
-    mv coredns build-cache/
-
-    touch build-cache/coredns_1_8_1
-fi
-
-pushd t/coredns || exit 1
-../../build-cache/coredns -dns.port=1053 &
-popd || exit 1