Skip to content

Commit

Permalink
Cleanup CommonBeforeSuite (#96)
Browse files Browse the repository at this point in the history
Signed-off-by: Parthvi <[email protected]>
  • Loading branch information
valaparthvi authored May 2, 2024
1 parent 368116d commit 9df8c7f
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 22 deletions.
3 changes: 1 addition & 2 deletions hosted/aks/k8s_chart_support/k8s_chart_support_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ var _ = BeforeSuite(func() {

var _ = BeforeEach(func() {
var err error
ctx, err = helpers.CommonBeforeSuite(helpers.Provider)
Expect(err).To(BeNil())
ctx = helpers.CommonBeforeSuite(helpers.Provider)
clusterName = namegen.AppendRandomString(helpers.ClusterNamePrefix)
k8sVersion, err = helper.GetK8sVersion(ctx.RancherClient, ctx.CloudCred.ID, location)
Expect(err).To(BeNil())
Expand Down
3 changes: 1 addition & 2 deletions hosted/aks/p0/p0_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ func TestP0(t *testing.T) {

var _ = BeforeEach(func() {
var err error
ctx, err = helpers.CommonBeforeSuite(helpers.Provider)
Expect(err).To(BeNil())
ctx = helpers.CommonBeforeSuite(helpers.Provider)
clusterName = namegen.AppendRandomString(helpers.ClusterNamePrefix)
k8sVersion, err = helper.GetK8sVersion(ctx.RancherClient, ctx.CloudCred.ID, location)
Expect(err).To(BeNil())
Expand Down
3 changes: 1 addition & 2 deletions hosted/aks/support_matrix/support_matrix_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ var (
func TestSupportMatrix(t *testing.T) {
RegisterFailHandler(Fail)
var err error
ctx, err = helpers.CommonBeforeSuite(helpers.Provider)
Expect(err).To(BeNil())
ctx = helpers.CommonBeforeSuite(helpers.Provider)
availableVersionList, err = helper.ListSingleVariantAKSAvailableVersions(ctx.RancherClient, ctx.CloudCred.ID, location)
Expect(err).To(BeNil())
RunSpecs(t, "SupportMatrix Suite")
Expand Down
3 changes: 1 addition & 2 deletions hosted/eks/k8s_chart_support/k8s_chart_support_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ var _ = BeforeSuite(func() {

var _ = BeforeEach(func() {
var err error
ctx, err = helpers.CommonBeforeSuite(helpers.Provider)
Expect(err).To(BeNil())
ctx = helpers.CommonBeforeSuite(helpers.Provider)
clusterName = namegen.AppendRandomString(helpers.ClusterNamePrefix)

k8sVersion, err = helper.GetK8sVersion(ctx.RancherClient)
Expand Down
3 changes: 1 addition & 2 deletions hosted/eks/p0/p0_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ func TestP0(t *testing.T) {

var _ = BeforeEach(func() {
var err error
ctx, err = helpers.CommonBeforeSuite(helpers.Provider)
Expect(err).To(BeNil())
ctx = helpers.CommonBeforeSuite(helpers.Provider)
clusterName = namegen.AppendRandomString(helpers.ClusterNamePrefix)
k8sVersion, err = helper.GetK8sVersion(ctx.RancherClient)
Expect(err).To(BeNil())
Expand Down
3 changes: 1 addition & 2 deletions hosted/eks/support_matrix/support_matrix_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ var (
func TestSupportMatrix(t *testing.T) {
RegisterFailHandler(Fail)
var err error
ctx, err = helpers.CommonBeforeSuite(helpers.Provider)
Expect(err).To(BeNil())
ctx = helpers.CommonBeforeSuite(helpers.Provider)
availableVersionList, err = kubernetesversions.ListEKSAllVersions(ctx.RancherClient)
Expect(err).To(BeNil())
Expect(availableVersionList).ToNot(BeEmpty())
Expand Down
3 changes: 1 addition & 2 deletions hosted/gke/k8s_chart_support/k8s_chart_support_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ var _ = BeforeSuite(func() {
})
var _ = BeforeEach(func() {
var err error
ctx, err = helpers.CommonBeforeSuite(helpers.Provider)
Expect(err).To(BeNil())
ctx = helpers.CommonBeforeSuite(helpers.Provider)
clusterName = namegen.AppendRandomString(helpers.ClusterNamePrefix)

k8sVersion, err = helper.GetK8sVersion(ctx.RancherClient, project, ctx.CloudCred.ID, zone, "")
Expand Down
3 changes: 1 addition & 2 deletions hosted/gke/p0/p0_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ func TestP0(t *testing.T) {

var _ = BeforeEach(func() {
var err error
ctx, err = helpers.CommonBeforeSuite(helpers.Provider)
Expect(err).To(BeNil())
ctx = helpers.CommonBeforeSuite(helpers.Provider)
clusterName = namegen.AppendRandomString(helpers.ClusterNamePrefix)
k8sVersion, err = helper.GetK8sVersion(ctx.RancherClient, project, ctx.CloudCred.ID, zone, "")
Expect(err).To(BeNil())
Expand Down
3 changes: 1 addition & 2 deletions hosted/gke/support_matrix/support_matrix_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ var (
func TestSupportMatrix(t *testing.T) {
RegisterFailHandler(Fail)
var err error
ctx, err = helpers.CommonBeforeSuite(helpers.Provider)
Expect(err).To(BeNil())
ctx = helpers.CommonBeforeSuite(helpers.Provider)
availableVersionList, err = helper.ListSingleVariantGKEAvailableVersions(ctx.RancherClient, project, ctx.CloudCred.ID, zone, "")
Expect(err).To(BeNil())
RunSpecs(t, "SupportMatrix Suite")
Expand Down
6 changes: 2 additions & 4 deletions hosted/helpers/helper_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"os"
"os/user"
"strconv"
"strings"

"github.com/onsi/ginkgo/v2"
Expand All @@ -25,7 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func CommonBeforeSuite(cloud string) (Context, error) {
func CommonBeforeSuite(cloud string) Context {

rancherConfig := new(rancher.Config)
Eventually(rancherConfig, "10s").ShouldNot(BeNil())
Expand Down Expand Up @@ -83,13 +82,12 @@ func CommonBeforeSuite(cloud string) (Context, error) {
Expect(err).To(BeNil())
}

clusterCleanup, _ := strconv.ParseBool(os.Getenv("DOWNSTREAM_CLUSTER_CLEANUP"))
return Context{
CloudCred: cloudCredential,
RancherClient: rancherClient,
Session: testSession,
ClusterCleanup: clusterCleanup,
}, nil
}
}

// WaitUntilClusterIsReady waits until the cluster is in a Ready state,
Expand Down

0 comments on commit 9df8c7f

Please sign in to comment.