Skip to content
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

bootstrap script should be executed on the host agent #41

Merged
merged 13 commits into from
Jul 26, 2021

Conversation

huchen2021
Copy link
Contributor

Signed-off-by: chen hui [email protected]

agent/cloudinit/cloudinit.go Outdated Show resolved Hide resolved
agent/cloudinit/cloudinit_test.go Outdated Show resolved Hide resolved
agent/cloudinit/cmd_runner.go Show resolved Hide resolved
agent/cloudinit/file_writer.go Outdated Show resolved Hide resolved
agent/cloudinit/file_writer_test.go Outdated Show resolved Hide resolved
agent/reconciler/host_reconciler.go Show resolved Hide resolved
agent/reconciler/host_reconciler.go Show resolved Hide resolved
agent/host_agent_test.go Outdated Show resolved Hide resolved
Signed-off-by: chen hui <[email protected]>
agent/cloudinit/cloudinit.go Outdated Show resolved Hide resolved
agent/cloudinit/cloudinit.go Outdated Show resolved Hide resolved
agent/cloudinit/cloudinit_test.go Show resolved Hide resolved
agent/cloudinit/cloudinitfakes/fake_ifile_writer.go Outdated Show resolved Hide resolved
agent/cloudinit/cloudinit_test.go Outdated Show resolved Hide resolved
agent/cloudinit/cmd_runner.go Show resolved Hide resolved
agent/cloudinit/file_writer.go Outdated Show resolved Hide resolved
agent/cloudinit/file_writer.go Outdated Show resolved Hide resolved
agent/cloudinit/file_writer.go Outdated Show resolved Hide resolved
Signed-off-by: Hui Chen <[email protected]>
chen hui added 3 commits July 21, 2021 03:28
Signed-off-by: chen hui <[email protected]>
Signed-off-by: chen hui <[email protected]>
@@ -53,14 +58,14 @@ var _ = Describe("Agent", func() {
command := exec.Command(pathToHostAgentBinary, "--kubeconfig", kubeconfigFile.Name(), "--namespace", ns.Name)
session, err = gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).ToNot(HaveOccurred())
Eventually(session).Should(gexec.Exit(255))
Eventually(session).Should(gexec.Exit(0))
Copy link
Contributor

Choose a reason for hiding this comment

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

The It description says it should error out, then why Exit(0)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's because I changed all klog.Fatal to "klog.Errorf and return"(comment from jamie).

Copy link
Contributor

Choose a reason for hiding this comment

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

Then should we assert on error message? To someone reading the test, this is confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no way to assert error message, since main function return no argument.

})

It("should return an error when invalid kubeconfig is passed in", func() {
command := exec.Command(pathToHostAgentBinary, "--kubeconfig", fakedKubeConfig)
session, err = gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).ToNot(HaveOccurred())
Eventually(session).Should(gexec.Exit(255))
Eventually(session).Should(gexec.Exit(0))
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's because I changed all klog.Fatal to "klog.Errorf and return"(comment from jamie).

@@ -110,28 +115,65 @@ var _ = Describe("Agent", func() {
})

It("should bootstrap the node when MachineRef is set", func() {

Copy link
Contributor

Choose a reason for hiding this comment

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

For this particular test case, only one file is sufficient. Don't you think?
Asking because the test is for asserting if the node is bootstrapped when MachineRef is set, it should not matter if there are different flavors / combinations of cloudinit configs or not

Copy link
Contributor Author

@huchen2021 huchen2021 Jul 23, 2021

Choose a reason for hiding this comment

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

It can't test different scenarios on one file:
file1: Don't specify permissions+append, to see if the function works.
file2: Specify permissions+append, to see if the function works.
file3: Specify encoding in base64 way, to see if it can decoded in base64 way.
file4: Specify encoding in gzip+base64 way, to see if it can decoded in gzip+base64 way.

This is integration test of this story, to make sure the code is ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

I remember commenting earlier to combine certain test cases. I'm not sure if this is one of those. Apologies for that.
So I see two parts here -

  1. Whenever a MachineRef is set on the ByoHost, the node should be bootstrapped (here we are hoping cloudinit will pass through - so maybe don't care for different scenarios for that)
  2. Different scenarios for cloudinit itself - this feels more of multiple unit tests instead of testing all in one integration test

Thoughts? @huchen2021 @jamiemonserrate

Copy link
Contributor Author

@huchen2021 huchen2021 Jul 23, 2021

Choose a reason for hiding this comment

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

@anusha94 It was two It blocks, you suggested to combine it. So I combine it, and put it in different files.
I think it's no big deal about whether it is one block, or two blocks, as long as the code are all covered by test case.

agent/main.go Outdated Show resolved Hide resolved
agent/main.go Outdated Show resolved Hide resolved
agent/main.go Outdated Show resolved Hide resolved
agent/reconciler/host_reconciler.go Outdated Show resolved Hide resolved
agent/reconciler/host_reconciler.go Outdated Show resolved Hide resolved
agent/reconciler/host_reconciler.go Outdated Show resolved Hide resolved
agent/reconciler/host_reconciler.go Outdated Show resolved Hide resolved
@huchen2021 huchen2021 requested a review from anusha94 July 23, 2021 01:45
@huchen2021 huchen2021 merged commit 3d8df56 into vmware-tanzu:main Jul 26, 2021
jamiemonserrate pushed a commit that referenced this pull request Oct 20, 2021
bootstrap script should be executed on the host agent
@jamiemonserrate jamiemonserrate changed the title TKG-5917 bootstrap script should be executed on the host agent bootstrap script should be executed on the host agent Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants