Skip to content

Commit

Permalink
Merge pull request #639 from rancher/test-tree
Browse files Browse the repository at this point in the history
Move e2e test dependencies into parent go.mod
  • Loading branch information
alexandreLamarre authored Jan 6, 2025
2 parents edfee14 + f784755 commit 155b1a9
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 575 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ jobs:
- arm64
name : build
runs-on : runs-on,image=ubuntu22-full-${{ matrix.arch }},runner=4cpu-linux-${{ matrix.arch }},run-id=${{ github.run_id }}
outputs:
k3sversions: ${{ steps.support.outputs.k3sversions }}
steps:
- name : Checkout repository
uses : actions/checkout@v4
Expand All @@ -69,10 +67,9 @@ jobs:
arch:
- x64
- arm64
#FIXME: temporarily hardcoded
K3S_VERSION :
- v1.28.1-k3s1
- v1.31.0-k3s1
- v1.28.9-k3s1
- v1.31.4-k3s1
steps:
- name : Checkout repository
uses : actions/checkout@v4
Expand All @@ -88,7 +85,14 @@ jobs:
run : ls -R ./dist/artifacts
- name : Install k3d
run : ./.github/workflows/scripts/install-k3d.sh
- name : Setup test environment
run : |
CLUSTER_NAME=backup-restore K3S_VERSION=${{ matrix.K3S_VERSION }} ./scripts/testenv
k3d kubeconfig get backup-restore > kubeconfig.yaml
- name : Debug kubeconfig
run : cat kubeconfig.yaml
- name : Run e2e tests
run :
CLUSTER_NAME=backup-restore K3S_VERSION=${{ matrix.K3S_VERSION }} ./scripts/testenv
cd e2e && KUBECONFIG=$KUBECONFIG CHART_NAMESPACE=cattle-resources-system go test -v -timeout 10m -count=1 ./...
run : |
cd e2e && KUBECONFIG=$KUBECONFIG CHART_NAMESPACE=cattle-resources-system go test -v -timeout 10m -count=1 ./...
env:
KUBECONFIG: ${{ github.workspace }}/kubeconfig.yaml
6 changes: 6 additions & 0 deletions .golangci.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
"issues": {
"skip-files": [
"/zz_generated_"
],
"exclude-rules": [
{
"path": "_test.go",
"linters": "revive"
}
]
}
}
6 changes: 3 additions & 3 deletions e2e/backup/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ var _ = Describe("Backup e2e remote", Ordered, Label("integration"), func() {
InsecureTLSSkipVerify: true,
},
},
ResourceSetName: "rancher-resource-set-full",
ResourceSetName: "rancher-resource-set-basic",
},
}
o.Add(b)
Expand Down Expand Up @@ -293,7 +293,7 @@ var _ = Describe("Backup e2e local driver", Ordered, Label("integration"), func(
})

By("creating a generic secret for encryption configuration")
payload := test.TestData("encryption.yaml")
payload := test.Data("encryption.yaml")

secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -345,7 +345,7 @@ var _ = Describe("Backup e2e local driver", Ordered, Label("integration"), func(
Name: encryptedBackup,
},
Spec: backupv1.BackupSpec{
ResourceSetName: "rancher-resource-set-full",
ResourceSetName: "rancher-resource-set-basic",
EncryptionConfigSecretName: encSecret,
},
}
Expand Down
14 changes: 7 additions & 7 deletions e2e/backup/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ var _ = Describe("Restore from remote driver", Ordered, Label("integration"), fu
It("should upload the required backups to the remote store", func() {
Expect(minioClient.MakeBucket(testCtx, insecureBucket, minio.MakeBucketOptions{})).To(Succeed())

By("uploading the preserve-unkown-fields backup")
By("uploading the preserve-unknown-fields backup")
ctxCa, caT := context.WithTimeout(testCtx, 10*time.Second)
defer caT()
preserveData := test.TestData("restore/preserve-unknown-fields.tar.gz")
preserveData := test.Data("restore/preserve-unknown-fields.tar.gz")
_, err := minioClient.PutObject(
ctxCa,
insecureBucket,
Expand All @@ -80,7 +80,7 @@ var _ = Describe("Restore from remote driver", Ordered, Label("integration"), fu
Expect(err).NotTo(HaveOccurred())

By("uploading deletion grace period backup")
deleteData := test.TestData("restore/deletion-grace-period-seconds.tar.gz")
deleteData := test.Data("restore/deletion-grace-period-seconds.tar.gz")
_, err = minioClient.PutObject(
ctxCa,
insecureBucket,
Expand All @@ -93,7 +93,7 @@ var _ = Describe("Restore from remote driver", Ordered, Label("integration"), fu

objectInfo := minioClient.ListObjects(ctxCa, insecureBucket, minio.ListObjectsOptions{})
i := 0
for _ = range objectInfo {
for range objectInfo {
i++
}
Expect(i).To(Equal(2))
Expand Down Expand Up @@ -159,10 +159,10 @@ var _ = Describe("Restore from remote driver", Ordered, Label("integration"), fu
It("should upload the test files to the remote store", func() {
Expect(minioClient.MakeBucket(testCtx, secureBucket, minio.MakeBucketOptions{})).To(Succeed())

By("uploading the preserve-unkown-fields backup")
By("uploading the preserve-unknown-fields backup")
ctxCa, caT := context.WithTimeout(testCtx, 10*time.Second)
defer caT()
encryptData := test.TestData("restore/encrypted-resources.tar.gz")
encryptData := test.Data("restore/encrypted-resources.tar.gz")
_, err := minioClient.PutObject(
ctxCa,
secureBucket,
Expand All @@ -174,7 +174,7 @@ var _ = Describe("Restore from remote driver", Ordered, Label("integration"), fu
Expect(err).NotTo(HaveOccurred())
objectInfo := minioClient.ListObjects(ctxCa, secureBucket, minio.ListObjectsOptions{})
i := 0
for _ = range objectInfo {
for range objectInfo {
i++
}
Expect(i).To(Equal(1))
Expand Down
4 changes: 2 additions & 2 deletions e2e/backup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

func SetupRancherResourceSet(o *ObjectTracker) {
rsc := test.TestData("rancher-resource-set.yaml")
rsc := test.Data("rancher-resource-set-basic.yaml")
rscObj := &backupv1.ResourceSet{}
Expect(yaml.Unmarshal(rsc, rscObj)).To(Succeed())
o.Add(rscObj)
Expand All @@ -42,7 +42,7 @@ func SetupOperator(ctx context.Context, kubeconfig *rest.Config, options operato

func SetupEncryption(o *ObjectTracker) {
By("creating a generic secret for encryption configuration")
payload := test.TestData("encryption.yaml")
payload := test.Data("encryption.yaml")
encsecret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: encSecret,
Expand Down
4 changes: 1 addition & 3 deletions e2e/backup/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"testing"
"time"

"github.com/kralicky/kmatch"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/rancher/backup-restore-operator/pkg/operator"
Expand All @@ -26,6 +25,7 @@ import (
"k8s.io/client-go/tools/clientcmd"

env "github.com/caarlos0/env/v11"
"github.com/kralicky/kmatch"
. "github.com/kralicky/kmatch"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -61,8 +61,6 @@ func (t *TestSpec) Validate() error {
if _, err := os.Stat(t.Kubeconfig); err != nil {
errs = append(errs, err)
}
if t.ChartNamespace == "" {
}
if len(errs) > 0 {
return errors.Join(errs...)
}
Expand Down
152 changes: 0 additions & 152 deletions e2e/go.mod

This file was deleted.

Loading

0 comments on commit 155b1a9

Please sign in to comment.