-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: refactoring e2e #227
test: refactoring e2e #227
Conversation
cf3b34b
to
d34b024
Compare
e5e3b7b
to
3639d7b
Compare
3639d7b
to
c25fcc8
Compare
e2e/config.go
Outdated
// SuiteFailed indicates whether any test in the current suite has failed | ||
var SuiteFailed = false | ||
var scheme = runtime.NewScheme() | ||
var CrClient crclient.Client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the variable used outside the package? If not, then it should start with small case. Also, why the name CrClient
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, used this client in pvc_test.go
So that's why initialised it with upper case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need a different package for pvc? Can everything be done in the e2e pkg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so inside lvm only lvm_suite_test.go should reside right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can be done. Updating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the lvm pkg at all? Can everything be in a single e2e pkg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, everything inside the same package.
e2e/config.go
Outdated
utilruntime.Must(snapapi.AddToScheme(scheme)) | ||
|
||
kubeconfig := os.Getenv("KUBECONFIG") | ||
config, _ := getKubeconfig(kubeconfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error is not handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
e2e/config.go
Outdated
|
||
kubeconfig := os.Getenv("KUBECONFIG") | ||
config, _ := getKubeconfig(kubeconfig) | ||
CrClient, _ = crclient.New(config, crclient.Options{Scheme: scheme}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error is not handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
e2e/helper.go
Outdated
if err != nil && !errors.IsNotFound(err) { | ||
return err | ||
} | ||
err := CrClient.Delete(context.TODO(), ns) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to pass proper context rather than context.TODO()
for every function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context.TODO() is still being used in a lot of places.
e2e/config.go
Outdated
// SuiteFailed indicates whether any test in the current suite has failed | ||
var SuiteFailed = false | ||
var scheme = runtime.NewScheme() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of having var
declared in each line, it can be grouped together. For example:
var ( )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grouped all the vars and const.
e2e/config.go
Outdated
@@ -23,11 +32,10 @@ var LvmSubscriptionChannel string | |||
// DiskInstall indicates whether disks are needed to be installed. | |||
var DiskInstall bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please recheck all these variables. The ones within the scope of the package should be in small case. Like DiskInstall
.
e2e/helper.go
Outdated
return err | ||
} | ||
err := CrClient.Create(context.TODO(), ns) | ||
gomega.Expect(err).To(gomega.BeNil()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
earlier it was validating against two errors ( not nil
and IsAlreadyExists
). But looks like the change (gomega error handling) does not cover IsAlreadyExists
e2e/subscription.go
Outdated
@@ -150,7 +150,7 @@ func (t *DeployManager) waitForLVMCatalogSource() error { | |||
} | |||
|
|||
// WaitForLVMOperator waits for the lvm-operator to come online. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// WaitForLVMOperator waits for the lvm-operator to come online. | |
// waitForLVMOperator waits for the lvm-operator to come online. |
e2e/subscription.go
Outdated
@@ -275,11 +275,11 @@ func (t *DeployManager) DeployLVMWithOLM(lvmCatalogImage string, subscriptionCha | |||
} | |||
|
|||
// DeleteClusterObjects deletes remaining operator manifests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// DeleteClusterObjects deletes remaining operator manifests. | |
// deleteClusterObjects deletes remaining operator manifests. |
e2e/subscription.go
Outdated
@@ -275,11 +275,11 @@ func (t *DeployManager) DeployLVMWithOLM(lvmCatalogImage string, subscriptionCha | |||
} | |||
|
|||
// DeleteClusterObjects deletes remaining operator manifests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// DeleteClusterObjects deletes remaining operator manifests. | |
// deleteClusterObjects deletes remaining operator manifests. |
e2e/subscription.go
Outdated
@@ -306,15 +306,15 @@ func (t *DeployManager) deleteClusterObjects(co *clusterObjects) error { | |||
} | |||
|
|||
// UninstallLVM uninstalls lvm operator. | |||
func (t *DeployManager) UninstallLVM(lvmCatalogImage string, subscriptionChannel string) error { | |||
func UninstallLVM(lvmCatalogImage string, subscriptionChannel string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
start function with lower case if its not used outside the package. Please check this for all the other functions as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
c25fcc8
to
c91726c
Compare
c91726c
to
76cf3ab
Compare
e2e/disk_setup.go
Outdated
@@ -53,7 +53,7 @@ func diskSetup() error { | |||
func diskRemoval() error { | |||
// get nodes | |||
nodeList := &corev1.NodeList{} | |||
err := DeployManagerObj.GetCrClient().List(context.TODO(), nodeList, client.HasLabels{labelNodeRoleWorker}) | |||
err := crClient.List(context.TODO(), nodeList, client.HasLabels{labelNodeRoleWorker}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uses context.TODO()
e2e/pvc_check.go
Outdated
@@ -29,184 +25,183 @@ func PVCTest() { | |||
var clonePod *k8sv1.Pod | |||
var restorePvc *k8sv1.PersistentVolumeClaim | |||
var restorePod *k8sv1.Pod | |||
client := tests.DeployManagerObj.GetCrClient() | |||
ctx := context.TODO() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using context.TODO()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
822e48d
to
52e44df
Compare
98f2e7e
to
091755c
Compare
e2e/LVMCluster.go
Outdated
return t.crClient.Create(context.TODO(), lvmClusterRes) | ||
func startLVMCluster() error { | ||
lvmClusterRes := generateLVMCluster() | ||
return crClient.Create(context.Background(), lvmClusterRes) | ||
} | ||
|
||
// Deletes a sample CR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as per golang coding convention, doc comment for an exported function should start with the function name. Please fix this for other functions as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is used only in this package(not an exported func), so will correct the name of function with lower case.
a62500c
to
61101c6
Compare
discussed some more improvements that can be made in the PR offline. Adding them here:
|
e2e/config.go
Outdated
// SuiteFailed indicates whether any test in the current suite has failed | ||
var SuiteFailed = false | ||
const ( | ||
testNamespace = "lvm-endtoendtest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comments describing the constants and variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
e2e/config.go
Outdated
kubeconfig := os.Getenv("KUBECONFIG") | ||
config, err := getKubeconfig(kubeconfig) | ||
if err != nil { | ||
panic(fmt.Sprintf("Failed to set kubecofig: %v", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
panic(fmt.Sprintf("Failed to set kubecofig: %v", err)) | |
panic(fmt.Sprintf("Failed to set kubeconfig: %v", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
e2e/subscription.go
Outdated
type clusterObjects struct { | ||
namespaces []k8sv1.Namespace | ||
operatorGroups []v1.OperatorGroup | ||
catalogSources []v1alpha1.CatalogSource | ||
subscriptions []v1alpha1.Subscription | ||
} | ||
|
||
// Generating the cluster objects. | ||
func (t *DeployManager) generateClusterObjects(lvmCatalogImage string, subscriptionChannel string) *clusterObjects { | ||
// generateClusterObjects generates the cluster objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// generateClusterObjects generates the cluster objects. | |
// generateClusterObjects generates the cluster objects required for deploying the operator using OLM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
61101c6
to
c798b13
Compare
Signed-off-by: riya-singhal31 <[email protected]>
c798b13
to
28ef252
Compare
lvmSubscriptionChannel string | ||
// diskInstall indicates whether disks are needed to be installed. | ||
diskInstall bool | ||
lvmOperatorInstall bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comments for lvmOperatorInstall and lvmOperatorUninstall.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nbalacha, riya-singhal31 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Removed the Deploy Manager package as it was being used by e2e only.
Created and accessed the clients, configs and all the required functions in the e2e folder itself.
Signed-off-by: riya-singhal31 [email protected]