diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 348bc83..eb69b5e 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -72,4 +72,10 @@ jobs: KUBECONFIG: /home/runner/.kube/hub-kubeconfig MANAGED_CLUSTER_NAME: spoke MANAGED_KUBECONFIG: /home/runner/.kube/spoke-internal-kubeconfig - EXTERNAL_MANAGED_KUBECONFIG: /home/runner/.kube/spoke-internal-kubeconfig + EXTERNAL_MANAGED_KUBECONFIG: /home/runner/.kube/spoke-internal-kubeconfig + - name: Run e2e + run: | + make test-e2e + env: + KUBECONFIG: /home/runner/.kube/hub-kubeconfig + MANAGED_CLUSTER_NAME: spoke diff --git a/.gitignore b/.gitignore index e798ff3..147a0e2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ e2e.test .vscode *.tgz +vendor diff --git a/Makefile b/Makefile index a75d930..af34fe6 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,10 @@ e2e-install: e2e-import-cluster: hack/e2e-import-cluster.sh +test-e2e: + go test -c ./test/e2e + ./e2e.test -test.v -ginkgo.v + ensure-helm: ifeq "" "$(wildcard $(HELM))" $(info Installing helm into '$(HELM)') diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..8ff45d9 --- /dev/null +++ b/go.mod @@ -0,0 +1,58 @@ +module github.com/stolostron/mce-install-kube + +go 1.23.0 + +require ( + github.com/onsi/ginkgo/v2 v2.21.0 + github.com/onsi/gomega v1.35.1 + k8s.io/apiextensions-apiserver v0.31.2 + k8s.io/apimachinery v0.31.2 + k8s.io/client-go v0.31.2 + open-cluster-management.io/api v0.15.0 + sigs.k8s.io/controller-runtime v0.19.1 +) + +require ( + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/fxamacker/cbor/v2 v2.7.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/swag v0.22.4 // indirect + github.com/go-task/slim-sprig/v3 v3.0.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/gnostic-models v0.6.8 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/imdario/mergo v0.3.6 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/x448/float16 v0.8.4 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/oauth2 v0.21.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/term v0.25.0 // indirect + golang.org/x/text v0.19.0 // indirect + golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.26.0 // indirect + google.golang.org/protobuf v1.35.1 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/api v0.31.2 // indirect + k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect + k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect + sigs.k8s.io/yaml v1.4.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..d2172a4 --- /dev/null +++ b/go.sum @@ -0,0 +1,173 @@ +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= +github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= +github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= +github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= +github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= +github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= +github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= +github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +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= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +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/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM= +github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= +github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= +github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +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/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +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/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= +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= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= +gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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= +k8s.io/api v0.31.2 h1:3wLBbL5Uom/8Zy98GRPXpJ254nEFpl+hwndmk9RwmL0= +k8s.io/api v0.31.2/go.mod h1:bWmGvrGPssSK1ljmLzd3pwCQ9MgoTsRCuK35u6SygUk= +k8s.io/apiextensions-apiserver v0.31.2 h1:W8EwUb8+WXBLu56ser5IudT2cOho0gAKeTOnywBLxd0= +k8s.io/apiextensions-apiserver v0.31.2/go.mod h1:i+Geh+nGCJEGiCGR3MlBDkS7koHIIKWVfWeRFiOsUcM= +k8s.io/apimachinery v0.31.2 h1:i4vUt2hPK56W6mlT7Ry+AO8eEsyxMD1U44NR22CLTYw= +k8s.io/apimachinery v0.31.2/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/client-go v0.31.2 h1:Y2F4dxU5d3AQj+ybwSMqQnpZH9F30//1ObxOKlTI9yc= +k8s.io/client-go v0.31.2/go.mod h1:NPa74jSVR/+eez2dFsEIHNa+3o09vtNaWwWwb1qSxSs= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= +k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= +k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= +k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +open-cluster-management.io/api v0.15.0 h1:lRee1KOlGHZb2scTA7ff9E9Fxt2hJc7jpkHnaCbvkOU= +open-cluster-management.io/api v0.15.0/go.mod h1:9erZEWEn4bEqh0nIX2wA7f/s3KCuFycQdBrPrRzi0QM= +sigs.k8s.io/controller-runtime v0.19.1 h1:Son+Q40+Be3QWb+niBXAg2vFiYWolDjjRfO8hn/cxOk= +sigs.k8s.io/controller-runtime v0.19.1/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/hack/e2e-install.sh b/hack/e2e-install.sh index e4c7790..68cf57c 100755 --- a/hack/e2e-install.sh +++ b/hack/e2e-install.sh @@ -45,10 +45,10 @@ echo "#### Install MCE on Hub cluster ####" make ensure-helm # install released mce -# helm install mce ./e2e/mce-chart --set-file images.imageCredentials.dockerConfigJson=pullsecret.json +# helm install mce ./hack/mce-chart --set-file images.imageCredentials.dockerConfigJson=pullsecret.json # install upstream mce -$HELM install mce ./e2e/mce-chart -f ./e2e/configuration/mce-values.yaml +$HELM install mce ./hack/mce-chart -f ./test/configuration/mce-values.yaml echo "" @@ -68,7 +68,7 @@ waitForReady "kubectl get crds | grep -c \"klusterletconfigs\"" 1 echo "" echo "###### Create global klusterletconfig ######" -kubectl apply -f ./e2e/configuration/klusterletconfig.yaml +kubectl apply -f ./test/configuration/klusterletconfig.yaml echo "" echo "###### Wait unitl local-cluster is created ######" @@ -91,7 +91,7 @@ kubectl apply -f ./configuration/workmanagercma.yaml echo "" echo "#### Install Policy addons #####" make ensure-helm -$HELM install policy ./policy -f ./e2e/configuration/policy-values.yaml +$HELM install policy ./policy -f ./test/configuration/policy-values.yaml echo "" diff --git a/e2e/mce-chart/.helmignore b/hack/mce-chart/.helmignore similarity index 100% rename from e2e/mce-chart/.helmignore rename to hack/mce-chart/.helmignore diff --git a/e2e/mce-chart/Chart.yaml b/hack/mce-chart/Chart.yaml similarity index 100% rename from e2e/mce-chart/Chart.yaml rename to hack/mce-chart/Chart.yaml diff --git a/e2e/mce-chart/crds/multicluster.openshift.io_multiclusterengines.yaml b/hack/mce-chart/crds/multicluster.openshift.io_multiclusterengines.yaml similarity index 100% rename from e2e/mce-chart/crds/multicluster.openshift.io_multiclusterengines.yaml rename to hack/mce-chart/crds/multicluster.openshift.io_multiclusterengines.yaml diff --git a/e2e/mce-chart/templates/_helpers.tpl b/hack/mce-chart/templates/_helpers.tpl similarity index 100% rename from e2e/mce-chart/templates/_helpers.tpl rename to hack/mce-chart/templates/_helpers.tpl diff --git a/e2e/mce-chart/templates/clusterrole.yaml b/hack/mce-chart/templates/clusterrole.yaml similarity index 100% rename from e2e/mce-chart/templates/clusterrole.yaml rename to hack/mce-chart/templates/clusterrole.yaml diff --git a/e2e/mce-chart/templates/clusterrolebinding.yaml b/hack/mce-chart/templates/clusterrolebinding.yaml similarity index 100% rename from e2e/mce-chart/templates/clusterrolebinding.yaml rename to hack/mce-chart/templates/clusterrolebinding.yaml diff --git a/e2e/mce-chart/templates/deployment.yaml b/hack/mce-chart/templates/deployment.yaml similarity index 100% rename from e2e/mce-chart/templates/deployment.yaml rename to hack/mce-chart/templates/deployment.yaml diff --git a/e2e/mce-chart/templates/image-pull-secret.yaml b/hack/mce-chart/templates/image-pull-secret.yaml similarity index 100% rename from e2e/mce-chart/templates/image-pull-secret.yaml rename to hack/mce-chart/templates/image-pull-secret.yaml diff --git a/e2e/mce-chart/templates/multiclusterengine.yaml b/hack/mce-chart/templates/multiclusterengine.yaml similarity index 100% rename from e2e/mce-chart/templates/multiclusterengine.yaml rename to hack/mce-chart/templates/multiclusterengine.yaml diff --git a/e2e/mce-chart/templates/namespace.yaml b/hack/mce-chart/templates/namespace.yaml similarity index 100% rename from e2e/mce-chart/templates/namespace.yaml rename to hack/mce-chart/templates/namespace.yaml diff --git a/e2e/mce-chart/templates/service.yaml b/hack/mce-chart/templates/service.yaml similarity index 100% rename from e2e/mce-chart/templates/service.yaml rename to hack/mce-chart/templates/service.yaml diff --git a/e2e/mce-chart/templates/serviceaccount.yaml b/hack/mce-chart/templates/serviceaccount.yaml similarity index 100% rename from e2e/mce-chart/templates/serviceaccount.yaml rename to hack/mce-chart/templates/serviceaccount.yaml diff --git a/e2e/mce-chart/templates/webhook-cert-secret.yaml b/hack/mce-chart/templates/webhook-cert-secret.yaml similarity index 100% rename from e2e/mce-chart/templates/webhook-cert-secret.yaml rename to hack/mce-chart/templates/webhook-cert-secret.yaml diff --git a/e2e/mce-chart/values.yaml b/hack/mce-chart/values.yaml similarity index 100% rename from e2e/mce-chart/values.yaml rename to hack/mce-chart/values.yaml diff --git a/e2e/mce-olm/olm/catalogsource.yaml b/hack/mce-olm/olm/catalogsource.yaml similarity index 100% rename from e2e/mce-olm/olm/catalogsource.yaml rename to hack/mce-olm/olm/catalogsource.yaml diff --git a/e2e/mce-olm/olm/kustomization.yaml b/hack/mce-olm/olm/kustomization.yaml similarity index 100% rename from e2e/mce-olm/olm/kustomization.yaml rename to hack/mce-olm/olm/kustomization.yaml diff --git a/e2e/mce-olm/olm/operatorgroup.yaml b/hack/mce-olm/olm/operatorgroup.yaml similarity index 100% rename from e2e/mce-olm/olm/operatorgroup.yaml rename to hack/mce-olm/olm/operatorgroup.yaml diff --git a/e2e/mce-olm/olm/subscription.yaml b/hack/mce-olm/olm/subscription.yaml similarity index 100% rename from e2e/mce-olm/olm/subscription.yaml rename to hack/mce-olm/olm/subscription.yaml diff --git a/e2e/mce-olm/prerequisites/image-pull-secret.yaml b/hack/mce-olm/prerequisites/image-pull-secret.yaml similarity index 100% rename from e2e/mce-olm/prerequisites/image-pull-secret.yaml rename to hack/mce-olm/prerequisites/image-pull-secret.yaml diff --git a/e2e/mce-olm/prerequisites/kustomization.yaml b/hack/mce-olm/prerequisites/kustomization.yaml similarity index 100% rename from e2e/mce-olm/prerequisites/kustomization.yaml rename to hack/mce-olm/prerequisites/kustomization.yaml diff --git a/e2e/mce-olm/prerequisites/namespace.yaml b/hack/mce-olm/prerequisites/namespace.yaml similarity index 100% rename from e2e/mce-olm/prerequisites/namespace.yaml rename to hack/mce-olm/prerequisites/namespace.yaml diff --git a/e2e/mce-olm/prerequisites/webhook-cert-secret.yaml b/hack/mce-olm/prerequisites/webhook-cert-secret.yaml similarity index 100% rename from e2e/mce-olm/prerequisites/webhook-cert-secret.yaml rename to hack/mce-olm/prerequisites/webhook-cert-secret.yaml diff --git a/e2e/configuration/cluster.yaml b/test/configuration/cluster.yaml similarity index 100% rename from e2e/configuration/cluster.yaml rename to test/configuration/cluster.yaml diff --git a/e2e/configuration/klusterletconfig.yaml b/test/configuration/klusterletconfig.yaml similarity index 100% rename from e2e/configuration/klusterletconfig.yaml rename to test/configuration/klusterletconfig.yaml diff --git a/e2e/configuration/mce-values.yaml b/test/configuration/mce-values.yaml similarity index 78% rename from e2e/configuration/mce-values.yaml rename to test/configuration/mce-values.yaml index 303dae8..09ab3dd 100644 --- a/e2e/configuration/mce-values.yaml +++ b/test/configuration/mce-values.yaml @@ -4,16 +4,16 @@ availabilityConfig: Basic images: overrides: - backplane_operator: "quay.io/stolostron/backplane-operator:2.7.0-BACKPLANE-2024-09-30-05-39-18" - registration_operator: "quay.io/stolostron/registration-operator:2.7.0-BACKPLANE-2024-09-30-05-39-18" - hypershift_addon_operator: "quay.io/stolostron/hypershift-addon-operator:2.7.0-BACKPLANE-2024-09-30-05-39-18" - managedcluster_import_controller: "quay.io/stolostron/managedcluster-import-controller:2.7.0-BACKPLANE-2024-09-30-05-39-18" - multicloud_manager: "quay.io/stolostron/multicloud-manager:2.7.0-BACKPLANE-2024-09-30-05-39-18" - addon_manager: "quay.io/stolostron/addon-manager:2.7.0-BACKPLANE-2024-09-30-05-39-18" - work: "quay.io/stolostron/work:2.7.0-BACKPLANE-2024-09-30-05-39-18" - registration: "quay.io/stolostron/registration:2.7.0-BACKPLANE-2024-09-30-05-39-18" - placement: "quay.io/stolostron/placement:2.7.0-BACKPLANE-2024-09-30-05-39-18" - kube_rbac_proxy_mce: "quay.io/stolostron/kube-rbac-proxy-mce:2.7.0-BACKPLANE-2024-09-30-05-39-18" + backplane_operator: "quay.io/stolostron/backplane-operator:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + registration_operator: "quay.io/stolostron/registration-operator:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + hypershift_addon_operator: "quay.io/stolostron/hypershift-addon-operator:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + managedcluster_import_controller: "quay.io/stolostron/managedcluster-import-controller:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + multicloud_manager: "quay.io/stolostron/multicloud-manager:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + addon_manager: "quay.io/stolostron/addon-manager:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + work: "quay.io/stolostron/work:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + registration: "quay.io/stolostron/registration:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + placement: "quay.io/stolostron/placement:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + kube_rbac_proxy_mce: "quay.io/stolostron/kube-rbac-proxy-mce:2.13.0-SNAPSHOT-2024-11-20-23-56-00" #images in MCE 2.6.2 diff --git a/e2e/configuration/multiclusterengine.yaml b/test/configuration/multiclusterengine.yaml similarity index 100% rename from e2e/configuration/multiclusterengine.yaml rename to test/configuration/multiclusterengine.yaml diff --git a/e2e/configuration/policy-values.yaml b/test/configuration/policy-values.yaml similarity index 66% rename from e2e/configuration/policy-values.yaml rename to test/configuration/policy-values.yaml index 3c303bd..e75a639 100644 --- a/e2e/configuration/policy-values.yaml +++ b/test/configuration/policy-values.yaml @@ -1,14 +1,14 @@ global: - registryOverride: "quay.io" + registryOverride: "quay.io/stolostron" # registry for ACM 2.11.2 # registryOverride: "registry.redhat.io" imageOverrides: # upstream images - governance_policy_propagator: "stolostron/governance-policy-propagator:2.12.0-SNAPSHOT-2024-09-30-01-46-06" - governance_policy_addon_controller: "stolostron/governance-policy-addon-controller:2.12.0-SNAPSHOT-2024-09-30-01-46-06" - config_policy_controller: "stolostron/config-policy-controller:2.12.0-SNAPSHOT-2024-09-30-01-46-06" - governance_policy_framework_addon: "stolostron/governance-policy-framework-addon:2.12.0-SNAPSHOT-2024-09-30-01-46-06" - klusterlet_addon_controller: "stolostron/klusterlet-addon-controller:2.12.0-SNAPSHOT-2024-09-30-01-46-06" + governance_policy_propagator: "governance-policy-propagator:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + governance_policy_addon_controller: "governance-policy-addon-controller:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + config_policy_controller: "config-policy-controller:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + governance_policy_framework_addon: "governance-policy-framework-addon:2.13.0-SNAPSHOT-2024-11-20-23-56-00" + klusterlet_addon_controller: "klusterlet-addon-controller:2.13.0-SNAPSHOT-2024-11-20-23-56-00" # images in ACM 2.11.2 # governance_policy_propagator: "rhacm2/governance-policy-propagator-rhel9@sha256:af848e7e31d8ec9b5ad1896a5d5ccc67f320a7740245c190ba8a76757984e65b" diff --git a/test/e2e/common.go b/test/e2e/common.go new file mode 100644 index 0000000..d060696 --- /dev/null +++ b/test/e2e/common.go @@ -0,0 +1,86 @@ +package e2e + +import ( + "fmt" + + apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/client-go/dynamic" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" + "sigs.k8s.io/controller-runtime/pkg/client/apiutil" + + addonclient "open-cluster-management.io/api/client/addon/clientset/versioned" + clusterclient "open-cluster-management.io/api/client/cluster/clientset/versioned" + operatorclient "open-cluster-management.io/api/client/operator/clientset/versioned" + workv1client "open-cluster-management.io/api/client/work/clientset/versioned" +) + +type Clients struct { + KubeClient kubernetes.Interface + APIExtensionsClient apiextensionsclient.Interface + OperatorClient operatorclient.Interface + ClusterClient clusterclient.Interface + WorkClient workv1client.Interface + AddonClient addonclient.Interface + DynamicClient dynamic.Interface + RestMapper meta.RESTMapper +} + +func NewClients(clusterCfg *rest.Config) (*Clients, error) { + kubeClient, err := kubernetes.NewForConfig(clusterCfg) + if err != nil { + return nil, fmt.Errorf("failed to create managed cluster client: %w", err) + } + + httpClient, err := rest.HTTPClientFor(clusterCfg) + if err != nil { + return nil, fmt.Errorf("failed to create managed cluster http client: %w", err) + } + + restMapper, err := apiutil.NewDynamicRESTMapper(clusterCfg, httpClient) + if err != nil { + return nil, fmt.Errorf("failed to create managed cluster rest mapper: %w", err) + } + + dynamicClient, err := dynamic.NewForConfig(clusterCfg) + if err != nil { + return nil, fmt.Errorf("failed to create managed cluster dynamic client: %w", err) + } + + apiExtensionsClient, err := apiextensionsclient.NewForConfig(clusterCfg) + if err != nil { + return nil, fmt.Errorf("failed to create managed cluster api extensions client: %w", err) + } + + operatorClient, err := operatorclient.NewForConfig(clusterCfg) + if err != nil { + return nil, fmt.Errorf("failed to create managed cluster operator client: %w", err) + } + + clusterClient, err := clusterclient.NewForConfig(clusterCfg) + if err != nil { + return nil, fmt.Errorf("failed to create managed cluster cluster client: %w", err) + } + + workClient, err := workv1client.NewForConfig(clusterCfg) + if err != nil { + return nil, fmt.Errorf("failed to create managed cluster work client: %w", err) + } + + addonClient, err := addonclient.NewForConfig(clusterCfg) + if err != nil { + return nil, fmt.Errorf("failed to create managed cluster addon client: %w", err) + } + + return &Clients{ + KubeClient: kubeClient, + APIExtensionsClient: apiExtensionsClient, + OperatorClient: operatorClient, + ClusterClient: clusterClient, + WorkClient: workClient, + AddonClient: addonClient, + DynamicClient: dynamicClient, + RestMapper: restMapper, + }, nil +} diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go new file mode 100644 index 0000000..89dab46 --- /dev/null +++ b/test/e2e/e2e_suite_test.go @@ -0,0 +1,59 @@ +package e2e + +import ( + "os" + "testing" + "time" + + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + "k8s.io/client-go/tools/clientcmd" +) + +var ( + hubKubeConfig string + HubClients *Clients +) + +const ( + LocalClusterName = "local-cluster" + ConfigPolicyAddonName = "config-policy-controller" + GovernancePolicyFrameworkAddonName = "governance-policy-framework" + HypershiftAddonName = "hypershift-addon" + WorkManagerAddonName = "work-manager" +) + +func TestE2E(tt *testing.T) { + OutputFail := func(message string, callerSkip ...int) { + ginkgo.Fail(message, callerSkip...) + } + + gomega.RegisterFailHandler(OutputFail) + ginkgo.RunSpecs(tt, "ocm E2E Suite") +} + +var _ = ginkgo.BeforeSuite(func() { + if hubKubeConfig == "" { + hubKubeConfig = os.Getenv("KUBECONFIG") + } + gomega.Expect(hubKubeConfig).ToNot(gomega.BeEmpty()) + + clusterCfg, err := clientcmd.BuildConfigFromFlags("", hubKubeConfig) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + HubClients, err = NewClients(clusterCfg) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + gomega.Default.SetDefaultEventuallyTimeout(90 * time.Second) + gomega.Default.SetDefaultEventuallyPollingInterval(5 * time.Second) + + ginkgo.By("Check Hub Ready") + gomega.Eventually(func() error { + return nil + }).Should(gomega.Succeed()) + +}) + +var _ = ginkgo.AfterSuite(func() { + ginkgo.By("clean created resources") +}) diff --git a/test/e2e/helpers.go b/test/e2e/helpers.go new file mode 100644 index 0000000..e227296 --- /dev/null +++ b/test/e2e/helpers.go @@ -0,0 +1,57 @@ +package e2e + +import ( + "fmt" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "open-cluster-management.io/api/addon/v1alpha1" + clusterv1 "open-cluster-management.io/api/cluster/v1" +) + +func CheckManagedClusterStatus(cluster *clusterv1.ManagedCluster) error { + var okCount = 0 + for _, condition := range cluster.Status.Conditions { + if (condition.Type == clusterv1.ManagedClusterConditionHubAccepted || + condition.Type == clusterv1.ManagedClusterConditionJoined || + condition.Type == clusterv1.ManagedClusterConditionAvailable) && + condition.Status == metav1.ConditionTrue { + okCount++ + } + } + + if okCount != 3 { + return fmt.Errorf("cluster %s condtions are not ready: %v", cluster.Name, cluster.Status.Conditions) + } + + okCount = 0 + + for _, claim := range cluster.Status.ClusterClaims { + switch claim.Name { + case "id.k8s.io", "kubeversion.open-cluster-management.io", + "platform.open-cluster-management.io", "product.open-cluster-management.io": + if claim.Value != "" { + okCount++ + } + } + } + if okCount != 4 { + return fmt.Errorf("cluster %s claims are not ready: %v", cluster.Name, cluster.Status.ClusterClaims) + } + return nil +} + +func CheckAddonStatus(addon v1alpha1.ManagedClusterAddOn) error { + var okCount = 0 + for _, condition := range addon.Status.Conditions { + if (condition.Type == v1alpha1.ManagedClusterAddOnConditionAvailable || + condition.Type == v1alpha1.ManagedClusterAddOnManifestApplied) && + condition.Status == metav1.ConditionTrue { + okCount++ + } + } + + if okCount == 2 { + return nil + } + + return fmt.Errorf("cluster %s condtions are not ready: %v", addon.Name, addon.Status.Conditions) +} diff --git a/test/e2e/local_cluster_test.go b/test/e2e/local_cluster_test.go new file mode 100644 index 0000000..62f21f7 --- /dev/null +++ b/test/e2e/local_cluster_test.go @@ -0,0 +1,45 @@ +package e2e + +import ( + "context" + "fmt" + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +var _ = ginkgo.Describe("check if local-cluster is healthy", func() { + + ginkgo.BeforeEach(func() { + + }) + ginkgo.AfterEach(func() { + + }) + + ginkgo.It("check status of the local-cluster", func() { + cluster, err := HubClients.ClusterClient.ClusterV1().ManagedClusters().Get(context.Background(), + LocalClusterName, metav1.GetOptions{}) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + gomega.Expect(CheckManagedClusterStatus(cluster)).ToNot(gomega.HaveOccurred()) + }) + + ginkgo.It("check status of the addons in local-cluster", func() { + addons, err := HubClients.AddonClient.AddonV1alpha1().ManagedClusterAddOns(LocalClusterName). + List(context.Background(), metav1.ListOptions{}) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + gomega.Expect(len(addons.Items)).Should(gomega.Equal(4)) + + for _, addon := range addons.Items { + switch addon.Name { + case WorkManagerAddonName, GovernancePolicyFrameworkAddonName, ConfigPolicyAddonName: + gomega.Expect(CheckAddonStatus(addon)).ToNot(gomega.HaveOccurred()) + case HypershiftAddonName: + // TODO: is not ready since there is no hyperShiftOperator ? + default: + err := fmt.Errorf("unexpected addon: %s", addon.Name) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + } + } + }) +})