-
Notifications
You must be signed in to change notification settings - Fork 11
Conversation
test/kubernetes_unittest.cc
Outdated
| } | ||
|
|
||
| json::value ComputePodAssociations(const json::Object* pod, | ||
| const KubernetesReader& reader) { |
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.
Indentation. Want to switch your editor config to expand tabs to spaces? Also below.
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.
Fixed all over
| "InstanceId: TestID\n" | ||
| )); | ||
| Environment environment(config); | ||
| KubernetesReader reader(config, nullptr); // Don't need HealthChecker. |
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 statement in the comment is kind of obvious from you setting it to nullptr, but if you choose to keep it, please update the other place where you do the same.
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 should already be commented in all other locations.
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 seems to be the only place, FWIW.
test/kubernetes_unittest.cc
Outdated
| Environment environment(config); | ||
| KubernetesReader reader(config, nullptr); // Don't need HealthChecker. | ||
| const std::string encoded_ref = boost::algorithm::join( | ||
| std::vector<std::string>{api_version, kind, uid1}, "/"); |
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.
Let's avoid this kind of logic in tests. Anything more complicated than "the same string goes in and out" is probably not worth the readability hit. Just use literal strings.
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.
Agreed, done.
test/kubernetes_unittest.cc
Outdated
| return reader.ComputePodAssociations(pod); | ||
| } | ||
|
|
||
| void InsertIntoOwners(const std::string& key, json::value& value, |
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.
UpdateOwnersCache.
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
test/kubernetes_unittest.cc
Outdated
| const std::string encoded_ref = boost::algorithm::join( | ||
| std::vector<std::string>{api_version, kind, uid1}, "/"); | ||
| json::value controller = json::object({ | ||
| {"controller", json::boolean(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.
2-space indent, please.
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.
Fixed
test/kubernetes_unittest.cc
Outdated
| })}, | ||
| }); | ||
|
|
||
| auto associations = ComputePodAssociations(pod->As<json::Object>(), reader); |
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.
const auto
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.
Fixed
test/kubernetes_unittest.cc
Outdated
|
|
||
| auto associations = ComputePodAssociations(pod->As<json::Object>(), reader); | ||
|
|
||
| EXPECT_EQ(associations->ToString(), json::object({ |
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 would suggest pulling this json::object out into an expected_associations local.
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
test/kubernetes_unittest.cc
Outdated
|
|
||
| auto associations = ComputePodAssociations(pod->As<json::Object>(), reader); | ||
|
|
||
| EXPECT_EQ(associations->ToString(), json::object({ |
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.
Let's stick with the EXPECT_EQ(expected, actual) parameter order throughout.
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.
Fixed
igorpeshansky
left a comment
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 minor formatting nit.
| "InstanceId: TestID\n" | ||
| )); | ||
| Environment environment(config); | ||
| KubernetesReader reader(config, nullptr); // Don't need HealthChecker. |
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 seems to be the only place, FWIW.
test/kubernetes_unittest.cc
Outdated
| })}, | ||
| {"version", json::string("TestVersion")}, | ||
| }); | ||
| const auto associations = ComputePodAssociations(pod->As<json::Object>(), reader); |
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.
Let's stay within 80 characters. I'd break after the =, personally...
igorpeshansky
left a comment
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 nits.
test/kubernetes_unittest.cc
Outdated
| return reader.GetNodeMetadata(node, collected_at, is_deleted); | ||
| } | ||
|
|
||
| json::value ComputePodAssociations(const json::Object* pod, |
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.
Just noticed — let's make reader the first argument, both here and in UpdateOwnersCache.
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
test/kubernetes_unittest.cc
Outdated
| return reader.ComputePodAssociations(pod); | ||
| } | ||
|
|
||
| void UpdateOwnersCache(const std::string& key, json::value& value, |
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.
const json::value& value.
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
test/kubernetes_unittest.cc
Outdated
| } | ||
|
|
||
| TEST_F(KubernetesTest, ComputePodAssociations) { | ||
| const std::string api_version = "1.2.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.
Let's inline these as well and get rid of the local 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.
Done
test/kubernetes_unittest.cc
Outdated
| {"infrastructureResource", json::object({ | ||
| {"labels", json::object({ | ||
| {"instance_id", json::string("TestID")}, | ||
| {"zone", json::string("TestZone")} |
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.
Let's keep the trailing comma.
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.
Inserted.
igorpeshansky
left a comment
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 more tiny cleanup.
test/kubernetes_unittest.cc
Outdated
| )); | ||
| Environment environment(config); | ||
| KubernetesReader reader(config, nullptr); // Don't need HealthChecker. | ||
| const std::string encoded_ref = "1.2.3/TestKind/TestUID1"; |
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.
Let's move this to just before the call to UpdateOwnersCache. Or, better yet, just inline the value into the call.
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.
Inlined
| Environment environment(config); | ||
| KubernetesReader reader(config, nullptr); // Don't need HealthChecker. | ||
| const std::string encoded_ref = "1.2.3/TestKind/TestUID1"; | ||
| json::value controller = json::object({ |
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.
Let's just inline the json::object() call into the UpdateOwnersCache call.
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.
Inlined.
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.
Actually: we use controller in another location, and thus I think its better to keep as a variable.
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.
Ah, you're right, but then let's use std::move(controller) instead of controller->Clone() below (no point in making gratuitous copies).
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.
Just pushed a commit with a fix.
| Environment environment(config); | ||
| KubernetesReader reader(config, nullptr); // Don't need HealthChecker. | ||
| const std::string encoded_ref = "1.2.3/TestKind/TestUID1"; | ||
| json::value controller = json::object({ |
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.
Ah, you're right, but then let's use std::move(controller) instead of controller->Clone() below (no point in making gratuitous copies).
supriyagarg
left a comment
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
igorpeshansky
left a comment
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 ![]()
| Environment environment(config); | ||
| KubernetesReader reader(config, nullptr); // Don't need HealthChecker. | ||
| const std::string encoded_ref = "1.2.3/TestKind/TestUID1"; | ||
| json::value controller = json::object({ |
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.
Just pushed a commit with a fix.
No description provided.