Skip to content

Commit 3f0e2eb

Browse files
soulbirdsoulbird
and
soulbird
authoredMay 23, 2022
chore(ci): move set_dns.sh to ci dir (#7089)
Co-authored-by: soulbird <zhaothree@gmail.com>
1 parent 4dd01ca commit 3f0e2eb

7 files changed

+47
-65
lines changed
 

‎ci/centos7-ci.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ install_dependencies() {
8686
run_case() {
8787
export_or_prefix
8888
make init
89-
./utils/set-dns.sh
89+
set_coredns
9090
# run test cases
9191
FLUSH_ETCD=1 prove -Itest-nginx/lib -I./ -r ${TEST_FILE_SUB_DIR} | tee /tmp/test.result
9292
rerun_flaky_tests /tmp/test.result

‎ci/common.sh

+42
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,48 @@ install_nodejs () {
7979
ln -s ${NODEJS_PREFIX}/bin/npm /usr/local/bin/npm
8080
}
8181

82+
set_coredns() {
83+
# test a domain name is configured as upstream
84+
echo "127.0.0.1 test.com" | sudo tee -a /etc/hosts
85+
echo "::1 ipv6.local" | sudo tee -a /etc/hosts
86+
# test certificate verification
87+
echo "127.0.0.1 admin.apisix.dev" | sudo tee -a /etc/hosts
88+
cat /etc/hosts # check GitHub Action's configuration
89+
90+
# override DNS configures
91+
if [ -f "/etc/netplan/50-cloud-init.yaml" ]; then
92+
sudo pip3 install yq
93+
94+
tmp=$(mktemp)
95+
yq -y '.network.ethernets.eth0."dhcp4-overrides"."use-dns"=false' /etc/netplan/50-cloud-init.yaml | \
96+
yq -y '.network.ethernets.eth0."dhcp4-overrides"."use-domains"=false' | \
97+
yq -y '.network.ethernets.eth0.nameservers.addresses[0]="8.8.8.8"' | \
98+
yq -y '.network.ethernets.eth0.nameservers.search[0]="apache.org"' > $tmp
99+
mv $tmp /etc/netplan/50-cloud-init.yaml
100+
cat /etc/netplan/50-cloud-init.yaml
101+
sudo netplan apply
102+
sleep 3
103+
104+
sudo mv /etc/resolv.conf /etc/resolv.conf.bak
105+
sudo ln -s /run/systemd/resolve/resolv.conf /etc/
106+
fi
107+
cat /etc/resolv.conf
108+
109+
mkdir -p build-cache
110+
111+
if [ ! -f "build-cache/coredns_1_8_1" ]; then
112+
wget https://github.com/coredns/coredns/releases/download/v1.8.1/coredns_1.8.1_linux_amd64.tgz
113+
tar -xvf coredns_1.8.1_linux_amd64.tgz
114+
mv coredns build-cache/
115+
116+
touch build-cache/coredns_1_8_1
117+
fi
118+
119+
pushd t/coredns || exit 1
120+
../../build-cache/coredns -dns.port=1053 &
121+
popd || exit 1
122+
}
123+
82124
GRPC_SERVER_EXAMPLE_VER=20210819
83125

84126
linux_get_dependencies () {

‎ci/linux_apisix_current_luarocks_runner.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ script() {
6060
cd ..
6161

6262
# apisix cli test
63-
./utils/set-dns.sh
63+
set_coredns
6464

6565
# install test dependencies
6666
sudo pip install requests

‎ci/linux_openresty_common_runner.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ script() {
6868
export_or_prefix
6969
openresty -V
7070

71-
./utils/set-dns.sh
71+
set_coredns
7272

7373
./t/grpc_server_example/grpc_server_example \
7474
-grpc-address :50051 -grpcs-address :50052 -grpcs-mtls-address :50053 \

‎t/cli/test_admin_mtls.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
. ./t/cli/common.sh
2121

22-
# The 'admin.apisix.dev' is injected by utils/set-dns.sh
22+
# The 'admin.apisix.dev' is injected by ci/common.sh@set_coredns
2323

2424
echo '
2525
apisix:

‎t/cli/test_etcd_mtls.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
exit_if_not_customed_nginx
2323

24-
# The 'admin.apisix.dev' is injected by utils/set-dns.sh
24+
# The 'admin.apisix.dev' is injected by ci/common.sh@set_coredns
2525

2626
# etcd mTLS verify
2727
echo '

‎utils/set-dns.sh

-60
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.