diff --git a/.gitignore b/.gitignore index 4d7851fab..55d56c01d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ .DS_Store node_modules Tests/kaas/results/ +Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/results *.tar.gz diff --git a/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/Dockerfile b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/Dockerfile index 2519a36b7..087b24e07 100644 --- a/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/Dockerfile +++ b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17-buster as build +FROM golang:1.23 as build # Install kubectl # Note: Latest version may be found on: diff --git a/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/Makefile b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/Makefile index 2202e9c2f..2892164bb 100644 --- a/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/Makefile +++ b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/Makefile @@ -60,7 +60,7 @@ dev-prerequests: dev-setup: kind-init - kind create cluster --name ${KIND_CLUSTER} + kind create cluster --name ${KIND_CLUSTER} --config kind-config.yaml dev-build: container-init @@ -104,11 +104,29 @@ dev-clean: @rm -rf results || true - dev-purge: kind-init dev-clean @echo "[purge]" kind delete cluster --name ${KIND_CLUSTER} || true docker rmi ${SONOBUOY_IMAGE} || true +dev-rerun: dev-clean dev-build dev-run + @echo "[rerun] Waiting for tests to complete..." + # Poll sonobuoy status until it shows "complete" + while true; do \ + status_output=$$(sonobuoy status); \ + echo "$$status_output"; \ + if echo "$$status_output" | grep -q "complete"; then \ + echo "Tests completed."; \ + break; \ + fi; \ + sleep 5; \ + done + @echo "[rerun] Waiting an additional 10 seconds to ensure results are ready..." + sleep 30 + $(MAKE) dev-result + @echo "[Displaying results...]" + cat results/plugins/scsconformance/sonobuoy_results.yaml + cat results/plugins/scsconformance/results/global/out.json + PHONY: dev-prerequests dev-build dev-run dev-result dev-clean dev-clean dev-purge diff --git a/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/event-ratelimit-config.yaml b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/event-ratelimit-config.yaml new file mode 100644 index 000000000..7dc0513a7 --- /dev/null +++ b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/event-ratelimit-config.yaml @@ -0,0 +1,8 @@ +# event-ratelimit-config.yaml +kind: Configuration +apiVersion: eventratelimit.admission.k8s.io/v1alpha1 +limits: +- burst: 20000 + qps: 5000 + type: Server + diff --git a/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/go.mod b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/go.mod index b1fe960ce..76485b7de 100644 --- a/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/go.mod +++ b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/go.mod @@ -1,10 +1,12 @@ module kaas/kaas-sonobuoy-go-example-2 -go 1.17 +go 1.23 require ( github.com/vmware-tanzu/sonobuoy-plugins/plugin-helper v0.0.0-20211029183731-1d6848b67eec k8s.io/api v0.21.3 + k8s.io/apimachinery v0.21.3 + k8s.io/client-go v0.21.3 sigs.k8s.io/e2e-framework v0.0.4-0.20211103134658-ebed03226136 ) @@ -28,19 +30,17 @@ require ( github.com/sirupsen/logrus v1.7.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/vmware-tanzu/sonobuoy v1.11.5-prerelease.1.0.20211004145628-b633b4fefcdc // indirect - golang.org/x/net v0.23.0 // indirect + golang.org/x/net v0.28.0 // indirect golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/term v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/term v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0 // indirect - k8s.io/apimachinery v0.21.3 // indirect - k8s.io/client-go v0.21.3 // indirect k8s.io/klog/v2 v2.9.0 // indirect k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e // indirect k8s.io/utils v0.0.0-20210527160623-6fdb442a123b // indirect diff --git a/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/go.sum b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/go.sum index 7fed0bb8f..f9d049cca 100644 --- a/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/go.sum +++ b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/go.sum @@ -413,7 +413,6 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= @@ -444,9 +443,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -478,8 +474,6 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -511,14 +505,9 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -533,8 +522,6 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -583,23 +570,14 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= +golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= +golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -607,11 +585,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -659,8 +634,6 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -783,7 +756,6 @@ k8s.io/code-generator v0.21.1/go.mod h1:hUlps5+9QaTrKx+jiM4rmq7YmH8wPOIko64uZCHD k8s.io/component-base v0.21.1/go.mod h1:NgzFZ2qu4m1juby4TnrmpR8adRk6ka62YdH5DkIIyKA= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= -k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= diff --git a/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/kind-config.yaml b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/kind-config.yaml new file mode 100644 index 000000000..fc1e05269 --- /dev/null +++ b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/kind-config.yaml @@ -0,0 +1,19 @@ +# kind-config.yaml +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +kubeadmConfigPatches: +- | + apiVersion: kubeadm.k8s.io/v1beta2 + kind: ClusterConfiguration + apiServer: + extraArgs: + enable-admission-plugins: EventRateLimit + admission-control-config-file: /etc/kubernetes/admission-control-config.yaml + feature-gates": APIPriorityAndFairness=true +nodes: +- role: control-plane + extraMounts: + - hostPath: ./event-ratelimit-config.yaml + containerPath: /etc/kubernetes/admission-control-config.yaml +- role: worker +- role: worker \ No newline at end of file diff --git a/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/scs_k8s_tests/scs_0215_v1_robustness_features_test.go b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/scs_k8s_tests/scs_0215_v1_robustness_features_test.go new file mode 100644 index 000000000..5976423c6 --- /dev/null +++ b/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/scs_k8s_tests/scs_0215_v1_robustness_features_test.go @@ -0,0 +1,322 @@ +package scs_k8s_tests + +import ( + "context" + "fmt" + "log" + "os" + "strconv" + "sync" + "testing" + "time" + + v1 "k8s.io/api/core/v1" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +) + +// getClusterSize estimates the cluster size by counting the number of nodes. +func getClusterSize(clientset *kubernetes.Clientset) int { + nodes, err := clientset.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{}) + if err != nil { + log.Fatalf("Failed to list nodes: %v", err) + } + return len(nodes.Items) +} + +// runConcurrentRequests sends concurrent API requests and returns the number of errors encountered. +func runConcurrentRequests(clientset *kubernetes.Clientset, maxRequestsInflight int) int { + var wg sync.WaitGroup + errChan := make(chan error, maxRequestsInflight) + + for i := 0; i < maxRequestsInflight; i++ { + wg.Add(1) + go func() { + defer wg.Done() + ctx, cancel := context.WithTimeout(context.TODO(), 2*time.Second) + defer cancel() + _, err := clientset.CoreV1().Pods("").List(ctx, metav1.ListOptions{}) + if err != nil { + errChan <- err + } + }() + } + + wg.Wait() + close(errChan) + return len(errChan) // Return the number of errors encountered +} + +// testPositiveCase handles the positive scenario where requests should succeed. +func testPositiveCase(t *testing.T, clientset *kubernetes.Clientset, maxRequestsInflight int) { + fmt.Println("Running Positive Test Case") + // Reduce the load even further for the positive test (e.g., 25% of maxRequestsInflight) + safeRequests := maxRequestsInflight / 4 + errors := runConcurrentRequests(clientset, safeRequests) + if errors > 0 { + t.Errorf("Test failed: encountered %d unexpected errors when requests were expected to succeed.", errors) + } else { + fmt.Println("Positive test case passed successfully!") + } +} + +// testNegativeCase handles the negative scenario where requests should be throttled. +func testNegativeCase(t *testing.T, clientset *kubernetes.Clientset, maxRequestsInflight int) { + fmt.Println("Running Negative Test Case") + // Increase the load significantly above the maxRequestsInflight to trigger rate limiting + overloadRequests := maxRequestsInflight * 2 + errors := runConcurrentRequests(clientset, overloadRequests) + + // Expect at least some errors due to rate limiting + if errors == 0 { + t.Errorf("Test failed: expected rate limit errors, but all requests succeeded.") + } else { + fmt.Println("Negative test case passed as expected: rate limit exceeded.") + } +} + +// Test_scs_maxRequestInflight is the main entry point that runs both positive and negative test cases. +func Test_scs_0215_maxRequestInflight(t *testing.T) { + // Load in-cluster configuration + config, err := rest.InClusterConfig() + if err != nil { + log.Fatalf("Failed to load in-cluster config: %v", err) + } + + // Adjust client rate limits + config.QPS = 10000 // Matches server-side QPS + config.Burst = 40000 // Matches server-side Burst + + // Create the clientset from the config + clientset, err := kubernetes.NewForConfig(config) + if err != nil { + log.Fatalf("Failed to create Kubernetes clientset: %v", err) + } + + // Increase timeout to allow more time for requests to complete + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + // Example of using the clientset to list pods + _, err = clientset.CoreV1().Pods("").List(ctx, metav1.ListOptions{}) + if err != nil { + if isRateLimitError(err) { + log.Printf("Rate limit error: %v", err) + } else { + log.Printf("Unexpected error: %v", err) // Log unexpected errors with details + } + } + + // Get cluster size (number of nodes) + clusterSize := getClusterSize(clientset) + fmt.Printf("Detected cluster size: %d nodes\n", clusterSize) + + // Determine maxRequestsInflight based on cluster size and environment variable + maxRequestsInflightStr := os.Getenv("MAX_REQUESTS_INFLIGHT") + maxRequestsInflight, err := strconv.Atoi(maxRequestsInflightStr) + if err != nil || maxRequestsInflight <= 0 { + maxRequestsInflight = clusterSize * 250 // Example scaling logic: 100 requests per node + } + + fmt.Printf("Using maxRequestsInflight = %d\n", maxRequestsInflight) + + // Run the positive test case + t.Run("Positive Test Case", func(t *testing.T) { + testPositiveCase(t, clientset, maxRequestsInflight) + }) + + // Run the negative test case + t.Run("Negative Test Case", func(t *testing.T) { + testNegativeCase(t, clientset, maxRequestsInflight) + }) +} + +// Main test function for max-mutating-requests-inflight +func Test_scs_maxMutatingRequestsInflight(t *testing.T) { + // Load in-cluster configuration + config, err := rest.InClusterConfig() + if err != nil { + log.Fatalf("Failed to load in-cluster config: %v", err) + } + + // Set higher QPS and burst limits to avoid client-side throttling + config.QPS = 100 + config.Burst = 200 + + clientset, err := kubernetes.NewForConfig(config) + if err != nil { + log.Fatalf("Failed to create Kubernetes client: %v", err) + } + + clusterSize := detectClusterSize() // Detects the cluster size + maxMutatingRequestsInflight := calculateMaxMutatingRequestsInflight(clusterSize) + fmt.Printf("Detected cluster size: %d nodes\n", clusterSize) + fmt.Printf("Using maxMutatingRequestsInflight = %d\n", maxMutatingRequestsInflight) + + // Positive Test Case: Requests within the allowed limit + t.Run("Positive_Test_Case", func(t *testing.T) { + fmt.Println("Running Positive Test Case") + err := runMutatingTest(clientset, maxMutatingRequestsInflight) // Pass clientset here + if err != nil { + t.Fatalf("Test failed: encountered unexpected errors when requests were expected to succeed: %v", err) + } + fmt.Println("Positive test case passed successfully!") + }) + + // Negative Test Case: Exceeding the allowed limit + t.Run("Negative_Test_Case", func(t *testing.T) { + fmt.Println("Running Negative Test Case") + err := runMutatingTest(clientset, maxMutatingRequestsInflight + 10) // Pass clientset here and exceed limit + if err != nil && isRateLimitError(err) { + fmt.Println("Negative test case passed as expected: rate limit exceeded.") + } else { + t.Fatalf("Test failed: expected rate limit errors, but requests succeeded or another error occurred: %v", err) + } + }) +} + + +// Function to detect the size of the cluster (stubbed, adjust as needed) +func detectClusterSize() int { + // Logic to detect cluster size (for example using kubectl) + return 1 // Default for single-node kind cluster +} + +// Function to calculate max-mutating-requests-inflight based on cluster size +func calculateMaxMutatingRequestsInflight(clusterSize int) int { + // Adjust this formula based on your requirements + return 100 * clusterSize // Example: 100 mutating requests per node +} + +// Function to simulate sending mutating requests up to the given limit +func runMutatingTest(clientset *kubernetes.Clientset, limit int) error { + var wg sync.WaitGroup + errChan := make(chan error, limit) + + for i := 0; i < limit; i++ { + wg.Add(1) + go func(i int) { + defer wg.Done() + ctx, cancel := context.WithTimeout(context.TODO(), 20*time.Second) + defer cancel() + + // Create a unique Pod name + podName := fmt.Sprintf("test-pod-%d", i) + + // Create a Pod + _, err := clientset.CoreV1().Pods("default").Create(ctx, &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: podName, + }, + Spec: v1.PodSpec{ + Containers: []v1.Container{ + { + Name: "test-container", + Image: "busybox", + }, + }, + }, + }, metav1.CreateOptions{}) + + if err != nil { + if isRateLimitError(err) { + errChan <- fmt.Errorf("rate limit reached") + } else { + errChan <- fmt.Errorf("error creating pod: %v", err) + } + return + } + + // Clean up by deleting the Pod + err = clientset.CoreV1().Pods("default").Delete(ctx, podName, metav1.DeleteOptions{}) + if err != nil { + if isRateLimitError(err) { + errChan <- fmt.Errorf("rate limit reached") + } else { + errChan <- fmt.Errorf("error deleting pod: %v", err) + } + return + } + }(i) + } + + wg.Wait() + close(errChan) + + var rateLimitErrors, otherErrors int + for err := range errChan { + if err.Error() == "rate limit reached" { + rateLimitErrors++ + } else { + otherErrors++ + } + } + + if otherErrors > 0 { + return fmt.Errorf("encountered %d unexpected errors", otherErrors) + } + + if rateLimitErrors > 0 { + fmt.Printf("Rate limit errors encountered: %d\n", rateLimitErrors) + } + + return nil +} + +// Function to determine if an error is related to rate limiting +func isRateLimitError(err error) bool { + if err == nil { + return false + } + return err.Error() == "TooManyRequests" || err.Error() == "429" +} + +// Main test function for min-request-timeout +func Test_scs_minRequestTimeout(t *testing.T) { + // Load in-cluster configuration + config, err := rest.InClusterConfig() + if err != nil { + log.Fatalf("Failed to load in-cluster config: %v", err) + } + + // Set QPS and Burst to higher values to avoid throttling + config.QPS = 100 + config.Burst = 200 + + // Create a Kubernetes client + clientset, err := kubernetes.NewForConfig(config) + if err != nil { + log.Fatalf("Failed to create Kubernetes client: %v", err) + } + + // Test case: min-request-timeout enforced (timeout set to 5 seconds) + t.Run("Test_minRequestTimeout", func(t *testing.T) { + minRequestTimeout := 5 * time.Second + fmt.Printf("Testing with min-request-timeout = %v\n", minRequestTimeout) + + ctx, cancel := context.WithTimeout(context.Background(), minRequestTimeout) + defer cancel() + + // Send a request to the Kubernetes API (List Pods in a namespace) + _, err := clientset.CoreV1().Pods("default").List(ctx, metav1.ListOptions{}) + + // Check if the request failed due to timeout + if err != nil && isTimeoutError(err) { + fmt.Printf("Request failed as expected due to timeout: %v\n", err) + } else if err != nil { + t.Fatalf("Test failed: unexpected error occurred: %v\n", err) + } else { + t.Fatalf("Test failed: request succeeded but was expected to timeout") + } + }) +} + +// Helper function to check if an error is a timeout error +func isTimeoutError(err error) bool { + if err == nil { + return false + } + return err.Error() == "context deadline exceeded" +} \ No newline at end of file