mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-25 23:03:38 +01:00
ci: stabilize e2e tests
This commit is contained in:
37
Makefile
37
Makefile
@@ -23,6 +23,13 @@ build:
|
||||
test:
|
||||
go test -v ./...
|
||||
|
||||
.PHONY: docker
|
||||
docker:
|
||||
docker build -t acouvreur/sablier:local .
|
||||
|
||||
caddy:
|
||||
docker build -t caddy:local plugins/caddy
|
||||
|
||||
release: $(PLATFORMS)
|
||||
.PHONY: release $(PLATFORMS)
|
||||
|
||||
@@ -41,18 +48,40 @@ docs:
|
||||
docsify serve docs
|
||||
|
||||
# End to end tests
|
||||
e2e: e2e-caddy e2e-nginx e2e-traefik
|
||||
|
||||
## Caddy
|
||||
e2e-caddy-docker:
|
||||
cd plugins/caddy/e2e/docker && bash ./run.sh
|
||||
|
||||
e2e-caddy-swarm:
|
||||
cd plugins/caddy/e2e/docker_swarm && bash ./run.sh
|
||||
|
||||
e2e-caddy-kubernetes:
|
||||
# e2e-caddy-kubernetes:
|
||||
# cd plugins/caddy/e2e/kubernetes && bash ./run.sh
|
||||
|
||||
e2e-caddy: e2e-caddy-docker e2e-caddy-swarm e2e-caddy-kubernetes
|
||||
e2e-caddy: e2e-caddy-docker e2e-caddy-swarm # e2e-caddy-kubernetes
|
||||
|
||||
## NGinx
|
||||
e2e-caddy: e2e-caddy-docker e2e-caddy-swarm e2e-caddy-kubernetes
|
||||
e2e-nginx-docker:
|
||||
cd plugins/nginx/e2e/docker && bash ./run.sh
|
||||
|
||||
e2e-nginx-swarm:
|
||||
cd plugins/nginx/e2e/docker_swarm && bash ./run.sh
|
||||
|
||||
e2e-nginx-kubernetes:
|
||||
cd plugins/nginx/e2e/kubernetes && bash ./run.sh
|
||||
|
||||
e2e-nginx: e2e-nginx-docker e2e-nginx-swarm e2e-nginx-kubernetes
|
||||
|
||||
## Traefik
|
||||
e2e:
|
||||
e2e-traefik-docker:
|
||||
cd plugins/traefik/e2e/docker && bash ./run.sh
|
||||
|
||||
e2e-traefik-swarm:
|
||||
cd plugins/traefik/e2e/docker_swarm && bash ./run.sh
|
||||
|
||||
e2e-traefik-kubernetes:
|
||||
cd plugins/traefik/e2e/kubernetes && bash ./run.sh
|
||||
|
||||
e2e-traefik: e2e-traefik-docker e2e-traefik-swarm e2e-traefik-kubernetes
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gavv/httpexpect/v2"
|
||||
)
|
||||
|
||||
var waitingTime = 10 * time.Second
|
||||
|
||||
func Test_Dynamic(t *testing.T) {
|
||||
e := httpexpect.New(t, "http://localhost:8080/dynamic/")
|
||||
e := httpexpect.Default(t, "http://localhost:8080/dynamic/")
|
||||
|
||||
e.GET("/whoami").
|
||||
Expect().
|
||||
@@ -23,16 +23,30 @@ func Test_Dynamic(t *testing.T) {
|
||||
Contains(`Dynamic Whoami`).
|
||||
Contains(`Your instance(s) will stop after 1 minutes of inactivity`)
|
||||
|
||||
time.Sleep(waitingTime)
|
||||
|
||||
e.GET("/whoami").
|
||||
WithMaxRetries(10).
|
||||
WithRetryDelay(time.Second, time.Second*2).
|
||||
WithRetryPolicy(httpexpect.RetryCustomHandler).
|
||||
WithCustomHandler(func(resp *http.Response, _ error) bool {
|
||||
if resp.Body != nil {
|
||||
|
||||
// Check body if available, etc.
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
return !strings.Contains(string(body), "Host: localhost:8080")
|
||||
}
|
||||
return false
|
||||
}).
|
||||
Expect().
|
||||
Status(http.StatusOK).
|
||||
Body().Contains(`Host: localhost:8080`)
|
||||
}
|
||||
|
||||
func Test_Blocking(t *testing.T) {
|
||||
e := httpexpect.New(t, "http://localhost:8080/blocking/")
|
||||
e := httpexpect.Default(t, "http://localhost:8080/blocking/")
|
||||
|
||||
e.GET("/whoami").
|
||||
Expect().
|
||||
@@ -41,7 +55,7 @@ func Test_Blocking(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Multiple(t *testing.T) {
|
||||
e := httpexpect.New(t, "http://localhost:8080/multiple/")
|
||||
e := httpexpect.Default(t, "http://localhost:8080/multiple/")
|
||||
|
||||
e.GET("/whoami").
|
||||
Expect().
|
||||
@@ -50,21 +64,50 @@ func Test_Multiple(t *testing.T) {
|
||||
Contains(`Multiple Whoami`).
|
||||
Contains(`Your instance(s) will stop after 1 minutes of inactivity`)
|
||||
|
||||
time.Sleep(waitingTime)
|
||||
|
||||
e.GET("/whoami").
|
||||
WithMaxRetries(10).
|
||||
WithRetryDelay(time.Second, time.Second*2).
|
||||
WithRetryPolicy(httpexpect.RetryCustomHandler).
|
||||
WithCustomHandler(func(resp *http.Response, _ error) bool {
|
||||
if resp.Body != nil {
|
||||
// Check body if available, etc.
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
return !strings.Contains(string(body), "Host: localhost:8080")
|
||||
}
|
||||
return false
|
||||
}).
|
||||
Expect().
|
||||
Status(http.StatusOK).
|
||||
Body().Contains(`Host: localhost:8080`)
|
||||
|
||||
e.GET("/nginx").
|
||||
WithMaxRetries(10).
|
||||
WithRetryDelay(time.Second, time.Second*2).
|
||||
WithRetryPolicy(httpexpect.RetryCustomHandler).
|
||||
WithCustomHandler(func(resp *http.Response, _ error) bool {
|
||||
if resp.Body != nil {
|
||||
|
||||
// Check body if available, etc.
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
return !strings.Contains(string(body), "nginx/")
|
||||
}
|
||||
return false
|
||||
}).
|
||||
Expect().
|
||||
Status(http.StatusNotFound).
|
||||
Body().Contains(`nginx/1.23.1`)
|
||||
Body().Contains(`nginx/`)
|
||||
}
|
||||
|
||||
func Test_Healthy(t *testing.T) {
|
||||
e := httpexpect.New(t, "http://localhost:8080/healthy/")
|
||||
e := httpexpect.Default(t, "http://localhost:8080/healthy/")
|
||||
|
||||
e.GET("/nginx").
|
||||
Expect().
|
||||
@@ -73,10 +116,24 @@ func Test_Healthy(t *testing.T) {
|
||||
Contains(`Healthy Nginx`).
|
||||
Contains(`Your instance(s) will stop after 1 minutes of inactivity`)
|
||||
|
||||
time.Sleep(waitingTime)
|
||||
|
||||
e.GET("/nginx").
|
||||
WithMaxRetries(10).
|
||||
WithRetryDelay(time.Second, time.Second*2).
|
||||
WithRetryPolicy(httpexpect.RetryCustomHandler).
|
||||
WithCustomHandler(func(resp *http.Response, _ error) bool {
|
||||
if resp.Body != nil {
|
||||
|
||||
// Check body if available, etc.
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
return !strings.Contains(string(body), "nginx/")
|
||||
}
|
||||
return false
|
||||
}).
|
||||
Expect().
|
||||
Status(http.StatusNotFound).
|
||||
Body().Contains(`nginx/1.23.1`)
|
||||
Body().Contains(`nginx/`)
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@@ -2,6 +2,8 @@ module github.com/acouvreur/sablier
|
||||
|
||||
go 1.21
|
||||
|
||||
replace github.com/gavv/httpexpect/v2 => github.com/acouvreur/httpexpect/v2 v2.16.0
|
||||
|
||||
require (
|
||||
github.com/docker/docker v24.0.6+incompatible
|
||||
github.com/gavv/httpexpect/v2 v2.15.0
|
||||
|
||||
5
go.sum
5
go.sum
@@ -42,10 +42,15 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
|
||||
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
||||
github.com/acouvreur/httpexpect/v2 v2.16.0/go.mod h1:7myOP3A3VyS4+qnA4cm8DAad8zMN+7zxDB80W9f8yIc=
|
||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
|
||||
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
|
||||
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
|
||||
github.com/avast/retry-go/v4 v4.5.0 h1:QoRAZZ90cj5oni2Lsgl2GW8mNTnUCnmpx/iKpwVisHg=
|
||||
github.com/avast/retry-go/v4 v4.5.0/go.mod h1:7hLEXp0oku2Nir2xBAsg0PTphp9z71bN5Aq1fboC3+I=
|
||||
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
|
||||
github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
|
||||
github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
|
||||
|
||||
@@ -285,6 +285,8 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWso
|
||||
github.com/ThalesIgnite/crypto11 v1.2.5 h1:1IiIIEqYmBvUYFeMnHqRft4bwf/O36jryEUpY+9ef8E=
|
||||
github.com/ThalesIgnite/crypto11 v1.2.5/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE=
|
||||
github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE=
|
||||
github.com/acouvreur/httpexpect/v2 v2.16.0 h1:FGXaR9jt6IQMXxpqbM8YpX7EEvyERU0Lps3ooEc/gk8=
|
||||
github.com/acouvreur/httpexpect/v2 v2.16.0/go.mod h1:7myOP3A3VyS4+qnA4cm8DAad8zMN+7zxDB80W9f8yIc=
|
||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 h1:rFw4nCn9iMW+Vajsk51NtYIcwSTkXr+JGrMd36kTDJw=
|
||||
github.com/alecthomas/chroma/v2 v2.5.0 h1:CQCdj1BiBV17sD4Bd32b/Bzuiq/EqoNTrnIhyQAZ+Rk=
|
||||
github.com/alecthomas/chroma/v2 v2.5.0/go.mod h1:yrkMI9807G1ROx13fhe1v6PN2DDeaR73L3d+1nmYQtw=
|
||||
|
||||
Reference in New Issue
Block a user