14 Running E2E tests
Hadi Moshayedi edited this page 2024-12-19 21:03:44 -08:00

What happens in the E2E CI at our github repo?

It runs bin/ci, which requires setting the following environment variables:

  • HETZNER_USER
  • HETZNER_PASSWORD
  • CI_HETZNER_SACRIFICIAL_SERVER_ID

It will create an instance of Prog::Test::HetznerServer, which will automatically reimage the Hetzner instance with Id equal to CI_HETZNER_SACRIFICIAL_SERVER_ID & then will create instances of Prog::Test::VmGroup to run the actual tests.

This is not very good for the development environment, since:

  • Each iteration will take about 30 minutes
  • It will try to download github os images, which 3rd party developers don't access to

Running VmGroup tests directly

Note that E2E tests require some images to run. So, either use Prog::Vm::HostNexus.assemble(..., default_boot_images: ["ubuntu-jammy", "almalinux-9], ...)", or download them after preparing the host:

> vmh.download_boot_image("almalinux-9", version: Config.almalinux_9_version)
> vmh.download_boot_image("ubuntu-jammy", version: Config.ubuntu_jammy_version)

Start the VmGroup tests using:

> st = Prog::Test::VmGroup.assemble(test_reboot: false, boot_images: vmh.boot_images.map { |x| x.name })

This will create some VMs, and then will run some commands inside them to verify they're functioning as expected, and then will destroy them.

You can monitor its progress using [st.reload].map { |x| [x.prog, x.label] }.

Eventually the strand will pop, so st.reload will cause Sequel::NoExistingObject: Record not found, and tests have finished at that point.

This should finish in about 6-7 minutes.

Running Vm tests directly

Create a VM which is sshable:

vm_st = Prog::Vm::Nexus.assemble_with_sshable(
      "ubi", Project.first.id,
      boot_image: "ubuntu-jammy",
      enable_ip4: true
    )

After it's provisioned, start the test:

st = Strand.create_with_id(
  prog: "Test::Vm",
  label: "start",
  stack: [{subject_id: vm_st.id}])

Then it will go through stages & execute some commands inside the Vm & verify the results. It will eventually pop.