-
Notifications
You must be signed in to change notification settings - Fork 11
Add test for GetPodAndContainerMetadata #130
Conversation
test/kubernetes_unittest.cc
Outdated
| Configuration config(std::stringstream( | ||
| "KubernetesClusterName: TestClusterName\n" | ||
| "KubernetesClusterLocation: TestClusterLocation\n" | ||
| "MetadataApiResourceTypePerarator: \".\"\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.
Please fix. TypeSeparator?
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.
Sorry, fixed.
test/kubernetes_unittest.cc
Outdated
| })}, | ||
| }); | ||
|
|
||
| auto metadatas = GetPodAndContainerMetadata( |
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 not m like in other places.
If you want plural, then metadata_list or something is better.
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 to metadata_list
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.
Frankly, I prefer m for brevity. Any reason to not go with that? As @supriyagarg mentioned, this is a convention in other tests.
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 guess I have a strong aversion to single-letter variable names. Changed.
test/kubernetes_unittest.cc
Outdated
| EXPECT_EQ(time::rfc3339::FromString("2018-03-03T01:23:45.678901234Z"), | ||
| metadatas[1].metadata().created_at); | ||
| EXPECT_EQ(Timestamp(), metadatas[1].metadata().collected_at); | ||
| json::value metadata1 = 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.
metadata1 -> container1
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
| EXPECT_EQ(time::rfc3339::FromString("2018-03-03T01:23:45.678901234Z"), | ||
| metadatas[2].metadata().created_at); | ||
| EXPECT_EQ(Timestamp(), metadatas[2].metadata().collected_at); | ||
| json::value metadata2 = 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.
metadata2 -> container2
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
| "KubernetesClusterName: TestClusterName\n" | ||
| "KubernetesClusterLocation: TestClusterLocation\n" | ||
| "MetadataApiResourceTypePerarator: \",\"\n" | ||
| "MetadataApiResourceTypeSeperator: \",\"\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.
Make that MetadataApiResourceTypeSeparator (here and below).
Sigh, the config revamp in #127 would allow catching invalid config options.
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 needs to be fixed.
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, sorry about that
test/kubernetes_unittest.cc
Outdated
| EXPECT_EQ("gke_container.TestNamespace.TestPodUid.TestContainerName0", | ||
| metadata_list[0].ids()[0]); | ||
| EXPECT_EQ("gke_container.TestNamespace.TestPodName.TestContainerName0", | ||
| metadata_list[0].ids()[1]); |
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.
EXPECT_EQ(std::vector<std::string>{
"gke_container.TestNamespace.TestPodUid.TestContainerName0",
"gke_container.TestNamespace.TestPodName.TestContainerName0",
}, metadata_list[0].ids());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
| EXPECT_EQ("k8s_container.TestPodUid.TestContainerName0", | ||
| metadata_list[1].ids()[0]); | ||
| EXPECT_EQ("k8s_container.TestNamespace.TestPodName.TestContainerName0", | ||
| metadata_list[1].ids()[1]); |
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.
EXPECT_EQ(std::vector<std::string>{
"k8s_container.TestPodUid.TestContainerName0",
"k8s_container.TestNamespace.TestPodName.TestContainerName0",
}, metadata_list[1].ids());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
| EXPECT_EQ(time::rfc3339::FromString("2018-03-03T01:23:45.678901234Z"), | ||
| metadata_list[2].metadata().created_at); | ||
| EXPECT_EQ(Timestamp(), metadata_list[2].metadata().collected_at); | ||
| json::value container2 = 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.
Should this not be pod metadata?
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
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 actually meant that this looks like container metadata (with the "metadata", "spec", and "status" fields). Should this not be pod metadata (with one "api" field)?
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.
Hmm, well reading the code, it does seem to me that a pod should be played at the end of the metadata list. Truthfully, I had a hard time following all the code paths closely, so its difficult for me to evaluate whether this is an actual bug.
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, silly me. This is pod metadata. I miscounted the nesting depth. Never mind.
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.
There's one more comment about the typo in the option name...
test/kubernetes_unittest.cc
Outdated
| EXPECT_EQ(time::rfc3339::FromString("2018-03-03T01:23:45.678901234Z"), | ||
| metadata_list[2].metadata().created_at); | ||
| EXPECT_EQ(Timestamp(), metadata_list[2].metadata().collected_at); | ||
| json::value container2 = 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 actually meant that this looks like container metadata (with the "metadata", "spec", and "status" fields). Should this not be pod metadata (with one "api" field)?
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 remaining rename that still needs to happen.
test/kubernetes_unittest.cc
Outdated
| "KubernetesClusterName: TestClusterName\n" | ||
| "KubernetesClusterLocation: TestClusterLocation\n" | ||
| "MetadataApiResourceTypePerarator: \",\"\n" | ||
| "MetadataApiResourceTypeSeperator: \",\"\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.
This still needs to be fixed.
test/kubernetes_unittest.cc
Outdated
| EXPECT_EQ(time::rfc3339::FromString("2018-03-03T01:23:45.678901234Z"), | ||
| metadata_list[2].metadata().created_at); | ||
| EXPECT_EQ(Timestamp(), metadata_list[2].metadata().collected_at); | ||
| json::value container2 = 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.
Oh, silly me. This is pod metadata. I miscounted the nesting depth. Never mind.
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.
test/kubernetes_unittest.cc
Outdated
| is_deleted); | ||
| } | ||
|
|
||
| std::vector<MetadataUpdater::ResourceMetadata> GetPodAndContainerMetadata( |
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.
Any reason these accessors are not static?
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.
LGTM ![]()
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
No description provided.