Page MenuHomeFreeBSD

M1: CI Scripts for Developers
Needs ReviewPublic

Authored by bofh on Feb 7 2024, 8:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 16, 8:02 PM
Unknown Object (File)
Fri, Nov 15, 7:53 AM
Unknown Object (File)
Fri, Nov 15, 3:41 AM
Unknown Object (File)
Fri, Nov 15, 2:45 AM
Unknown Object (File)
Thu, Nov 14, 5:09 PM
Unknown Object (File)
Thu, Nov 14, 1:56 PM
Unknown Object (File)
Thu, Nov 14, 10:14 AM
Unknown Object (File)
Thu, Nov 14, 8:05 AM
Subscribers
None

Details

Summary

This is a complete redo of https://reviews.freebsd.org/D38815 without touching release directory although utilizing the same script.

Current Features:

  • Does smoke tests using either bhyve(amd64 only) or qemu(Non x86_64 or when defined USE_QEMU=1). Currently defined CITYPE=smoke. Once we have added full tests we can also utilize something like CITYPE=complete
  • Most of the resources are dynamically allocated based on available resources in the host
  • If CPU supports POPCNT or vmm can be loaded then bhyve is used for amd64 otherwise automatically installs and uses qemu@nox11
  • When required third party applications or packages for booting non-x86 images are automatically installed

Current Limitation:

  • Does not support full tests like the one in our Jenkins
  • At this moment this is also not suitable to be used in our Jenkins platform as the jobs are divided in multiple smaller tasks and artifacts are moved here and there which are not exactly the scenario for individual developers.

Future Works:

  • Add full tests like the one in ci.f.o
  • Add different tests or options to disable some tests
  • Add test profiles full
  • Possibly add test through Cloud Providers like AWS/GCP/Azure or Cirrus or Github Actions
Test Plan
cd ~
git clone git@github.com:5u623l20/freebsd-src.git --branch=ffcci2
cd freebsd-src/tests/ci
make ci
make TARGET=amd64 TARGET_ARCH=amd64 ci
make TARGET=amd64 TARGET_ARCH=amd64 USE_QEMU=1 ci
make TARGET=arm64 TARGET_ARCH=aarch64 ci
make TARGET=powerpc TARGET_ARCH=powerpc64 ci
make TARGET=powerpc TARGET_ARCH=powerpc64le ci  
make TARGET=riscv TARGET_ARCH=riscv64 ci

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

bofh requested review of this revision.Feb 7 2024, 8:10 PM
tests/ci/Makefile
7

typo developed1 :)

bofh marked an inline comment as done.Feb 8 2024, 2:43 PM
tests/ci/Makefile
34

What are the "smoke tests" (are they defined somewhere) ?

tests/ci/Makefile
34

There is actually no specific tests running. It just builds the world/kernel, then creates an image and boots the system. And after the boot sequence is completed the system automatically shuts down. Check the file named tests/ci/tools/freebsdci in the bottom of this page to check what happens after the system boots. We will add the actual tests that are actually run on our ci system slowly and gradually after this is merged.

I wonder if using make(1) is really a good choice for this. Doing things like computing the RAM size of the VM in make feels awkward. There's also no good way to see what parameters are available to developers, and the framework is not friendly to user error (e.g., misspelling a variable name on the command line means that make will silently do the wrong thing). There is no namespacing for parameters (parameters for the build, VM boot, and the test itself are all mixed together).

For the purpose of running canned smoke tests, I think what you have is sufficient, and it's simple and easy to understand. But if this make(1) target is going to expand and become more flexible to suit various developer workloads, not just running some static smoke test in a CI pipeline, I'm worried that this code will become very hard to use and maintain. It would be helpful to understand what future directions you are planning for this work. How do you see this fitting into developer workflows? For instance, I think this needs to run as root, but this is not actually required (ignore bhyve for now) - do you plan to remove that constraint?

tests/ci/Makefile
49

This default setting won't work for powerpc64 I think (the default config is GENERIC64 there).

164

Why is this include right here?

171

Is it possible to override KERNCONF from the command line?

tests/ci/tools/ci.conf
20

I suspect it's not worth documenting these. The list will only get outdated. e.g., many, many tests depend on python for various things.

tests/ci/tools/freebsdci
56

Is this a placeholder for some kind of checks?

61
bofh marked 2 inline comments as done.Feb 12 2024, 5:00 PM

I wonder if using make(1) is really a good choice for this. Doing things like computing the RAM size of the VM in make feels awkward. There's also no good way to see what parameters are available to developers, and the framework is not friendly to user error (e.g., misspelling a variable name on the command line means that make will silently do the wrong thing). There is no namespacing for parameters (parameters for the build, VM boot, and the test itself are all mixed together).

make is definitely not the best tool but this is what was discussed by many when we initially planned this work.

For the purpose of running canned smoke tests, I think what you have is sufficient, and it's simple and easy to understand. But if this make(1) target is going to expand and become more flexible to suit various developer workloads, not just running some static smoke test in a CI pipeline, I'm worried that this code will become very hard to use and maintain. It would be helpful to understand what future directions you are planning for this work. How do you see this fitting into developer workflows? For instance, I think this needs to run as root, but this is not actually required (ignore bhyve for now) - do you plan to remove that constraint?

Truly speaking I haven't given the thought about the root user case but in the future when src or kernel developers need testing they can run the full tests either in their local hardware or through CI Pipelines in various repositories like Github or Cirrus-ci or also leveraging direct Cloud resources. The main purpose for working on this was to facilitate the developers with the same suite of tests we run in our CI platform but at pre-commit stage. As in the current workflow the tests or CI are done after committing or merging the codes and there is no easy way for a developer to go through the extensive testings we go through at our CI. At this stage a smoke test only really feels vague but after lots of delay I think we should push this and more stuffs gradually. When we will have the entire test suite added here which we run in our CI pipeline it will be more beneficial for the developers and this will make more sense.

I will definitely need to write some sections for the Committers Guide at some stage but for most of the developers I think this is only like `cd /usr/src/tests/ci && make CITYPE=<smoke|default|full> TARGET=<TARGET> TARGET_ARCH=<TARGET_ARCH> ci'

I am still not sure whether if META builds will be helpful for developers or not. If there is a demand I will also add support for META.

tests/ci/Makefile
49

I think the config file name is GENERIC64 but the ident is still GENERIC.

164

clean target needs to use the variables CLEANFILES and CLEANDIRS and without including this here it fails to utilize the vars.

171

Truly speaking I haven't tried utilizing this from command line but have tested through __MAKE_CONF with the KERNCONF directive. But I think when defined through command line it will also work.

tests/ci/tools/ci.conf
20

Noted. I will remove these while making other changes and resubmitting again.

tests/ci/tools/freebsdci
56

Not at all. After this is merged I will add the full tests scenario and more functions here. The purpose of this function is simply just printing this message.

61

:P

bofh marked an inline comment as done.Feb 12 2024, 5:02 PM
bofh marked an inline comment as not done.
  • Remove comments
  • Reduce pkg installations for smoke tests

I wonder if using make(1) is really a good choice for this. Doing things like computing the RAM size of the VM in make feels awkward. There's also no good way to see what parameters are available to developers, and the framework is not friendly to user error (e.g., misspelling a variable name on the command line means that make will silently do the wrong thing). There is no namespacing for parameters (parameters for the build, VM boot, and the test itself are all mixed together).

make is definitely not the best tool but this is what was discussed by many when we initially planned this work.

I'm still reading other parts, but I think I can response this one first.

I think the goal is having several make targets for CI operations, and when things getting well, adding a target to src root, such as 'make ci' for let people can run everything with a single command. This doesn't mean that we have to write everything in make. Similar to what is done in ports/Mk and src/releases, we can introduce several helper scripts written in other languages. These script interpreters may not even need to be part of the base system (in such cases, the Makefile would check for dependencies and prompt for their installation if necessary). For now I think the current Makefile isn't too overly complex so I can accept it. However, I will definitely support extracting the complex logic out of Makefile when we are adding more feature.

I wonder if using make(1) is really a good choice for this. Doing things like computing the RAM size of the VM in make feels awkward. There's also no good way to see what parameters are available to developers, and the framework is not friendly to user error (e.g., misspelling a variable name on the command line means that make will silently do the wrong thing). There is no namespacing for parameters (parameters for the build, VM boot, and the test itself are all mixed together).

make is definitely not the best tool but this is what was discussed by many when we initially planned this work.

I'm still reading other parts, but I think I can response this one first.

I think the goal is having several make targets for CI operations, and when things getting well, adding a target to src root, such as 'make ci' for let people can run everything with a single command. This doesn't mean that we have to write everything in make. Similar to what is done in ports/Mk and src/releases, we can introduce several helper scripts written in other languages. These script interpreters may not even need to be part of the base system (in such cases, the Makefile would check for dependencies and prompt for their installation if necessary). For now I think the current Makefile isn't too overly complex so I can accept it. However, I will definitely support extracting the complex logic out of Makefile when we are adding more feature.

So far the way I have divided the Makefiles there won't be any too much complexity in the Makefile itself. The entire complexity will add up in the freebsdci rc script. However if you want me to mimic everything from the jenkins ci scripts that will be real trouble. My point of view is we should stay as close as possible on how the re@ generates the images so that the problems are reproducible by multiple teams. The only complex thing that I will need to add in the Makefile is a method of archiving the images or separating the environments. But I won't bother too much with that now. Will think about the bridge when we need to cross the river. :D

bofh edited the summary of this revision. (Show Details)

Double quote variable comparison