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

testing: sonobuoy plugin for e2e testing #26

Merged
merged 2 commits into from
Feb 10, 2020

Conversation

dweomer
Copy link
Contributor

@dweomer dweomer commented Feb 8, 2020

  • includes removal of controller serviceAccountName references and envvar
  • image tarballs a la docker save are added to dist/artifacts
  • sonobuoy plugin yaml added to dist/artifacts
  • introduces e2e-tests tag suffix image that can be used for the sonobuoy plugin

@dweomer dweomer force-pushed the testing/sonobuoy branch 3 times, most recently from a813d31 to 1e3c594 Compare February 8, 2020 21:47
upgradeapiv1 "github.com/rancher/system-upgrade-controller/pkg/apis/upgrade.cattle.io/v1"
)

var _ = Describe("Upgrade", func() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

everything else in this commit exists to run these three simple tests. will add more once this lands on master

Comment on lines +12 to +27
When("plan missing channel and version", func() {
var (
err error
plan = e2e.NewPlan("unresolvable-", "", nil)
)
BeforeEach(func() {
plan, err = e2e.CreatePlan(plan)
Expect(err).ToNot(HaveOccurred())

plan, err = e2e.PollPlanCondition(plan.Name, upgradeapiv1.PlanLatestResolved, 2*time.Second, 30*time.Second)
Expect(err).ToNot(HaveOccurred())
})
It("should not resolve", func() {
Expect(upgradeapiv1.PlanLatestResolved.MatchesError(plan, "Error", upgradeapiv1.ErrPlanUnresolvable)).To(BeTrue())
})
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test for unresolavable plan

Comment on lines +28 to +46
When("plan has version", func() {
var (
err error
plan = e2e.NewPlan("resolve-version-", "", nil)
)
BeforeEach(func() {
plan.Spec.Version = "test"

plan, err = e2e.CreatePlan(plan)
Expect(err).ToNot(HaveOccurred())

plan, err = e2e.PollPlanCondition(plan.Name, upgradeapiv1.PlanLatestResolved, 2*time.Second, 30*time.Second)
Expect(err).ToNot(HaveOccurred())
})
It("should resolve", func() {
Expect(upgradeapiv1.PlanLatestResolved.IsTrue(plan)).To(BeTrue())
Expect(upgradeapiv1.PlanLatestResolved.GetReason(plan)).To(Equal("Version"))
})
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

assert that a plan with a version resolves

Comment on lines +47 to +67
When("plan has channel", func() {
var (
err error
plan = e2e.NewPlan("resolve-channel-", "", nil)
)
BeforeEach(func() {
plan.Spec.Channel = e2e.ChannelServerURL()
Expect(plan.Spec.Channel).ToNot(BeEmpty())

plan, err = e2e.CreatePlan(plan)
Expect(err).ToNot(HaveOccurred())

plan, err = e2e.PollPlanCondition(plan.Name, upgradeapiv1.PlanLatestResolved, 2*time.Second, 30*time.Second)
Expect(err).ToNot(HaveOccurred())
})
It("should resolve", func() {
Expect(upgradeapiv1.PlanLatestResolved.IsTrue(plan)).To(BeTrue())
Expect(upgradeapiv1.PlanLatestResolved.GetReason(plan)).To(Equal("Channel"))
})
})
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

assert that a plan with a channel resolves

hostname: local-leader
privileged: true
ports:
- "172.17.0.1:6443:6443" # k3s

Choose a reason for hiding this comment

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

Will the address be always 172.17.0.1 for the host (dapper container i assume?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the default for docker0. This worked for me on a linux box, my mac, and it passed drone so that's good enough for me for now. I do agree that this should be more flexible in the future but I just wanted to get it off my plate.

context: ./images/k3s/.
args:
- ARCH=${ARCH}
command: server --no-deploy=traefik,metrics-server

Choose a reason for hiding this comment

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

Can we use disable here instead of no-deploy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

--disable doesn't yet seem to be available in a release

Choose a reason for hiding this comment

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

got it


services:

leader:

Choose a reason for hiding this comment

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

nit: I think server/agent nomenclature is more accurate than leader/worker

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO these are too generic for this purpose.

@@ -0,0 +1,29 @@
# Install the all-in-one binary so we can copy our run-time images into the image

Choose a reason for hiding this comment

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

Is there a reason you are not using the official Image directly in the docker-compose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I tried to capture in this comment. I have to recreate a k3s image because the official image declares /var/lib/rancher as a VOLUME which means subsequent additions to that area will never show up in an image. If, however, in a Dockerfile you copy content into a location and then declare it a VOLUME afterwards and then run the image with an non-bind mount volume at that location, docker will by default at first-run copy the contents from the image into the volume. This is the trick that I am leveraging.

Choose a reason for hiding this comment

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

I see, thanks for clarification

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other reason I need to re-create a k3s image is because I want the tests to run locally without the need to pull anything which means I need the images tarballs in the k3s image. Doing that via docker-compose within Dapper is problematic because the docker daemon it is using does not have the same filesystem root that the host does which means bind mounts are hopeless.

@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -e

Choose a reason for hiding this comment

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

nit: maybe a DEBUG variable can be useful here to give more visibility with -x for example

from_secret: docker_password
platforms:
- linux/amd64
- linux/arm64

Choose a reason for hiding this comment

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

Is there a reason arm is not included here?

Copy link
Contributor Author

@dweomer dweomer Feb 10, 2020

Choose a reason for hiding this comment

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

there is currently no sonobuoy client built for arm therefore pushing an arm image isn't necessary right now

Copy link

@galal-hussein galal-hussein left a comment

Choose a reason for hiding this comment

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

@dweomer explained the questions/comments that I had, LGTM. thanks 👍

- includes removal of controller serviceAccountName references and envvar
- image tarballs a la `docker save` are added to dist/artifacts
- sonobuoy plugin yaml added to dist/artifacts
- introduces e2e-tests tag suffix image that can be used for the sonobuoy plugin
@dweomer dweomer merged commit 7d30ba4 into rancher:master Feb 10, 2020
@dweomer dweomer deleted the testing/sonobuoy branch February 10, 2020 18:52
@dweomer dweomer mentioned this pull request Feb 11, 2020
2 tasks
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.

2 participants