-
Notifications
You must be signed in to change notification settings - Fork 78
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
Ko 461 nodeport service v2 #177
Changes from all commits
0032058
177ebd0
f714499
cd34088
111a036
88765b2
bb2c9d4
12729e4
2c0e453
9e91c5c
7bccdff
9cb1852
15004dd
50bc3e5
8848f81
380e7d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,7 +214,6 @@ func (ns *NsWrapper) WaitForOutputContainsAndLog(description string, kcmd kubect | |
Expect(execErr).ToNot(HaveOccurred()) | ||
} | ||
|
||
|
||
func (ns *NsWrapper) WaitForDatacenterCondition(dcName string, conditionType string, value string) { | ||
step := fmt.Sprintf("checking that dc condition %s has value %s", conditionType, value) | ||
json := fmt.Sprintf("jsonpath={.status.conditions[?(.type=='%s')].status}", conditionType) | ||
|
@@ -223,7 +222,6 @@ func (ns *NsWrapper) WaitForDatacenterCondition(dcName string, conditionType str | |
ns.WaitForOutputAndLog(step, k, value, 600) | ||
} | ||
|
||
|
||
func (ns *NsWrapper) WaitForDatacenterToHaveNoPods(dcName string) { | ||
step := "checking that no dc pods remain" | ||
json := "jsonpath={.items}" | ||
|
@@ -369,3 +367,27 @@ func (ns NsWrapper) HelmInstall(chartPath string) { | |
err := helm_util.Install(chartPath, "cass-operator", ns.Namespace, overrides) | ||
mageutil.PanicOnError(err) | ||
} | ||
|
||
// Note that the actual value will be cast to a string before the comparison with the expectedValue | ||
func (ns NsWrapper) ExpectKeyValue(m map[string]interface{}, key string, expectedValue string) { | ||
actualValue, ok := m[key].(string) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand the intent of this code correctly, I don't think it works the way you expect. Floats, ints, etc. cannot be cast to strings in this manner: https://play.golang.org/p/lIg2pmmYczZ You would have to parse them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This tries to interpret the value as a string. If that was possible, then ok is set to true. If that was not possible, for instance, the value was a float64, then ok is set to false. |
||
if !ok { | ||
// Note: floats will end up as strings with six decimal points | ||
// example: "12.000000" | ||
tryFloat64, ok := m[key].(float64) | ||
if !ok { | ||
msg := fmt.Sprintf("Actual value for key %s is not expected type", key) | ||
err := fmt.Errorf(msg) | ||
Expect(err).ToNot(HaveOccurred()) | ||
} | ||
actualValue = fmt.Sprintf("%f", tryFloat64) | ||
} | ||
Expect(actualValue).To(Equal(expectedValue), "Expected %s %s to be %s", key, m[key], expectedValue) | ||
} | ||
|
||
// Compare all key/values from an expected map to an actual map | ||
func (ns NsWrapper) ExpectKeyValues(actual map[string]interface{}, expected map[string]string) { | ||
for key := range expected { | ||
ns.ExpectKeyValue(actual, key, expected[key]) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
ExpectKeyValues(), which takes a whole map, and the helper function ExpectKeyValue() are a first-pass at a generic way to validate key/values. Right now everything is cast to a string. I added a helper for dealing with Float64 values because the Ports from the service were coming back as Float64s for some reason. I am open to suggestion for improvements, but we may want to handle them in a follow-up ticket.