Skip to content

Commit

Permalink
Enhance E2E Test Suite to support Parallel Execution (#833)
Browse files Browse the repository at this point in the history
* Refactor e2e test suite for enhanced concurrency and clarity
  • Loading branch information
seshachalam-yv authored Aug 16, 2024
1 parent 4802138 commit 3383e02
Show file tree
Hide file tree
Showing 12 changed files with 695 additions and 368 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ test-e2e: $(KUBECTL) $(HELM) $(SKAFFOLD) $(KUSTOMIZE)
@VERSION=$(VERSION) GIT_SHA=$(GIT_SHA) $(HACK_DIR)/e2e-test/run-e2e-test.sh $(PROVIDERS)

.PHONY: ci-e2e-kind
ci-e2e-kind:
ci-e2e-kind: $(GINKGO)
@BUCKET_NAME=$(BUCKET_NAME) $(HACK_DIR)/ci-e2e-kind.sh

.PHONY: ci-e2e-kind-azure
ci-e2e-kind-azure:
ci-e2e-kind-azure: $(GINKGO)
@BUCKET_NAME=$(BUCKET_NAME) $(HACK_DIR)/ci-e2e-kind-azure.sh
2 changes: 1 addition & 1 deletion hack/e2e-test/run-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function test_e2e {
echo "-------------------"

SOURCE_PATH=$PWD \
go test -timeout=0 ./test/e2e --v -args -ginkgo.v -ginkgo.show-node-events
ginkgo -v -p ./test/e2e
fi
}

Expand Down
34 changes: 9 additions & 25 deletions test/e2e/etcd_backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

"github.com/gardener/etcd-druid/api/v1alpha1"
druidstore "github.com/gardener/etcd-druid/internal/store"

brtypes "github.com/gardener/etcd-backup-restore/pkg/types"
"github.com/gardener/gardener/pkg/utils/test/matchers"
Expand Down Expand Up @@ -49,32 +48,11 @@ var _ = Describe("Etcd Backup", func() {
provider := p
Context(fmt.Sprintf("with provider %s", provider.Name), func() {
BeforeEach(func() {
etcdName = fmt.Sprintf("etcd-%s", provider.Name)
etcdName = fmt.Sprintf("etcd-single-node-%s", provider.Name)
storePrefix = etcdName
storageContainer = getEnvAndExpectNoError(envStorageContainer)

By("Purge snapstore")
snapstoreProvider := provider.Storage.Provider
if snapstoreProvider == druidstore.Local {
purgeLocalSnapstoreJob := purgeLocalSnapstore(parentCtx, cl, storageContainer)
defer cleanUpTestHelperJob(parentCtx, cl, purgeLocalSnapstoreJob.Name)
} else {
store, err := getSnapstore(string(snapstoreProvider), storageContainer, storePrefix)
Expect(err).ShouldNot(HaveOccurred())
Expect(purgeSnapstore(store)).To(Succeed())
}
})

AfterEach(func() {
ctx, cancelFunc := context.WithTimeout(parentCtx, 10*time.Minute)
defer cancelFunc()

By("Delete debug pod")
etcd := getDefaultEtcd(etcdName, namespace, storageContainer, storePrefix, provider)
debugPod := getDebugPod(etcd)
Expect(client.IgnoreNotFound(cl.Delete(ctx, debugPod))).ToNot(HaveOccurred())

By("Purge etcd")
purgeEtcd(ctx, cl, providers)
purgeSnapstoreIfNeeded(parentCtx, cl, provider, storageContainer, etcdName)
})

It("Should create, test backup and delete etcd with backup", func() {
Expand Down Expand Up @@ -187,6 +165,12 @@ var _ = Describe("Etcd Backup", func() {
for i := 1; i <= 15; i++ {
Expect(keyValueMap[fmt.Sprintf("%s-%d", etcdKeyPrefix, i)]).To(Equal(fmt.Sprintf("%s-%d", etcdValuePrefix, i)))
}

By("Deleting debug pod")
Expect(client.IgnoreNotFound(cl.Delete(ctx, debugPod))).ToNot(HaveOccurred())

By("Deleting etcd")
deleteAndCheckEtcd(ctx, cl, objLogger, etcd, multiNodeEtcdTimeout)
})
})
}
Expand Down
34 changes: 9 additions & 25 deletions test/e2e/etcd_compaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

druidv1alpha1 "github.com/gardener/etcd-druid/api/v1alpha1"
druidstore "github.com/gardener/etcd-druid/internal/store"

brtypes "github.com/gardener/etcd-backup-restore/pkg/types"
. "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -43,32 +42,11 @@ var _ = Describe("Etcd Compaction", func() {
provider := p
Context(fmt.Sprintf("with provider %s", provider.Name), func() {
BeforeEach(func() {
etcdName = fmt.Sprintf("etcd-%s", provider.Name)
etcdName = fmt.Sprintf("etcd-compaction-%s", provider.Name)
storePrefix = etcdName
storageContainer = getEnvAndExpectNoError(envStorageContainer)

By("Purge snapstore")
snapstoreProvider := provider.Storage.Provider
if snapstoreProvider == druidstore.Local {
purgeLocalSnapstoreJob := purgeLocalSnapstore(parentCtx, cl, storageContainer)
defer cleanUpTestHelperJob(parentCtx, cl, purgeLocalSnapstoreJob.Name)
} else {
store, err := getSnapstore(string(snapstoreProvider), storageContainer, storePrefix)
Expect(err).ShouldNot(HaveOccurred())
Expect(purgeSnapstore(store)).To(Succeed())
}
})

AfterEach(func() {
ctx, cancelFunc := context.WithTimeout(parentCtx, 10*time.Minute)
defer cancelFunc()

By("Delete debug pod")
etcd := getDefaultEtcd(etcdName, namespace, storageContainer, storePrefix, provider)
debugPod := getDebugPod(etcd)
Expect(client.IgnoreNotFound(cl.Delete(ctx, debugPod))).ToNot(HaveOccurred())

By("Purge etcd")
purgeEtcd(ctx, cl, providers)
purgeSnapstoreIfNeeded(parentCtx, cl, provider, storageContainer, etcdName)
})

It("should test compaction on backup", func() {
Expand Down Expand Up @@ -195,6 +173,12 @@ var _ = Describe("Etcd Compaction", func() {
Expect(err).ShouldNot(HaveOccurred())

Expect(len(latestSnapshotsAfterPopulate.DeltaSnapshots)).Should(BeNumerically(">", 0))

By("Deleting debug pod")
Expect(client.IgnoreNotFound(cl.Delete(ctx, debugPod))).ToNot(HaveOccurred())

By("Deleting etcd")
deleteAndCheckEtcd(ctx, cl, objLogger, etcd, multiNodeEtcdTimeout)
})
})
}
Expand Down
Loading

0 comments on commit 3383e02

Please sign in to comment.