Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

device manager tests + kustomize support for end-users #473

Merged
merged 7 commits into from
Nov 26, 2019

Conversation

pohly
Copy link
Contributor

@pohly pohly commented Nov 21, 2019

This builds on top of #420 and enables that new test in the CI by running it and all other Go tests in the existing steps and VMs. This makes the CI run a bit faster (3:24min, see #420 (comment)), keeps the Jenkins UI a bit more manageable (the current number of steps already require scrolling), and last but not least, we get better code coverage (all Go tests run on all distros, in exactly the same environment (= container) as the PMEM-CSI driver itself).

To run the device manager inside the normal test cluster, we need some free PMEM. To achieve that, kustomization of the PMEM-CSI driver deployment with kubectl kustomize gets enabled and used during the cluster setup. This feature should also be useful for admins because it is an easy way to move the driver into its own namespace.

Finally, this adds some testing of the pmem-ns-init parameters, something that we didn't have before.

The recent commit changed the make rules so that the binaries get
unpacked from an archive. But because tar preserves the original
modification time stamp, that unpacking is repeated each time the
binaries are needed. We can avoid that by bumping the time stamp after
unpacking.
@pohly
Copy link
Contributor Author

pohly commented Nov 22, 2019

@okartau, @avalluri: can you both please review this?

The 1.15 Clear Linux production cluster fails to come up and I'm investigating that right now, but other than that this PR is ready.

"kubectl kustomize" cannot be called for all bases in deploy/kustomize
because it has no `--load_restrictor none` and the security policy prevents
reading some patch files:

  $ kubectl kustomize deploy/kustomize/kubernetes-1.14-lvm-testing/
  Error: AccumulateTarget: AccumulateTarget: AccumulateTarget: security; file '../../patches/controller-role-patch.yaml' is not in or below '/nvme/gopath/src/github.com/intel/pmem-csi/deploy/kustomize/kubernetes-1.14/rbac'

We can solve this for users by creating "normal" bases where all
patches and resources have already been pulled into a single
pmem-csi.yaml. All we need to do is to put them into a separate
directory and add a kustomize.yaml.

For the sake of preserving current behavior we store those generated
files also under their old names. Symlinks are not used because that
does not work on Windows or when pulling the files via http.
@pohly
Copy link
Contributor Author

pohly commented Nov 22, 2019

The 1.15 Clear Linux production cluster fails to come up and I'm investigating that right now

Fixed. The symlinks in the 1.15 directory were incomplete and tar had to be told to archive the content of the symlinks, not the symlinks themselves.

This verifies that kustomize works for our base deployments. It also
adds some limited testing of the -usefordax and -useforsector
parameters because the now unused space will be used for runnning the
device manager Go test. If all space was used for LVM, those tests
would fail when using direct mode.
Depending on the random number generator, the size of the new volume
might have been zero, which isn't valid.
It failed to pass in direct mode when the host already had some other
namespaces. We must ignore existing namespaces.

The size check leads to better assertions when using BeNumerically.
This used to be broken. A fix went in with commit
6a2336a, now we also have a test.

Fixes: intel#472
@avalluri
Copy link
Contributor

@pohly I try to understand the comments you made in commit 43f3735:

This has multiple advantages:

  • we test in exactly the environment in which the code will run

Other than the device manager what other unit tests in your opinion require(benefit from) such an environment.

Because it runs so quickly, it's okay to simply repeat this testing in
each CI step which runs E2E tests.

Currently, running all(registry server, device manager, and state) unit tests taking around 27s in each run. Do you think this argument is still valid once we improve our unit tests?

root := os.Getenv("REPO_ROOT")
var err error

build := exec.Command("/bin/sh", "-c", os.Getenv("TEST_CMD")+" -c -o _work/test.test "+pkg)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about making a single binary for all unit tests and run in a single stretch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would have to reorganize the test source code. I prefer to keep it decentralized (one test per package).

Copy link
Contributor Author

@pohly pohly left a comment

Choose a reason for hiding this comment

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

This has multiple advantages:
we test in exactly the environment in which the code will run

Other than the device manager what other unit tests in your opinion require(benefit from) such an environment.

At this point, none. But even if we all think that this is the case, it's still better to test that opinion.

Because it runs so quickly, it's okay to simply repeat this testing in
each CI step which runs E2E tests.

Currently, running all(registry server, device manager, and state) unit tests taking around 27s in each run. > Do you think this argument is still valid once we improve our unit tests?

Yes.

test/e2e/gotests/gotests.go Outdated Show resolved Hide resolved
root := os.Getenv("REPO_ROOT")
var err error

build := exec.Command("/bin/sh", "-c", os.Getenv("TEST_CMD")+" -c -o _work/test.test "+pkg)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would have to reorganize the test source code. I prefer to keep it decentralized (one test per package).

This has multiple advantages:
- we test in exactly the environment in which the code will run
- it's faster than bringing up a separate VM
- no need to remember a separate make target to run all tests

Speed is important both for CI and developers. Running the tests in an
existing cluster just takes 9 seconds and can be done using the same
command as running other tests individually:

   make test_e2e TEST_E2E_FOCUS=gotests.*pmem-device-manager

Because it runs so quickly, it's okay to simply repeat this testing in
each CI step which runs E2E tests.
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.

2 participants