Skip to content

Commit

Permalink
add e2e for http
Browse files Browse the repository at this point in the history
Signed-off-by: ii2day <ji.li@daocloud.io>
  • Loading branch information
ii2day committed Jul 13, 2023
1 parent 54abc3f commit 5b0d291
Show file tree
Hide file tree
Showing 304 changed files with 38,896 additions and 53 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ e2e_init:
make -C test deploy_metallb
make -C test deploy_contour
make -C test deploy_project
make -C test install_apiserver_token




Expand Down
11 changes: 10 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ require (
k8s.io/kube-openapi v0.0.0-20221110221610-a28e98eb7c70 // indirect
)

require k8s.io/apiserver v0.26.3
require (
github.com/docker/docker v24.0.4+incompatible
k8s.io/apiserver v0.26.3
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
Expand All @@ -76,6 +80,8 @@ require (
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
Expand Down Expand Up @@ -122,8 +128,11 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/petermattis/goid v0.0.0-20221018141743-354ef7f2fd21 // indirect
Expand Down
19 changes: 18 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
Expand All @@ -47,6 +48,8 @@ github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7Y
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
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/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
Expand Down Expand Up @@ -99,6 +102,12 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v24.0.4+incompatible h1:s/LVDftw9hjblvqIeTiGYXBCD95nOEEl7qRsRrIOuQI=
github.com/docker/docker v24.0.4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
Expand Down Expand Up @@ -401,6 +410,7 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae h1:O4SWKdcHVCvYqyDV+9CJA1fcDN2L11Bule0iFy3YlAI=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand All @@ -411,6 +421,8 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
Expand All @@ -424,6 +436,10 @@ github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU
github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM=
github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc=
github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
Expand Down Expand Up @@ -487,7 +503,7 @@ github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk=
Expand Down Expand Up @@ -1018,6 +1034,7 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
11 changes: 6 additions & 5 deletions pkg/agentHttpServer/appHttpServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (s *echoPutHandler) Handle(r echo.PutParams) middleware.Responder {
}
head[k] = t
}
atomic.AddInt64(&requestCounts, 1)
t := echo.NewPutOK()
t.Payload = &models.EchoRes{
ClientIP: r.HTTPRequest.RemoteAddr,
Expand All @@ -122,7 +123,6 @@ func (s *echoPutHandler) Handle(r echo.PutParams) middleware.Responder {
time.Sleep(time.Duration(*r.Delay) * time.Second)
t.Payload.RequestParam = fmt.Sprintf("delay=%d", *r.Delay)
}

return t
}

Expand All @@ -149,6 +149,7 @@ func (s *echoPostHandler) Handle(r echo.PostParams) middleware.Responder {
}
head[k] = t
}
atomic.AddInt64(&requestCounts, 1)
t := echo.NewPostOK()
t.Payload = &models.EchoRes{
ClientIP: r.HTTPRequest.RemoteAddr,
Expand All @@ -163,7 +164,6 @@ func (s *echoPostHandler) Handle(r echo.PostParams) middleware.Responder {

body, _ := r.TestArgs.MarshalBinary()
t.Payload.RequestBody = string(body)

if r.Delay != nil {
time.Sleep(time.Duration(*r.Delay) * time.Second)
t.Payload.RequestParam = fmt.Sprintf("delay=%d", *r.Delay)
Expand All @@ -179,7 +179,7 @@ type echoHeadHandler struct {
}

func (s *echoHeadHandler) Handle(r echo.HeadParams) middleware.Responder {

atomic.AddInt64(&requestCounts, 1)
return echo.NewHeadOK()
}

Expand Down Expand Up @@ -284,6 +284,7 @@ func (s *echoKdoctorPutHandler) Handle(r echo.PutKdoctoragentParams) middleware.
}
head[k] = t
}
atomic.AddInt64(&requestCounts, 1)
t := echo.NewPutKdoctoragentOK()
t.Payload = &models.EchoRes{
ClientIP: r.HTTPRequest.RemoteAddr,
Expand Down Expand Up @@ -326,6 +327,7 @@ func (s *echoKdoctorPostHandler) Handle(r echo.PostKdoctoragentParams) middlewar
}
head[k] = t
}
atomic.AddInt64(&requestCounts, 1)
t := echo.NewPostKdoctoragentOK()
t.Payload = &models.EchoRes{
ClientIP: r.HTTPRequest.RemoteAddr,
Expand All @@ -340,7 +342,6 @@ func (s *echoKdoctorPostHandler) Handle(r echo.PostKdoctoragentParams) middlewar

body, _ := r.TestArgs.MarshalBinary()
t.Payload.RequestBody = string(body)

if r.Delay != nil {
time.Sleep(time.Duration(*r.Delay) * time.Second)
t.Payload.RequestParam = fmt.Sprintf("delay=%d", *r.Delay)
Expand All @@ -356,7 +357,7 @@ type echoKdoctorHeadHandler struct {
}

func (s *echoKdoctorHeadHandler) Handle(r echo.HeadKdoctoragentParams) middleware.Responder {

atomic.AddInt64(&requestCounts, 1)
return echo.NewHeadKdoctoragentOK()
}

Expand Down
13 changes: 13 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ deploy_project:
HELM_OPTION+=" --set kdoctorAgent.ingress.enable=false " ; \
fi ; \
HELM_OPTION+=" --set feature.aggregateReport.enabled=true " ; \
HELM_OPTION+=" --set feature.nethttp_defaultConcurrency=10 " ; \
HELM_OPTION+=" --set feature.aggregateReport.controller.reportHostPath=/var/run/kdoctor/controller " ; \
HELM_OPTION+=" --set kdoctorAgent.debug.logLevel=debug --set kdoctorController.debug.logLevel=debug " ; \
HELM_OPTION+=" --set kdoctorAgent.prometheus.enabled=true --set kdoctorController.prometheus.enabled=true " ; \
Expand Down Expand Up @@ -511,6 +512,14 @@ install_nginx:

#==========================

.PHONY: install_apiserver_token
install_apiserver_token: KIND_KUBECONFIG ?= $(E2E_KIND_KUBECONFIG_PATH)
install_apiserver_token: KIND_CLUSTER_NAME ?= $(E2E_KIND_CLUSTER_NAME)
install_apiserver_token:
@echo "---------- install apiserver token"
sed 's?<<TEST_NAMESPACE>>?$(E2E_INSTALL_NAMESPACE)?' yaml/kdoctortoken.yaml | kubectl --kubeconfig=$(KIND_KUBECONFIG) apply -f -


.PHONY: clean
clean:
-@ kind delete cluster --name $(E2E_KIND_CLUSTER_NAME)
Expand All @@ -534,6 +543,10 @@ e2e_test:
echo "find cluster node: $${NODE_LIST}" ; \
export E2E_KIND_CLUSTER_NODE_LIST="$${NODE_LIST}" ; \
export E2E_CLUSTER_NAME=$(KIND_CLUSTER_NAME) ; \
export APISERVER=`kubectl config view --kubeconfig $(KIND_KUBECONFIG) |grep server | awk '{print $$2}'` ;\
export E2E_INSTALL_NAMESPACE=$(E2E_INSTALL_NAMESPACE) ;\
export GIT_COMMIT_VERSION=$(GIT_COMMIT_VERSION) ;\
export AGENT_REGISTER=$(REGISTER)/$(GIT_REPO)-agent ; \
if [ "$(E2E_IP_FAMILY)" == "ipv4" ] ; then \
export E2E_IPV4_ENABLED=true ; export E2E_IPV6_ENABLED=false ; \
elif [ "$(E2E_IP_FAMILY)" == "ipv6" ] ; then \
Expand Down
18 changes: 18 additions & 0 deletions test/docs/AppHttpHealth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# E2E Cases for AppHttpHealth

| Case ID | Title | Priority | Smoke | Status | Other |
|---------|-----------------------------------------------------------------------------|----------|-------|--------|-------------|
| A00001 | Successfully http testing appHttpHealth method GET case | p1 | | done | |
| A00002 | Failed http testing appHttpHealth due to status code case | p1 | | done | |
| A00003 | Failed http testing appHttpHealth due to delay case | p1 | | done | |
| A00004 | Successfully https testing appHttpHealth method GET case | p1 | | done | |
| A00005 | Failed https testing appHttpHealth due to tls case | p1 | | done | |
| A00006 | Successfully http testing appHttpHealth method PUT case | p1 | | done | |
| A00007 | Successfully http testing appHttpHealth method POST With Body case | p1 | | done | |
| A00008 | Successfully http testing appHttpHealth method HEAD case | p1 | | done | |
| A00009 | Successfully http testing appHttpHealth method PATCH case | p1 | | done | |
| A000010 | Successfully http testing appHttpHealth method OPTIONS case | p1 | | done | |
| A000011 | After QPS is specified, the number of requests meets the requirements case | p1 | | done | |
| A000012 | Successfully http testing appHttpHealth due to success rate case | p1 | | done | |
| A000013 | Successfully https testing appHttpHealth method GET Protocol Http2 case | p1 | | done | |
| A000014 | Report request count equal real request count case | p1 | | done | |
6 changes: 6 additions & 0 deletions test/docs/NetReach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# E2E Cases for IP NetReach

| Case ID | Title | Priority | Smoke | Status | Other |
|---------|--------------------------------------------------------|----------|-------|--------|-------------|
| B00001 | Successfully testing netReach case | p1 | | done | |

9 changes: 9 additions & 0 deletions test/docs/schedule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# E2E Cases for IP schedule

| Case ID | Title | Priority | Smoke | Status | Other |
|---------|-------------------------------------------------|----------|-------|--------|-------------|
| C00001 | Successfully testing NetReach crontab case | p1 | | done | |
| C00002 | Successfully testing AppHttpHealth crontab case | p1 | | done | |
| C00003 | Successfully testing NetReach sample case | p1 | | done | |
| C00004 | Successfully testing AppHttpHealth sample case | p1 | | done | |

67 changes: 67 additions & 0 deletions test/e2e/apphttphealth/apphttphealth_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2023 Authors of kdoctor-io
// SPDX-License-Identifier: Apache-2.0

package apphttphealth_test

import (
"context"
kdoctor_v1beta1 "github.com/kdoctor-io/kdoctor/pkg/k8s/apis/kdoctor.io/v1beta1"
"github.com/kdoctor-io/kdoctor/test/e2e/common"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
e2e "github.com/spidernet-io/e2eframework/framework"
"github.com/spidernet-io/e2eframework/tools"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"testing"
)

func TestNetReach(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "AppHttpHealth Suite")
}

var frame *e2e.Framework

var httpPort = 80
var httpsPort = 443
var bodyConfigMapName string
var caSecret *v1.Secret
var reportNum int

var _ = BeforeSuite(func() {
defer GinkgoRecover()
var e error
frame, e = e2e.NewFramework(GinkgoT(), []func(*runtime.Scheme) error{kdoctor_v1beta1.AddToScheme})
Expect(e).NotTo(HaveOccurred())

// test request body
bodyConfigMapName = "kdoctor-test-body-" + tools.RandomName()
cm := new(v1.ConfigMap)
cm.SetName(bodyConfigMapName)
cm.SetNamespace(common.TestNameSpace)
body := make(map[string]string, 0)
body["test1"] = "test1"
body["test2"] = "test2"
cm.Data = body
e = frame.CreateConfigmap(cm)
Expect(e).NotTo(HaveOccurred(), "create test body configmap")

caSecret = new(v1.Secret)
key := types.NamespacedName{
Name: common.KDoctorCaName,
Namespace: common.TestNameSpace,
}
e = frame.KClient.Get(context.Background(), key, caSecret)
Expect(e).NotTo(HaveOccurred(), "get kdoctor ca secret")

ds, e := frame.GetDaemonSet(common.KDoctorAgentDSName, common.TestNameSpace)
Expect(e).NotTo(HaveOccurred(), "get kdoctor-agent daemonset")
reportNum = int(ds.Status.NumberReady)
})

var _ = AfterSuite(func() {
defer GinkgoRecover()
_ = frame.DeleteConfigmap(bodyConfigMapName, common.TestNameSpace)
})
Loading

0 comments on commit 5b0d291

Please sign in to comment.