Skip to content

Commit

Permalink
refactor alltestCases and live test it
Browse files Browse the repository at this point in the history
  • Loading branch information
bartam1 committed Jul 25, 2023
1 parent eb76940 commit 6de9f34
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 89 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,3 @@ jobs:
comment_mode: off
files: |
tests/e2e/reports/e2e_*.xml
# - name: E2E Test Report
# uses: dorny/test-reporter@v1
# if: always()
# with:
# name: E2E tests
# path: "tests/e2e/reports/e2e_*.xml"
# reporter: jest-junit
# fail-on-error: true

2 changes: 1 addition & 1 deletion tests/e2e/koperator_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func beforeSuite() (tests.TestPool, error) {
}

//classifier := MockTests()
classifier := tests.NewClassifier(k8sClusterPool, testCaseInstall)
classifier := tests.NewClassifier(k8sClusterPool, alltestCase)

var testPool tests.TestPool
testStrategy := viper.GetString(config.Tests.TestStrategy)
Expand Down
20 changes: 12 additions & 8 deletions tests/e2e/test_alltestcase.go → tests/e2e/test_alltestcases.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

var alltestCase = tests.TestCase{
TestDuration: 10 * time.Minute,
TestName: "Testing e2e test altogether",
TestName: "ALL_TESTCASE",
TestFn: allTestCase,
}

Expand All @@ -32,12 +32,16 @@ func allTestCase(kubectlOptions k8s.KubectlOptions) {
var snapshottedInfo = &clusterSnapshot{}
snapshotCluster(snapshottedInfo)
testInstall(kubectlOptions)
testInstallZookeeperCluster()
testInstallKafkaCluster("../../config/samples/simplekafkacluster.yaml")
testUninstallKafkaCluster()
testInstallKafkaCluster("../../config/samples/simplekafkacluster_ssl.yaml")
testUninstallKafkaCluster()
testUninstallZookeeperCluster()
testUninstall()
testInstallZookeeperCluster(kubectlOptions)
testInstallKafkaCluster(kubectlOptions, "../../config/samples/simplekafkacluster.yaml")
testProduceConsumeExternal(kubectlOptions, "")
testProduceConsumeInternal(kubectlOptions)
testUninstallKafkaCluster(kubectlOptions)
testInstallKafkaCluster(kubectlOptions, "../../config/samples/simplekafkacluster_ssl.yaml")
testProduceConsumeExternal(kubectlOptions, "")
testProduceConsumeInternal(kubectlOptions)
testUninstallKafkaCluster(kubectlOptions)
testUninstallZookeeperCluster(kubectlOptions)
testUninstall(kubectlOptions)
snapshotClusterAndCompare(snapshottedInfo)
}
2 changes: 1 addition & 1 deletion tests/e2e/test_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

var testCaseInstall = tests.TestCase{
TestDuration: 4 * time.Minute,
TestName: "Install TestCase",
TestName: "INSTALL_TESTCASE",
TestFn: testInstall,
}

Expand Down
21 changes: 2 additions & 19 deletions tests/e2e/test_install_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,17 @@ package e2e
import (
"github.com/gruntwork-io/terratest/modules/k8s"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func testInstallZookeeperCluster() bool {
func testInstallZookeeperCluster(kubectlOptions k8s.KubectlOptions) bool {
return When("Installing Zookeeper cluster", func() {
var kubectlOptions k8s.KubectlOptions
var err error

It("Acquiring K8s config and context", func() {
kubectlOptions, err = kubectlOptionsForCurrentContext()
Expect(err).NotTo(HaveOccurred())
})

kubectlOptions.Namespace = zookeeperOperatorHelmDescriptor.Namespace
requireCreatingZookeeperCluster(kubectlOptions)
})
}

func testInstallKafkaCluster(kafkaClusterManifestPath string) bool {
func testInstallKafkaCluster(kubectlOptions k8s.KubectlOptions, kafkaClusterManifestPath string) bool {
return When("Installing Kafka cluster", func() {
var kubectlOptions k8s.KubectlOptions
var err error

It("Acquiring K8s config and context", func() {
kubectlOptions, err = kubectlOptionsForCurrentContext()
Expect(err).NotTo(HaveOccurred())
})

kubectlOptions.Namespace = koperatorLocalHelmDescriptor.Namespace
requireCreatingKafkaCluster(kubectlOptions, kafkaClusterManifestPath)
})
Expand Down
21 changes: 2 additions & 19 deletions tests/e2e/test_produce_consume.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@ package e2e
import (
"github.com/gruntwork-io/terratest/modules/k8s"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func testProduceConsumeInternal() bool {
func testProduceConsumeInternal(kubectlOptions k8s.KubectlOptions) bool {
return When("Internally produce and consume message to/from Kafka cluster", func() {
var kubectlOptions k8s.KubectlOptions
var err error

It("Acquiring K8s config and context", func() {
kubectlOptions, err = kubectlOptionsForCurrentContext()
Expect(err).NotTo(HaveOccurred())
})

kubectlOptions.Namespace = koperatorLocalHelmDescriptor.Namespace

requireDeployingKcatPod(kubectlOptions, kcatPodName)
Expand All @@ -26,16 +17,8 @@ func testProduceConsumeInternal() bool {
})
}

func testProduceConsumeExternal(tlsSecretName string) bool {
func testProduceConsumeExternal(kubectlOptions k8s.KubectlOptions, tlsSecretName string) bool {
return When("Externally produce and consume message to/from Kafka cluster", func() {
var kubectlOptions k8s.KubectlOptions
var err error

It("Acquiring K8s config and context", func() {
kubectlOptions, err = kubectlOptionsForCurrentContext()
Expect(err).NotTo(HaveOccurred())
})

kubectlOptions.Namespace = koperatorLocalHelmDescriptor.Namespace

requireDeployingKafkaTopic(kubectlOptions, testExternalTopicName)
Expand Down
13 changes: 1 addition & 12 deletions tests/e2e/test_uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,14 @@ import (
. "github.com/onsi/gomega"
)

func testUninstall() bool {
func testUninstall(kubectlOptions k8s.KubectlOptions) bool {
return When("Uninstalling Koperator and dependencies", Ordered, func() {
var kubectlOptions k8s.KubectlOptions
var err error

When("Initializing", func() {
It("Acquiring K8s config and context", func() {
kubectlOptions, err = kubectlOptionsForCurrentContext()
Expect(err).NotTo(HaveOccurred())
})

It("Setting globals", func() {
err := dependencyCRDs.Initialize(kubectlOptions)
Expect(err).NotTo(HaveOccurred())
})

})

requireUninstallingKoperator(k8s.KubectlOptions{
ContextName: kubectlOptions.ContextName,
ConfigPath: kubectlOptions.ConfigPath,
Expand All @@ -58,6 +48,5 @@ func testUninstall() bool {
ConfigPath: kubectlOptions.ConfigPath,
Namespace: certManagerHelmDescriptor.Namespace,
})

})
}
21 changes: 2 additions & 19 deletions tests/e2e/test_uninstall_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,18 @@ package e2e
import (
"github.com/gruntwork-io/terratest/modules/k8s"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func testUninstallZookeeperCluster() bool {
func testUninstallZookeeperCluster(kubectlOptions k8s.KubectlOptions) bool {
return When("Uninstalling Zookeeper cluster", func() {
var kubectlOptions k8s.KubectlOptions
var err error

It("Acquiring K8s config and context", func() {
kubectlOptions, err = kubectlOptionsForCurrentContext()
Expect(err).NotTo(HaveOccurred())
})

kubectlOptions.Namespace = zookeeperOperatorHelmDescriptor.Namespace
requireDeleteZookeeperCluster(kubectlOptions, zookeeperClusterName)

})
}

func testUninstallKafkaCluster() bool {
func testUninstallKafkaCluster(kubectlOptions k8s.KubectlOptions) bool {
return When("Uninstalling Kafka cluster", func() {
var kubectlOptions k8s.KubectlOptions
var err error

It("Acquiring K8s config and context", func() {
kubectlOptions, err = kubectlOptionsForCurrentContext()
Expect(err).NotTo(HaveOccurred())
})

kubectlOptions.Namespace = koperatorLocalHelmDescriptor.Namespace
requireDeleteKafkaCluster(kubectlOptions, kafkaClusterName)
})
Expand Down

0 comments on commit 6de9f34

Please sign in to comment.