Skip to content
This repository was archived by the owner on Aug 19, 2019. It is now read-only.

Add test for GetPodAndContainerMetadata#130

Merged
ACEmilG merged 5 commits intomasterfrom
ACEmilG-GetPodAndContainerMetadata-test
Apr 11, 2018
Merged

Add test for GetPodAndContainerMetadata#130
ACEmilG merged 5 commits intomasterfrom
ACEmilG-GetPodAndContainerMetadata-test

Conversation

@ACEmilG
Copy link
Copy Markdown
Contributor

@ACEmilG ACEmilG commented Apr 4, 2018

No description provided.

Comment thread test/kubernetes_unittest.cc Outdated
Configuration config(std::stringstream(
"KubernetesClusterName: TestClusterName\n"
"KubernetesClusterLocation: TestClusterLocation\n"
"MetadataApiResourceTypePerarator: \".\"\n"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix. TypeSeparator?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, fixed.

Comment thread test/kubernetes_unittest.cc Outdated
})},
});

auto metadatas = GetPodAndContainerMetadata(
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to metadata_list

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

Comment thread 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({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metadata1 -> container1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Comment thread 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({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metadata2 -> container2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

@igorpeshansky igorpeshansky self-requested a review April 5, 2018 03:59
Comment thread test/kubernetes_unittest.cc Outdated
"KubernetesClusterName: TestClusterName\n"
"KubernetesClusterLocation: TestClusterLocation\n"
"MetadataApiResourceTypePerarator: \",\"\n"
"MetadataApiResourceTypeSeperator: \",\"\n"
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, sorry about that

Comment thread 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]);
Copy link
Copy Markdown
Contributor

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());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread 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]);
Copy link
Copy Markdown
Contributor

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());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread 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({
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Contributor

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)?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

@igorpeshansky igorpeshansky left a 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...

Comment thread 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({
Copy link
Copy Markdown
Contributor

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)?

Copy link
Copy Markdown
Contributor

@igorpeshansky igorpeshansky left a 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.

Comment thread test/kubernetes_unittest.cc Outdated
"KubernetesClusterName: TestClusterName\n"
"KubernetesClusterLocation: TestClusterLocation\n"
"MetadataApiResourceTypePerarator: \",\"\n"
"MetadataApiResourceTypeSeperator: \",\"\n"
Copy link
Copy Markdown
Contributor

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.

Comment thread 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({
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

@igorpeshansky igorpeshansky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more.

Comment thread test/kubernetes_unittest.cc Outdated
is_deleted);
}

std::vector<MetadataUpdater::ResourceMetadata> GetPodAndContainerMetadata(
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Contributor

@igorpeshansky igorpeshansky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :shipit:

Copy link
Copy Markdown
Contributor

@supriyagarg supriyagarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ACEmilG ACEmilG merged commit c17e8de into master Apr 11, 2018
@ACEmilG ACEmilG deleted the ACEmilG-GetPodAndContainerMetadata-test branch April 11, 2018 12:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants