From e1c5671991e332f18b5d9816c5bd7134b9d35892 Mon Sep 17 00:00:00 2001 From: nic-chen Date: Sat, 7 Nov 2020 20:46:25 +0800 Subject: [PATCH] fix: CI fail --- .github/workflows/deploy-with-docker.yml | 8 +---- api/test/shell/docker_deploy_test.sh | 43 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 7 deletions(-) create mode 100755 api/test/shell/docker_deploy_test.sh diff --git a/.github/workflows/deploy-with-docker.yml b/.github/workflows/deploy-with-docker.yml index ab836e2058..1f75f77985 100644 --- a/.github/workflows/deploy-with-docker.yml +++ b/.github/workflows/deploy-with-docker.yml @@ -41,13 +41,7 @@ jobs: docker logs docker-deploy_managerapi_1 - name: Run Test - run: | - curl http://127.0.0.1:8088/apisix/admin/user/login -X POST -i -d '{"username":"admin", "password": "admin"}' - code=$(curl -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:8088/apisix/admin/user/login -X POST -i -d '{"username":"admin", "password": "admin"}') - if [ ! $code -eq 200 ]; then - echo "failed: failed to custom port" - exit 1 - fi + run: api/test/shell/docker_deploy_test.sh - name: Deploy run: | diff --git a/api/test/shell/docker_deploy_test.sh b/api/test/shell/docker_deploy_test.sh new file mode 100755 index 0000000000..eb39633019 --- /dev/null +++ b/api/test/shell/docker_deploy_test.sh @@ -0,0 +1,43 @@ +#!/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 + +# web page +curl http://127.0.0.1:8080 +code=$(curl -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:8080) +if [ ! $code -eq 200 ]; then + echo "failed: failed to custom port" + exit 1 +fi + +# login +resp=$(curl http://127.0.0.1:8080/apisix/admin/user/login -X POST -d '{"username":"admin", "password": "admin"}') +token=$(echo "${resp}" | sed 's/{/\n/g' | sed 's/,/\n/g' | grep "token" | sed 's/:/\n/g' | sed '1d' | sed 's/}//g' | sed 's/"//g') +if [ -z "${token}" ]; then + echo "login failed" +fi + +# plugin orchestration +echo $token +code=$(curl -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:8080/apisix/admin/routes/1 -X PUT -i -H "Authorization: $token" -d '{"id":"1","uri":"/index.html","upstream":{"type":"roundrobin","nodes":[{"host":"www.test.com","port":80,"weight":1}]},"script":{"rule":{"root":"451106f8-560c-43a4-acf2-2a6ed0ea57b8","451106f8-560c-43a4-acf2-2a6ed0ea57b8":[["code==403","b93d622c-92ef-48b4-b6bb-57e1ce893ee3"],["","988ef5c2-c896-4606-a666-3d4cbe24a731"]]},"conf":{"451106f8-560c-43a4-acf2-2a6ed0ea57b8":{"name":"uri-blocker","conf":{"block_rules":["root.exe","root.m+"],"rejected_code":403}},"988ef5c2-c896-4606-a666-3d4cbe24a731":{"name":"kafka-logger","conf":{"batch_max_size":1000,"broker_list":{},"buffer_duration":60,"inactive_timeout":5,"include_req_body":false,"kafka_topic":"1","key":"2","max_retry_count":0,"name":"kafkalogger","retry_delay":1,"timeout":3}},"b93d622c-92ef-48b4-b6bb-57e1ce893ee3":{"name":"fault-injection","conf":{"abort":{"body":"200","http_status":300},"delay":{"duration":500}}}},"chart":{}}}') +if [ ! $code -eq 200 ]; then + echo "failed to create route" + exit 1 +fi