Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TT-13048] Flaky test due to using httpbin org, improvements #6504

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docker/services/httpbin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ services:
image: tykio/ci-tools:latest
networks:
- proxy
ports:
- 3123:3123
volumes:
- ./logs:/logs:rw
entrypoint:
- /usr/local/bin/httpbin-logserver
command:
- '-addr'
- ':80'
- ':3123'
- '-output'
- '/logs/service.json'
2 changes: 1 addition & 1 deletion tests/regression/issue_10104_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func Test_Issue10104(t *testing.T) {
ts := gateway.StartTest(nil)
defer ts.Close()
t.Cleanup(ts.Close)

// load api definition from file
ts.Gw.LoadAPI(loadAPISpec(t, "testdata/issue-10104-apidef.json"))
Expand Down
4 changes: 2 additions & 2 deletions tests/regression/issue_11585_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
func Test_Issue11585_DeleteAPICacheSignal(t *testing.T) {
t.Run("redis event", func(t *testing.T) {
ts := gateway.StartTest(nil)
defer ts.Close()
t.Cleanup(ts.Close)

api := ts.Gw.BuildAndLoadAPI(func(spec *gateway.APISpec) {
spec.UseKeylessAccess = true
Expand Down Expand Up @@ -49,7 +49,7 @@ func Test_Issue11585_DeleteAPICacheSignal(t *testing.T) {

t.Run("rpc", func(t *testing.T) {
ts := gateway.StartTest(nil)
defer ts.Close()
t.Cleanup(ts.Close)

rpcListener := gateway.RPCStorageHandler{
KeyPrefix: "rpc.listener.",
Expand Down
14 changes: 7 additions & 7 deletions tests/regression/issue_11806_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func Test_Issue11806_DomainRouting(t *testing.T) {

t.Run("Load listenPath without domain first", func(t *testing.T) {
ts := gateway.StartTest(testConfig)
defer ts.Close()
t.Cleanup(ts.Close)

ts.Gw.LoadAPI(noDomain, withDomain)

Expand All @@ -34,7 +34,7 @@ func Test_Issue11806_DomainRouting(t *testing.T) {

t.Run("Load listenPath with domain first", func(t *testing.T) {
ts := gateway.StartTest(testConfig)
defer ts.Close()
t.Cleanup(ts.Close)

ts.Gw.LoadAPI(withDomain, noDomain)

Expand Down Expand Up @@ -62,10 +62,10 @@ func testDomainRouting(tb testing.TB, ts *gateway.Test) {
},
{
Path: "/test/",
Host: "customer.mydomain.com",
Host: "example.com",
Method: http.MethodGet,
Code: http.StatusOK,
BodyMatch: "customer.mydomain.com",
BodyMatch: "example.com",
},
}...)
}
Expand All @@ -80,7 +80,7 @@ func testSubrouterHost(t *testing.T) {
ctx := context.Background()

// Create a subrouter with a specific host
subrouter := router.Host("customer.mydomain.com").Subrouter()
subrouter := router.Host("example.com").Subrouter()
subrouter.HandleFunc("/test", func(w http.ResponseWriter, _ *http.Request) {
_, err := w.Write([]byte("Subrouter"))
assert.NoError(t, err)
Expand Down Expand Up @@ -117,7 +117,7 @@ func testSubrouterHost(t *testing.T) {
reqWithSpecificHost, err := http.NewRequestWithContext(ctx, "GET", "/test", nil)
assert.NoError(t, err)

reqWithSpecificHost.Host = "customer.mydomain.com"
reqWithSpecificHost.Host = "example.com"
respWithSpecificHost := httptest.NewRecorder()
router.ServeHTTP(respWithSpecificHost, reqWithSpecificHost)
if respWithSpecificHost.Body.String() != "Subrouter" {
Expand All @@ -131,7 +131,7 @@ func testRouteLongestPathFirst(t *testing.T) {
ts := gateway.StartTest(func(globalConf *config.Config) {
globalConf.EnableCustomDomains = true
})
defer ts.Close()
t.Cleanup(ts.Close)

type hostAndPath struct {
host, path string
Expand Down
4 changes: 4 additions & 0 deletions tests/regression/regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package regression
import (
"embed"
"encoding/json"
"strings"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -25,6 +26,9 @@ func loadAPISpec(tb testing.TB, filename string) *gateway.APISpec {
err := json.Unmarshal(data, apidef)
require.NoError(tb, err, "Error decoding API Definition: %s", filename)

// auto replace from public to private endpoint, part of CI env
apidef.Proxy.ListenPath = strings.ReplaceAll(apidef.Proxy.ListenPath, "httpbin.org", "127.0.0.1:3123")

return &gateway.APISpec{
APIDefinition: apidef,
}
Expand Down
4 changes: 2 additions & 2 deletions tests/regression/testdata/issue-11806-api-with-domain.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"auth": {
"auth_header_name": "Authorization"
},
"domain": "customer.mydomain.com",
"domain": "example.com",
"name": "api3",
"proxy": {
"listen_path": "/test/",
"strip_listen_path": true,
"target_url": "http://httpbin.org/anything/api3/customer.mydomain.com"
"target_url": "http://httpbin.org/anything/api3/example.com"
},
"use_keyless": true,
"version_data": {
Expand Down
Loading