From 0af8e1ca97cd05fdc71c6643eb0719c5078a76f2 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Wed, 28 Dec 2022 17:31:44 +0100 Subject: [PATCH] Use kind to create cluster in CI, instead of k3d (#1821) * Use kind to create cluster in CI, instead of k3d * Install just csi-hostpath-driver only for `make test` * Use service object instead of secret object Co-authored-by: Chaitali Gondhalekar Co-authored-by: Pavan Navarathna <6504783+pavannd1@users.noreply.github.com> --- .github/workflows/main.yaml | 14 +++++++------- pkg/kube/unstructured_test.go | 9 +++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 02993fb4f8..cd2ea21d61 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -37,18 +37,18 @@ jobs: - uses: actions/download-artifact@v3 with: name: src - - uses: AbsaOSS/k3d-action@v2 - with: - cluster-name: "kanister-run-${{ matrix.testSuite }}" - args: >- - --agents 3 - --no-lb - --k3s-arg "--no-deploy=traefik,servicelb@server:*" + - uses: helm/kind-action@v1.4.0 - run: tar -xvf ./src.tar.gz - run: | make install-csi-hostpath-driver make install-minio if: matrix.testSuite == 'integration-test' || matrix.testSuite == 'helm-test' + # A test (CRDSuite) that runs as part of `make test` requies atleast one CRD to + # be present on the cluster. That's why we are only installing csi-hostpath-driver + # before running `make test`, to create some CRDs on the cluster. + - run: | + make install-csi-hostpath-driver + if: matrix.testSuite == 'test' - run: make ${{ matrix.testSuite }} build: runs-on: ubuntu-20.04 diff --git a/pkg/kube/unstructured_test.go b/pkg/kube/unstructured_test.go index 99f79a687c..560c587246 100644 --- a/pkg/kube/unstructured_test.go +++ b/pkg/kube/unstructured_test.go @@ -17,9 +17,10 @@ package kube import ( "bytes" "context" - . "gopkg.in/check.v1" "text/template" + . "gopkg.in/check.v1" + "github.com/Masterminds/sprig" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -37,9 +38,9 @@ func (s *UnstructuredSuite) TestFetch(c *C) { gvr := schema.GroupVersionResource{ Group: "", Version: "v1", - Resource: "serviceaccounts", + Resource: "services", } - u, err := FetchUnstructuredObject(ctx, gvr, "default", "default") + u, err := FetchUnstructuredObject(ctx, gvr, "default", "kubernetes") c.Assert(err, IsNil) buf := bytes.NewBuffer(nil) @@ -49,7 +50,7 @@ func (s *UnstructuredSuite) TestFetch(c *C) { arg string }{ {"{{ .Unstructured.metadata.name }}"}, - {"{{ index .Unstructured.secrets 0 }}"}, + {"{{ .Unstructured.spec.clusterIP }}"}, } { t, err := template.New("config").Option("missingkey=error").Funcs(sprig.TxtFuncMap()).Parse(tc.arg) c.Assert(err, IsNil)