Skip to content

Commit

Permalink
ci: run USDT interface test in a VM
Browse files Browse the repository at this point in the history
Our CI tasks are run by CirrusCI in Docker containers in a Google
Compute Engine based Kubernetes environment. These containers have
limited capabilities - especially CAP_SYS_ADMIN is missing. See
bitcoin/bitcoin#23296 (comment)

We need elevated privileges to hook into the USDT tracepoints. We use a
CirrusCI "compute_engine_instance" (a VM, not a container) where we have
the required privileges. The ubunut-mininmal-2204-lts was choosen with
debian-11 being an alternative. Both pack an outdated 'bpfcc-tools'
package (v0.18.0) from 2020. This version prints warnings to stderr
during BPF bytecode compilation, which causes our functional test runner
to fail. This is fixed in newer verison.

Until debian-12 or a newer Ubuntu release is avaliable as image in GCE
(https://cloud.google.com/compute/docs/images/os-details), we use a
third-party and untrusted PPA that releases up-to-date versions of the
package.

The official iovisor (authors of BCC) PPA is outdated too. An
alternative would be to compile BCC from source in the CI.
  • Loading branch information
0xB10C authored and MacroFake committed Jul 7, 2022
1 parent dba6f82 commit 1e68ce3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
12 changes: 9 additions & 3 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,21 @@ task:
FILE_ENV: "./ci/test/00_setup_env_native_fuzz.sh"

task:
name: '[multiprocess, i686, DEBUG] [focal]'
name: '[multiprocess, i686, DEBUG, USDT] [jammy]'
<< : *GLOBAL_TASK_TEMPLATE
container:
image: ubuntu:focal
# We can't use a 'container' for the USDT interface tests as the CirrusCI
# containers don't have privileges to hook into bitcoind. CirrusCI uses
# Google Compute Engine instances: https://cirrus-ci.org/guide/custom-vms/
# Images can be found here: https://cloud.google.com/compute/docs/images/os-details
compute_engine_instance:
image_project: ubuntu-os-cloud
image: family/ubuntu-2204-lts # when upgrading, check if we can drop "ADD_UNTRUSTED_BPFCC_PPA"
cpu: 4
memory: 16G # The default memory is sometimes just a bit too small, so double everything
env:
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV
FILE_ENV: "./ci/test/00_setup_env_i686_multiprocess.sh"
#HOME: /root/

task:
name: '[no wallet, libbitcoinkernel] [bionic]'
Expand Down
15 changes: 11 additions & 4 deletions ci/test/00_setup_env_i686_multiprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@

export LC_ALL=C.UTF-8

# We install an up-to-date 'bpfcc-tools' package from an untrusted PPA.
# This can be dropped with the next Ubuntu or Debian release that includes up-to-date packages.
# See the if-then in ci/test/04_install.sh too.
export ADD_UNTRUSTED_BPFCC_PPA=true

export HOST=i686-pc-linux-gnu
export CONTAINER_NAME=ci_i686_multiprocess
export DOCKER_NAME_TAG=ubuntu:20.04
export PACKAGES="cmake python3 python3-pip llvm clang g++-multilib"
export DEP_OPTS="DEBUG=1 MULTIPROCESS=1"
export DOCKER_NAME_TAG=ubuntu:22.04 # May not run in docker unless --enable-usdt is dropped
export PACKAGES="cmake python3 python3-pip llvm clang g++-multilib bpfcc-tools"
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
export DEP_OPTS="NO_QT=1 DEBUG=1 MULTIPROCESS=1"
export GOAL="install"
export BITCOIN_CONFIG="--enable-debug CC='clang -m32' CXX='clang++ -m32' LDFLAGS='--rtlib=compiler-rt -lgcc_s'"
export BITCOIN_CONFIG="--enable-usdt --enable-debug CC='clang -m32' CXX='clang++ -m32' LDFLAGS='--rtlib=compiler-rt -lgcc_s'"
export TEST_RUNNER_ENV="BITCOIND=bitcoin-node"
export TEST_RUNNER_EXTRA="--nosandbox"
8 changes: 8 additions & 0 deletions ci/test/04_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ if [[ $DOCKER_NAME_TAG == *centos* ]]; then
${CI_RETRY_EXE} CI_EXEC dnf -y install epel-release
${CI_RETRY_EXE} CI_EXEC dnf -y --allowerasing install "$DOCKER_PACKAGES" "$PACKAGES"
elif [ "$CI_USE_APT_INSTALL" != "no" ]; then
if [[ "${ADD_UNTRUSTED_BPFCC_PPA}" == "true" ]]; then
# Ubuntu 22.04 LTS and Debian 11 both have an outdated bpfcc-tools packages.
# The iovisor PPA is outdated as well. The next Ubuntu and Debian releases will contain updated
# packages. Meanwhile, use an untrusted PPA to install an up-to-date version of the bpfcc-tools
# package.
# TODO: drop this once we can use newer images in GCE
CI_EXEC add-apt-repository ppa:hadret/bpfcc
fi
${CI_RETRY_EXE} CI_EXEC apt-get update
${CI_RETRY_EXE} CI_EXEC apt-get install --no-install-recommends --no-upgrade -y "$PACKAGES" "$DOCKER_PACKAGES"
if [ -n "$PIP_PACKAGES" ]; then
Expand Down

0 comments on commit 1e68ce3

Please sign in to comment.