-
Notifications
You must be signed in to change notification settings - Fork 95
Test to delete vm from its vmgroup and few dependent utils #1483
Test to delete vm from its vmgroup and few dependent utils #1483
Conversation
// 4. Again execute vmgroup ls command to verify command works fine. | ||
func (s *vgBasicSuite) TestDeleteVMFromVmgroup(c *C) { | ||
misc.LogTestStart(c.TestName()) | ||
vmName := "VM_" + inputparams.GetRandomNumber() |
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 do you want to create a new vmgroup here? Why not using existing vmgroup "vmGroupName"?
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.
@lipingxue Because of issue #1484, I am creating a separate tenant else verifications in other tests will start failing. For remaining tests in the same file, I am creating vmgroup once in the SetUpSuite()
tests/e2e/vmgroupmisc_test.go
Outdated
vgName := "VG_" + inputparams.GetRandomNumber() | ||
|
||
// Create a vm - we need this to add to vmgroup and later on delete this vm | ||
esx.CreateVM(vmName, s.config.Datastores[0]) |
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.
Should check the out and err returned by function "esx.CreateVM".
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.
@lipingxue We are already doing it in InvokeCommandLocally()
https://github.com/vmware/docker-volume-vsphere/blob/master/tests/utils/ssh/ssh.go#L50
tests/e2e/vmgroupmisc_test.go
Outdated
// Create a vm - we need this to add to vmgroup and later on delete this vm | ||
esx.CreateVM(vmName, s.config.Datastores[0]) | ||
|
||
admincli.CreateVMgroup(s.config.EsxHost, vgName, vmName, admincliconst.VMHomeDatastore) |
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 add assert to make sure no error is returned from "CreateVMgroup".
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
tests/e2e/vmgroupmisc_test.go
Outdated
admincli.CreateVMgroup(s.config.EsxHost, vgName, vmName, admincliconst.VMHomeDatastore) | ||
// Verify if vmgroup exists | ||
isVmgroupAvailable := admincli.IsVmgroupPresent(s.config.EsxHost, vgName) | ||
c.Assert(isVmgroupAvailable, Equals, true, Commentf("vmgroup ls command does not lists the vmgroup %s .", vgName)) |
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.
Change "vmgroup ls command does not lists the vmgroup %s ." to "Vmgroup %s dose not exist."
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
c.Assert(isVMPartofVg, Equals, true, Commentf("VM %s does not belong to vmgroup %s .", vmName, vgName)) | ||
|
||
// Destroy the vm | ||
esx.DestroyVM(vmName) |
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.
Check the out and error returned from DestroyVM.
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.
+1 .. atleast validate VM is no more present.
tests/e2e/vmgroupmisc_test.go
Outdated
|
||
// Destroy the vm | ||
esx.DestroyVM(vmName) | ||
misc.SleepForSec(3) |
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 the sleep is needed? Please add comments for that.
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.
ok
tests/e2e/vmgroupmisc_test.go
Outdated
|
||
// Check vmgroup ls | ||
isVmgroupAvailable = admincli.IsVmgroupPresent(s.config.EsxHost, vgName) | ||
c.Assert(isVmgroupAvailable, Equals, true, Commentf("vmgroup ls command does not lists the vmgroup %s .", vgName)) |
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.
Same comments as above.
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
tests/utils/esx/govc.go
Outdated
// CreateVM creates a vm on the specified ds and esx | ||
func CreateVM(vmName, datastore string) string { | ||
log.Printf("Creating a vm [%s] \n", vmName) | ||
cmd := esx.VMCreate + datastore + " -on=false -link=false -net.adapter=vmxnet3 " + vmName |
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 always use "-net.adapter=vmxnet3"?
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.
Changed into a parameter to be passed to 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.
LGTM!
tests/e2e/vmgroupmisc_test.go
Outdated
vgName := "VG_" + inputparams.GetRandomNumber() | ||
|
||
// Create a vm - we need this to add to vmgroup and later on delete this vm | ||
esx.CreateVM(vmName, s.config.Datastores[0]) |
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.
minor: can we atleast validate vm is created or not? (helps in debugging failure)
c.Assert(isVMPartofVg, Equals, true, Commentf("VM %s does not belong to vmgroup %s .", vmName, vgName)) | ||
|
||
// Destroy the vm | ||
esx.DestroyVM(vmName) |
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.
+1 .. atleast validate VM is no more present.
func DestroyVM(vmName string) string { | ||
log.Printf("Deleting a vm - %s \n", vmName) | ||
cmd := esx.VMDestroy + vmName | ||
return ssh.InvokeCommandLocally(cmd) |
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.
minor: command can be simply moved here.
tests/e2e/vmgroupmisc_test.go
Outdated
// Check vmgroup ls | ||
isVmgroupAvailable = admincli.IsVmgroupPresent(s.config.EsxHost, vgName) | ||
c.Assert(isVmgroupAvailable, Equals, true, Commentf("vmgroup ls command does not lists the vmgroup %s .", vgName)) | ||
|
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.
It is better to add TODO here saying .. due to product behavior vmgroup deletion is not possible and add the reference of the issue here .. if there is any issue otherwise please raise one and add its reference here.
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.
LGTM! Please address minor comments before merging.
tests/utils/esx/govc.go
Outdated
log.Printf("Verifying if vm - %s exists \n", vmName) | ||
listVMs := " /ha-datacenter/vm" | ||
cmd := esx.LsOption + listVMs | ||
vmList := ssh.InvokeCommandLocally(cmd) |
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.
minor: need to combine 94-96.
tests/e2e/vmgroupmisc_test.go
Outdated
esx.DestroyVM(vmName) | ||
|
||
// Added the sleep before next step as deletion may take time to finish completely. | ||
misc.SleepForSec(3) |
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.
it is better to use polling mechanism here instead 3 seconds ..
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
tests/constants/esx/govc.go
Outdated
VMDestroy = govcCmd + "vm.destroy " | ||
|
||
// LsOption refers to govc ls | ||
LsOption = govcCmd + "ls " |
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.
could have created ListVMs as an exported variable.
f3bb9c9
to
03791aa
Compare
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.
One general comment, after you addressed comments, please don't squash before you push. I would like o see only the delta between the current code and my last review.
c.Assert(isVMPartofVg, Equals, true, Commentf("VM %s does not belong to vmgroup %s .", vmName, vgName)) | ||
|
||
// Destroy the vm | ||
esx.DestroyVM(vmName) |
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 still not address. You don't check the out and error returned from DestroyVM
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.
govc does not returns error code. I wrote a util to check if vm exists. That I am using after creating a vm as well as after destroying vm.
03791aa
to
b64b05c
Compare
This PR covers following things:
Test steps:
Tested it locally. All test test-esx passed