-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update integration test * chmod test file * update test-pipeline.yml * add more integration test * remove filter inherit close previous generation since pipline inherit will close previous filters, double close may cause problem
- Loading branch information
1 parent
5596d7c
commit 96e546c
Showing
27 changed files
with
450 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,19 @@ jobs: | |
uses: codecov/[email protected] | ||
with: | ||
file: ./coverage.txt | ||
integration-test-ubuntu: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: Set up Go 1.x.y | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Checkout codebase | ||
uses: actions/checkout@v3 | ||
|
||
- name: Test | ||
run: | | ||
make integration_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2017, MegaEase | ||
# All rights reserved. | ||
# | ||
# Licensed 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:https://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 the Easegress' basic functionality which is generating | ||
# an HTTPServer and Pipeline for testing HTTP Requests. | ||
set -e | ||
|
||
# path related define. | ||
# Note: use $(dirname $(realpath ${BASH_SOURCE[0]})) to value SCRIPTPATH is OK in linux platform, | ||
# but not in MacOS.(cause there is not `realpath` in it) | ||
# reference: https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself | ||
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" | ||
pushd $SCRIPTPATH"/../../example" > /dev/null | ||
EXAMPLEDIR="$SCRIPTPATH"/../../example | ||
|
||
# clean cleans primary-single's data and cluster data and the `go run` process. | ||
function clean() | ||
{ | ||
# basic cleaning routine | ||
bash $EXAMPLEDIR/stop_cluster.sh | ||
bash $EXAMPLEDIR/clean_cluster.sh | ||
} | ||
|
||
# clean the cluster resource. | ||
clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright (c) 2017, MegaEase | ||
* All rights reserved. | ||
* | ||
* Licensed 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:https://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. | ||
*/ | ||
|
||
package test | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"net/http" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func makeURL(template string, a ...interface{}) string { | ||
return "http:https://127.0.0.1:12381/apis/v1" + fmt.Sprintf(template, a...) | ||
} | ||
|
||
func successfulStatusCode(code int) bool { | ||
return code >= 200 && code < 300 | ||
} | ||
|
||
func intentString(str string) string { | ||
return "\n\t\t" + strings.ReplaceAll(str, "\n", "\n\t\t") | ||
} | ||
|
||
func handleRequest(t *testing.T, method string, url string, reader io.Reader) *http.Response { | ||
req, err := http.NewRequest(method, url, reader) | ||
require.Nil(t, err) | ||
resp, err := http.DefaultClient.Do(req) | ||
require.Nil(t, err) | ||
return resp | ||
} | ||
|
||
const ( | ||
objectsURL = "/objects" | ||
objectURL = "/objects/%s" | ||
) | ||
|
||
func createObject(t *testing.T, yamlFile string) (ok bool, msg string) { | ||
resp := handleRequest(t, http.MethodPost, makeURL(objectsURL), strings.NewReader(yamlFile)) | ||
defer resp.Body.Close() | ||
|
||
ok = successfulStatusCode(resp.StatusCode) | ||
if !ok { | ||
data, err := io.ReadAll(resp.Body) | ||
require.Nil(t, err) | ||
msg = fmt.Sprintf("create object\n %v\nfailed, %v", intentString(yamlFile), intentString(string(data))) | ||
} | ||
return | ||
} | ||
|
||
func updateObject(t *testing.T, name string, yamlFile string) (ok bool, msg string) { | ||
resp := handleRequest(t, http.MethodPut, makeURL(objectURL, name), strings.NewReader(yamlFile)) | ||
defer resp.Body.Close() | ||
|
||
ok = successfulStatusCode(resp.StatusCode) | ||
if !ok { | ||
data, err := io.ReadAll(resp.Body) | ||
require.Nil(t, err) | ||
msg = fmt.Sprintf("update object %v\n %v\nfailed, %v", name, intentString(yamlFile), intentString(string(data))) | ||
} | ||
return | ||
} | ||
|
||
func deleteObject(t *testing.T, name string) (ok bool, msg string) { | ||
resp := handleRequest(t, http.MethodDelete, makeURL(objectURL, name), nil) | ||
defer resp.Body.Close() | ||
|
||
ok = successfulStatusCode(resp.StatusCode) | ||
if !ok { | ||
data, err := io.ReadAll(resp.Body) | ||
require.Nil(t, err) | ||
msg = fmt.Sprintf("delete object %v failed, %v", name, intentString(string(data))) | ||
} | ||
return ok, msg | ||
} | ||
|
||
func listObject(t *testing.T) (ok bool, msg string) { | ||
resp := handleRequest(t, http.MethodGet, makeURL(objectsURL), nil) | ||
defer resp.Body.Close() | ||
|
||
data, err := io.ReadAll(resp.Body) | ||
require.Nil(t, err) | ||
return successfulStatusCode(resp.StatusCode), string(data) | ||
} |
Oops, something went wrong.