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
Bug 1827603: vSphere - Unit tests for zone and regions #569
Bug 1827603: vSphere - Unit tests for zone and regions #569
Conversation
|
||
func TestGetVSphereConfig(t *testing.T) { | ||
testConfig := ` | ||
[Labels] |
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 this a leftover bit or something? i don't recognize the syntax 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.
That's INI config, that comes from cloud cloud-provider-config
config map. Had to learn that too :)
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.
oh, interesting, guess i need to learn it as well XD
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.
Who chose INI XD
i will defer to others on the vsphere specifics, but in general this looks good to me |
@alexander-demichev: This pull request references Bugzilla bug 1827603, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
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. |
/retest |
createAndAttachTag := func(tagName, categoryName string) { | ||
if err := session.WithRestClient(context.TODO(), func(c *rest.Client) error { | ||
tagsMgr := tags.NewManager(c) | ||
|
||
categoryID, err := tagsMgr.CreateCategory(context.TODO(), &tags.Category{ | ||
AssociableTypes: []string{"VirtualMachine"}, | ||
Cardinality: "SINGLE", | ||
Name: categoryName, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
tagID, err := tagsMgr.CreateTag(context.TODO(), &tags.Tag{ | ||
CategoryID: categoryID, | ||
Name: tagName, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = tagsMgr.AttachTag(context.TODO(), tagID, vmObj.Reference()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}); err != nil { | ||
t.Fatal(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.
I feel like I've seen this before in another PR, could this be a proper function rather than an anonymous one that multiple tests could use?
} | ||
|
||
if regionName != labels[machinecontroller.MachineRegionLabelName] { | ||
t.Errorf("Expected region name: %s, got: %s", zoneName, labels[machinecontroller.MachineRegionLabelName]) |
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.
Typo?
t.Errorf("Expected region name: %s, got: %s", zoneName, labels[machinecontroller.MachineRegionLabelName]) | |
t.Errorf("Expected region name: %s, got: %s", regionName, labels[machinecontroller.MachineRegionLabelName]) |
|
||
func TestGetVSphereConfig(t *testing.T) { | ||
testConfig := ` | ||
[Labels] |
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.
Who chose INI XD
pkg/controller/vsphere/util_test.go
Outdated
if vSphereConfig.Labels.Region != "testRegion" { | ||
t.Errorf("Expected region %s, got %s", "testRegion", vSphereConfig.Labels.Region) | ||
} | ||
|
||
if vSphereConfig.Labels.Zone != "testZone" { | ||
t.Errorf("Expected zone %s, got %s", "testZone", vSphereConfig.Labels.Zone) | ||
} |
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.
Maybe put testZone
and testRegion
into consts?
7a47bd0
to
188911d
Compare
thanks for this! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: enxebre 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 |
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
} | ||
} | ||
|
||
func createTagAndCategory(session *session.Session, categoryName, tagName 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.
Thanks for doing this 👍
/retest Please review the full test history for this PR and help us cut down flakes. |
10 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
5 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/hold |
188911d
to
8e1a42a
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.
/lgtm
/hold cancel |
/retest Please review the full test history for this PR and help us cut down flakes. |
8 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@alexander-demichev: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@alexander-demichev: All pull requests linked via external trackers have merged: openshift/machine-api-operator#569. Bugzilla bug 1827603 has been moved to the MODIFIED state. 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. |
This PR adds unit tests for zone and regions in vSphere. Regions and zones are not always present on the machine, this depends on vSphere configuration but we can lower risks of an error on our side and make sure we set them properly.