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

tests(e2e): Bootstrap end-to-end tests #803

Merged
merged 16 commits into from
Oct 19, 2023
Merged

tests(e2e): Bootstrap end-to-end tests #803

merged 16 commits into from
Oct 19, 2023

Conversation

GabrielNagy
Copy link
Contributor

@GabrielNagy GabrielNagy commented Oct 7, 2023

This is a comprehensive set of changes best reviewed commit by commit.

It handles the following parts of the e2e test process:

  • creating base VMs and image templates (automated in GitHub workflow)
  • building adsys as a deb
  • provisioning disposable client VMs, joining them to the integration tests realm and installing adsys

The following parts are not covered:

  • configuring the AD controller
  • running adsys and asserting outputs on the client (in other words, the actual tests)

End-to-end tests are structured in suites of steps meant to be run in succession to accomplish a task, e.g. creating an image template or provisioning the client VM. Between steps, the current state is saved to a file (inventory.yaml) which will be used in the subsequent step of the suite. These suites are written in a semi-portable way so they can easily be replicated on any developer's machine (provided they have a VPN connection set up).

A run of the GitHub workflow that builds VM templates can be seen here: https://github.com/GabrielNagy/adsys/actions/runs/6440737893

Fixes UDENG-1358 and UDENG-1441 and UDENG-1362

@codecov-commenter
Copy link

codecov-commenter commented Oct 7, 2023

Codecov Report

Merging #803 (b6e158b) into main (d1d43e5) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #803   +/-   ##
=======================================
  Coverage   86.07%   86.07%           
=======================================
  Files          77       77           
  Lines        8552     8552           
=======================================
  Hits         7361     7361           
  Misses        868      868           
  Partials      323      323           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@GabrielNagy GabrielNagy marked this pull request as ready for review October 7, 2023 11:55
@GabrielNagy GabrielNagy requested a review from a team as a code owner October 7, 2023 11:55
Add various internal packages that will help us in our e2e workflows:

- CLI command bootstrapping
- azure command execution
- remote command execution (SSH + SFTP)
- inventory/state management
Add a series of scripts to be used for building image templates on
Azure. This is accomplished through running 3 scripts in succession:

- 00_check_vm_image: acquire the Azure image URN to use as a base image
- 01_prepare_base_vm: provision required dependencies on the base image
- 02_create_vm_template: turn the customized VM into an image template

Detailed usage and requirements are described in each of the scripts.
This requires versions of ppp and sstp-client which are not yet
available in the Ubuntu archive so we're temporarily using a PPA.

The calling workflows are responsible for passing the required inputs as
secrets to the action.
This workflow runs on a scheduled basis and can also be triggered
manually if needed.

By default it'll figure out the currently supported Ubuntu versions and
build templates for them unless suitable templates already exist (in
other words, templates will only be built when a release transitions
from development to stable, and when no template - stable or
developmental - exists for the release at all).

This behavior can be overridden using the manual workflow inputs, which
provide a way to force refreshing the template builds, and configuring
the matrix of codenames to build.
This set of scripts is responsible for building the current working
directory of adsys as a deb package for the given codename, then
provisioning a VM from our custom VM image template, joining the
integration tests realm and installing the previously built adsys
deb(s).

The package build is done via Docker containers and tests are disabled
both to speed up the build process and to weed out false positives since
adsys package tests were not written to be run in a Docker container.

For Ubuntu releases where adsys doesn't build cleanly, such as jammy, we
provide patches to satisfy the build process.
The structure of these GPOs is described in the ADSys QA Plan document.

The GPOs are added in XML format to be converted to POL before copying
them on the AD controller (using the xml_to_pol.py) script.
We don't measure coverage on end-to-end tests, and the code there
doesn't run in production, so it shouldn't affect our coverage status.
And use apt-get build-dep instead of mk-build-deps.
Previously, the approach was to:
- always build an image if no custom image exists
- build stable image if we only have daily custom images
- never build again if a custom stable image already exists

Now, we take into consideration the build number of the Azure
Marketplace VM image, and ensure we refresh our custom images when new
base images are published. This means we have to track the build number
as part of the custom image version to ensure idempotency of the build.

Thus, the version format of our custom images becomes the following:
- X: major version, 0 for development releases, 1 for stable releases
- Y: minor version, replicates build number of the Marketplace VM, e.g.
     202310110
- Z: patch version, incremented for consecutive builds of the same minor
     version, starts at 0 (in practice this won't be encountered unless
     we force a build with the --force param)

Additionally, the behavior of the 00_check_vm_image script is to no
longer error when there is no image to be printed - this is to be able
to properly differentiate between a valid behavior and an actual error.

Now, the script always exits with 0 unless an actual error occurs. If
there is no image URN to be printed, stdout will be empty so the
consumer will know that the image for the given codename is already up
to date.
And use `keep` instead of `preserve`.
Use eatmydata and the dpkg force-unsafe-io setting to speed up package
installation during base VM preparation.

Pass --unattended to the realm command when joining the domain.

Pass set -eu to the provision script to make it more resilient.
We don't really care how these fields are serialized (as long as they
are serialized), it's also less work when we decide to add/remove a
field.
@GabrielNagy
Copy link
Contributor Author

@didrocks if you would be so kind as to have a look on the last 5 commits I just pushed, full diff is here https://github.com/ubuntu/adsys/compare/e2624c41eef4285f103e7ac51d5e4d24ae4f85f5..14a98755049024d0e48edd6acc420dec0151f14e

It's what we discussed in our calls, hopefully I haven't missed anything. An updated run of the E2E image template build workflow can be seen here.

@GabrielNagy
Copy link
Contributor Author

Pushed a change to reflect what we discussed regarding the structure of the cmd files.

Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

Some small/minor details comments. Thanks for implementing those changes, this looks 👍

.github/workflows/e2e-build-images.yaml Show resolved Hide resolved
.github/actions/azure-sstpc-vpn/action.yaml Show resolved Hide resolved
e2e/cmd/00_check_vm_image/main.go Outdated Show resolved Hide resolved
e2e/internal/az/image.go Show resolved Hide resolved
e2e/internal/az/image.go Show resolved Hide resolved
As opposed to a flat structure.
Prefer apt-get instead of apt in scripts, and only set DEBIAN_FRONTEND
where needed.
Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

And all good! Thanks for the walkthrough the other day on the first PR pass, that was really helpful! :)

@GabrielNagy GabrielNagy merged commit 4a52072 into main Oct 19, 2023
14 checks passed
@GabrielNagy GabrielNagy deleted the prepare-e2e branch October 19, 2023 08:02
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.

3 participants