-
Notifications
You must be signed in to change notification settings - Fork 40
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
e2etest: adding and cleaning aws disk #188
Conversation
4ac3307
to
699c483
Compare
7effd2f
to
50aa67d
Compare
/test lvm-operator-bundle-e2e-aws |
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.
Added some minor comments. Overall looks good. Need to wait for the CI to pass though.
Mostly the review comments are around the disk count. Also, there are some linting errors that should be fixed.
e2e/disk_setup.go
Outdated
} | ||
|
||
/* | ||
// represents the disk layout to setup on the nodes. |
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.
Looks like this commented code is not needed. You can remove this.
e2e/aws_disk.go
Outdated
|
||
func createAndAttachAWSVolumesForNode(t *testing.T, nodeEntry nodeDisks, ec2Client *ec2.EC2) { | ||
node := nodeEntry.node | ||
if len(nodeEntry.disks) > 20 { |
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.
nodeEntry.disks
count is not a user input and is something that we are setting in the code. So it always be fixed.
So I think there is no need for this check.
e2e/aws_disk.go
Outdated
t.Fatalf("failed to create and attach aws disks for node %q: %+v", nodeEntry.node.Name, err) | ||
} | ||
volumes := make([]*ec2.Volume, len(nodeEntry.disks)) | ||
volumeLetters := []string{"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"} |
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 all these volume letters? I would keep it same as the disk count that we are using.
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.
Kept 2 letters now, as we are creating 2 disks.
e2e/disk_setup.go
Outdated
) | ||
|
||
func diskSetup() func(*testing.T) { | ||
return func(t *testing.T) { |
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.
does this need to be a function inside another function ? For simplicity, I would prefer to keep it a single function if internal function is not needed here.
e2e/disk_setup.go
Outdated
} | ||
|
||
func diskRemoval() func(*testing.T) { | ||
return func(t *testing.T) { |
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.
does this need to be a function inside another function ? For simplicity, I would prefer to keep it a single function if internal function is not needed here.
Thanks for the suggestions Santosh. |
d55c34a
to
3727440
Compare
e2e/disk_setup.go
Outdated
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
func diskSetup(t *testing.T) { |
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 really need a testing.T argument here? It does not match the way the other functions have been written.
Please try to do this without testing.T
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/aws_disk.go
Outdated
volumeIDs := make([]*string, 0) | ||
instanceID, _, zone, err := getAWSNodeInfo(node) | ||
if err != nil { | ||
t.Errorf("failed to create and attach aws disks for node %q: %+v", nodeEntry.node.Name, 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.
This will cause the tests to fail when run against our baremetal clusters.
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.
When would we want to run the e2e tests on baremetal clusters?
Only for testing locally on SNO?
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, the e2e-tests are meant to be run against local clusters when required 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.
Please provide a way to skip the AWS disk setup and delete using command line glags or env variables. This is ensure that the tests do not fail when run against a non-aws cluster.
https://onsi.github.io/ginkgo/#supporting-custom-suite-configuration
e2e/disk_setup.go
Outdated
|
||
// represents the disk layout to setup on the nodes. | ||
var nodeEnv []nodeDisks | ||
for _, disks := range nodeList.Items { |
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.
Why is the node being referred to by a variable called disk?
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 overwrites the entries so only a single node will have disks attached.
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.
Errors should be returned and checked wherever required.
Makefile
Outdated
@@ -315,10 +315,12 @@ lvm-must-gather: | |||
# Variables required to run and build LVM end to end tests. | |||
LVM_OPERATOR_INSTALL ?= true | |||
LVM_OPERATOR_UNINSTALL ?= true | |||
DISK_INSTALL ?= false | |||
DISK_UNINSTALL ?= false |
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.
Not required - if the disk is created, it should be removed.
e2e/aws_disk.go
Outdated
volumeIDs := make([]*string, 0) | ||
instanceID, _, zone, err := getAWSNodeInfo(node) | ||
if err != nil { | ||
fmt.Printf("failed to create and attach aws disks for node %q: %+v\n", nodeEntry.node.Name, 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.
The function should return here.
e2e/aws_disk.go
Outdated
} | ||
} | ||
|
||
func createAndAttachAWSVolumesForNode(nodeEntry nodeDisks, ec2Client *ec2.EC2) { |
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 should return an error.
e2e/aws_disk.go
Outdated
volume, err := ec2Client.CreateVolume(createInput) | ||
if err != nil { | ||
err := fmt.Errorf("expect to create AWS volume with input %v: %w", createInput, err) | ||
fmt.Printf("failed to create and attach aws disks for node %q: %+v\n", nodeEntry.node.Name, 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.
Return on failure. This comment holds for all other errors in the function.
e2e/config.go
Outdated
@@ -33,6 +39,8 @@ func init() { | |||
flag.StringVar(&LvmSubscriptionChannel, "lvm-subscription-channel", "", "The subscription channel to revise updates from") | |||
flag.BoolVar(&lvmOperatorInstall, "lvm-operator-install", true, "Install the LVM operator before starting tests") | |||
flag.BoolVar(&lvmOperatorUninstall, "lvm-operator-uninstall", true, "Uninstall the LVM cluster and operator after test completion") | |||
flag.BoolVar(&DiskInstall, "disk-install", false, "Do not install disks unless specified") | |||
flag.BoolVar(&DiskUninstall, "disk-uninstall", false, "Do not uninstall disks unless specified") |
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.
Not required.
e2e/disk_setup.go
Outdated
|
||
// represents the disk layout to setup on the nodes. | ||
var nodeEnv []nodeDisks | ||
for _, disks := range nodeList.Items { |
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 rename the variable disks. The entry being referred to in the loop is a node.
Makefile
Outdated
@@ -315,10 +315,12 @@ lvm-must-gather: | |||
# Variables required to run and build LVM end to end tests. | |||
LVM_OPERATOR_INSTALL ?= true | |||
LVM_OPERATOR_UNINSTALL ?= true | |||
DISK_INSTALL ?= false |
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.
Add a comment that this only handles AWS for now.
e2e/aws_disk.go
Outdated
} | ||
|
||
const ( | ||
awsPurposeTag = "lvm-e2etest" |
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.
awsPurposeTag = "lvm-e2etest" | |
awsPurposeTag = odf-lvmo" |
e2e/setup_teardown.go
Outdated
|
||
// BeforeTestSuiteSetup is the function called to initialize the test environment. | ||
func BeforeTestSuiteSetup() { | ||
|
||
if DiskInstall { | ||
debug("Creating disk for CI\n") | ||
diskSetup() |
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 should return an error val which should be checked.
/test lvm-operator-bundle-e2e-aws |
Makefile
Outdated
@@ -317,8 +317,11 @@ LVM_OPERATOR_INSTALL ?= true | |||
LVM_OPERATOR_UNINSTALL ?= true | |||
SUBSCRIPTION_CHANNEL ?= alpha | |||
|
|||
# Handles only AWS as of now. | |||
DISK_INSTALL ?= true |
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.
Set this to false by default after confirming that the CI passes with it set to true.
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, I did that for checking purpose only.
e2e/aws_disk.go
Outdated
// this function is async | ||
func createAndAttachAWSVolumes(ec2Client *ec2.EC2, namespace string, nodeEnv []nodeDisks) { | ||
for _, nodeEntry := range nodeEnv { | ||
go createAndAttachAWSVolumesForNode(nodeEntry, ec2Client) |
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.
There needs to be a way to return an error to the calling function. You can skip the goroutine and do this serially for now.
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.
An additional problem here is that the disks may not have been created or attached before the LVMO is deployed.
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, I'll do it serially.
That's right because PVC test is getting passed. Problem is that TopoLVM node pod is not ready, so its failing lvm cluster reconciliation test here.
e2e/setup_teardown.go
Outdated
|
||
// BeforeTestSuiteSetup is the function called to initialize the test environment. | ||
func BeforeTestSuiteSetup() { | ||
|
||
if DiskInstall { | ||
debug("Creating disk for CI\n") |
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.
debug("Creating disk for CI\n") | |
debug("Creating disks for e2e tests\n") |
e2e/disk_setup.go
Outdated
err = cleanupAWSDisks(ec2Client) | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
|
||
return nil |
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.
return nil | |
return err |
e2e/disk_setup.go
Outdated
|
||
// represents the disk layout to setup on the nodes. | ||
var nodeEnv []nodeDisks | ||
for _, nodes := range nodeList.Items { |
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.
for _, nodes := range nodeList.Items { | |
for _, node := range nodeList.Items { |
dad4b48
to
bbb018a
Compare
/retest |
1 similar comment
/retest |
e2e/config.go
Outdated
@@ -33,6 +36,7 @@ func init() { | |||
flag.StringVar(&LvmSubscriptionChannel, "lvm-subscription-channel", "", "The subscription channel to revise updates from") | |||
flag.BoolVar(&lvmOperatorInstall, "lvm-operator-install", true, "Install the LVM operator before starting tests") | |||
flag.BoolVar(&lvmOperatorUninstall, "lvm-operator-uninstall", true, "Uninstall the LVM cluster and operator after test completion") | |||
flag.BoolVar(&DiskInstall, "disk-install", true, "Do not install disks unless specified") |
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.
flag.BoolVar(&DiskInstall, "disk-install", true, "Do not install disks unless specified") | |
flag.BoolVar(&DiskInstall, "disk-install", true, "Create and attach disks to the nodes. This currently only works with AWS") |
e2e/setup_teardown.go
Outdated
@@ -44,4 +52,10 @@ func AfterTestSuiteCleanup() { | |||
err = DeployManagerObj.UninstallLVM(LvmCatalogSourceImage, LvmSubscriptionChannel) | |||
gomega.Expect(err).To(gomega.BeNil(), "error uninstalling LVM: %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.
gomega.Expect(err).To(gomega.BeNil(), "error uninstalling LVM: %v", err) | |
gomega.Expect(err).To(gomega.BeNil(), "error uninstalling the LVM Operator: %v", err) |
e2e/validation.go
Outdated
} | ||
return ds.Status.DesiredNumberScheduled == ds.Status.NumberReady | ||
}, timeout, interval).Should(BeTrue()) | ||
debug("Status is ready\n") |
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.
debug("Status is ready\n") | |
debug("TopolvmNode Status is ready\n") |
/retest |
e2e/aws_disk.go
Outdated
// do not provide more than 20 disksize | ||
// do not use more than once per node | ||
// this function is async | ||
func createAndAttachAWSVolumes(ec2Client *ec2.EC2, namespace string, nodeEnv []nodeDisks) 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.
Looks like the namespace is not required and can be removed.
e2e/disk_setup.go
Outdated
) | ||
|
||
func diskSetup() error { | ||
namespace := TestNamespace |
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.
Looks like the namespace var is not used and can be removed.
e2e/disk_setup.go
Outdated
gomega.SetDefaultEventuallyTimeout(time.Minute * 10) | ||
gomega.SetDefaultEventuallyPollingInterval(time.Second * 2) |
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.
Where is this being used?
adds aws disk in the test namespace for resources to get installed. Signed-off-by: riya-singhal31 <rsinghal@redhat.com>
Thanks @nbalacha for all the optimization suggestions and corrections. |
[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 |
This PR also updates prometheus/client_golang which is required to be backported for https://bugzilla.redhat.com/show_bug.cgi?id=2056104 /cherry-pick release-4.11 |
@iamniting: new pull request created: #209 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
adds aws disk in the test namespace for resources to get installed.
Signed-off-by: riya-singhal31 rsinghal@redhat.com