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

feat: Add initial E2E test and structure #203

Merged
merged 1 commit into from
Aug 5, 2022

Conversation

Callisto13
Copy link
Member

@Callisto13 Callisto13 commented Jul 26, 2022

This adds a single test to create a CAPMVM workload cluster and a bit of
structure so that more tests can be added later.

Note that only CAPMVM on the current branch is tested, not released
versions or upgrades between versions. I have deliberately left it so we
can add those bit by bit after the general setup is merged in.

I have a lot more to do in the e2e saga, but this is a first step which
is useable.

I used the CAPI test framework1 which seems to be something of a
standard across providers, although it is a bit unwieldy.

Everything can be found under test/e2e/.

The contents of test/e2e/data are mostly yaml and can be ignored.

The dir test/e2e/config contains the config file used by the CAPI test
framework. Other config files can be passed in via test params but this
is the default.

The test itself is at test/e2e/e2e_test.go and
test/e2e/e2e_suite_test.go. The suite performs some env setup and
teardown by way of a manager. It is assumed for now that the tests are
not run in parallel (there is only one of them) so I did not set up any
synchronization between nodes, but that will need to be done as we add
more tests and parallelization.

The test creates a cilium flavour cluster, mainly because I could not
get the other one to work and did not want to spend a lot of time fixing
that. After the cluster is created it checks that all flintlock hosts
were used, and that a simple application can be successfully deployed.

In test/e2e/utils there are a bunch of helper things, which will
probably end up being broken up as they expand:

  • params.go sets up test flags
  • defaults.go holds defaults for test flags
  • utils.go is a bunch of helper funcs used by the test
  • clusterctl.go contains some functions I copied from the framework
    because I had to edit them and they are not hugely flexible.
  • manager.go holds some objects and methods which handle environment
    setup/teardown and shared test information.

The test can be run locally by:

  • Pulling the images listed at the top of
    test/e2e/config/e2e_conf.yaml to the local machine running the tests
    (except for the capmvm image, which will be built)
    this is no longer necessary, i fixed it
  • Starting 1 or more flintlock servers
  • Running make e2e E2E_ARGS="-e2e.flintlock-hosts 1.2.3.4:9090,5.6.7.8:9090"

Checklist:

  • squashed commits into logical changes
  • includes documentation <- coming later
  • adds unit tests
  • adds or updates e2e tests

@Callisto13 Callisto13 added the kind/feature New feature or request label Jul 26, 2022
- name: registry.k8s.io/cluster-api/kubeadm-bootstrap-controller:v1.1.5
loadBehavior: tryLoad
- name: registry.k8s.io/cluster-api/kubeadm-control-plane-controller:v1.1.5
loadBehavior: tryLoad
Copy link
Member Author

@Callisto13 Callisto13 Jul 26, 2022

Choose a reason for hiding this comment

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

So I found that the framework will load these images into the kind cluster, but wont pull them down. So you have to just have them on the machine first which is a pain.
IDK if the capa or oci providers use some extra framework trick, I have not found it yet. For now I am going to script something i guess, or write a helper func in the tests.

edit: reading the framework code, it looks like it should be pulling images that are not found locally 🤔 wonder why i was seeing errors

edit2: aha! because i am using an older version of capi that is why! We are using CAPI 1.1.5, which I left as I did not want to get into bumping that, and 1.1.5's franework stuff does not pull images for you. CAPA is using 1.1.2, which also does not pull images if not found, but I cannot find what they are doing to pull the images themselves. CAPOCI is using 1.2.0. which does have a framework bit which will pull down the images if they do not exist locally.
Do I want to get into bumping CAPI? Will have a go, but I tried that at the start of this and quickly decided it was a pain so we shall see.

final edit: decided not to get into that mess and just wrote a small func with a note that we can get rid of it when we bump CAPI

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

eh mine is better ;)

@@ -4,6 +4,7 @@ go 1.17

require (
github.com/go-logr/logr v1.2.3
github.com/onsi/ginkgo v1.16.5
Copy link
Member Author

Choose a reason for hiding this comment

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

we are pinned to ginkgo v1 until CAPI and literally everything else bumps to v2

Copy link
Member

Choose a reason for hiding this comment

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

Looks like this will be happening 22nd Aug: kubernetes-sigs/cluster-api#6906

Copy link
Member Author

Choose a reason for hiding this comment

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

not holding my breath ;)

Copy link
Member

@richardcase richardcase left a comment

Choose a reason for hiding this comment

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

Generally all looks ok to me, just one comment around the machine pool part.

My brain is a little fried (its been a long day) so will take another look in the morning when i'm more switched on.

test/e2e/utils/clusterctl.go Outdated Show resolved Hide resolved
test/e2e/utils/clusterctl.go Show resolved Hide resolved
richardcase
richardcase previously approved these changes Aug 3, 2022
Copy link
Member

@richardcase richardcase left a comment

Choose a reason for hiding this comment

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

This looks good, great work @Callisto13 .

I have run this locally across 2 machine and it all passed. I even had to use E2E_ARGS because i have a different ip range for my machines.....E2E_ARGS="-e2e.capmvm.vip-address 192.168.9.10".

@Callisto13
Copy link
Member Author

sorry! i forgot to push that small change i did yesterday afternoon

thanks for checking that E2E_ARGS works fine 👍 I might change how the flintlock hosts are injected at some point

This adds a single test to create a CAPMVM workload cluster and a bit of
structure so that more tests can be added later.

Note that only CAPMVM on the current branch is tested, not released
versions or upgrades between versions. I have deliberately left it so we
can add those bit by bit after the general setup is merged in.

I have a lot more to do in the e2e saga, but this is a first step which
is useable.

I used the CAPI test framework[1] which seems to be something of a
standard across providers, although it is a bit unwieldy.

Everything can be found under `test/e2e/`.

The contents of `test/e2e/data` are mostly yaml and can be ignored.

The dir `test/e2e/config` contains the config file used by the CAPI test
framework. Other config files can be passed in via test params but this
is the default.

The test itself is at `test/e2e/e2e_test.go` and
`test/e2e/e2e_suite_test.go`. The suite performs some env setup and
teardown by way of a manager. It is assumed for now that the tests are
not run in parallel (there is only one of them) so I did not set up any
synchronization between nodes, but that will need to be done as we add
more tests and parallelization.

The test creates a cilium flavour cluster, mainly because I could not
get the other one to work and did not want to spend a lot of time fixing
that. After the cluster is created it checks that all flintlock hosts
were used, and that a simple application can be successfully deployed.

In `test/e2e/utils` there are a bunch of helper things, which will
probably end up being broken up as they expand:
- `params.go` sets up test flags
- `defaults.go` holds defaults for test flags
- `utils.go` is a bunch of helper funcs used by the test
- `clusterctl.go` contains some functions I copied from the framework
  because I had to edit them and they are not hugely flexible.
- `manager.go` holds some objects and methods which handle environment
  setup/teardown and shared test information.

The test can be run locally by:
- Starting 1 or more flintlock servers
- Exporting the server addresses `export
  FLINTLOCK_HOSTS="1.2.3.4:9090,5.6.7.8:9090"`
- Running `make e2e`

[1]: https://pkg.go.dev/sigs.k8s.io/cluster-api/test/framework
Copy link
Member

@richardcase richardcase left a comment

Choose a reason for hiding this comment

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

The additions to the readme are good.

@Callisto13 Callisto13 merged commit cdced18 into liquidmetal-dev:main Aug 5, 2022
@Callisto13 Callisto13 deleted the e2e branch August 5, 2022 09:30
@Callisto13 Callisto13 restored the e2e branch August 5, 2022 11:32
@Callisto13 Callisto13 deleted the e2e branch August 8, 2022 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants