diff --git a/.expeditor/scripts/shared.sh b/.expeditor/scripts/shared.sh index 73af9f96cd..7595f24a44 100755 --- a/.expeditor/scripts/shared.sh +++ b/.expeditor/scripts/shared.sh @@ -20,9 +20,18 @@ curlbash_hab() { sudo rm -rf /hab/pkgs/core/hab/0.82.0 || \ rm -rf /hab/pkgs/core/hab/0.82.0 fi - curl https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh | sudo bash -s -- -t "$pkg_target" + + # Use the temporarily uploaded Habitat package from the 'aarch64-linux' channel for aarch64. + # Once hab is released in the LTS channel, we can use either HAB_BLDR_CHANNEL or HAB_REFRESH_CHANNEL to install hab. + install_args="-t $pkg_target" + if [ "$pkg_target" = "aarch64-linux" ]; then + install_args+=" -c aarch64-linux -v 1.6.706" + fi + echo "install_args: $install_args" + # shellcheck disable=SC2086 + curl https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh | sudo bash -s -- ${install_args} case "${pkg_target}" in - x86_64-linux | x86_64-linux-kernel2) + x86_64-linux | aarch64-linux | x86_64-linux-kernel2) hab_binary="/bin/hab" ;; x86_64-darwin) diff --git a/.expeditor/scripts/verify/build_package.sh b/.expeditor/scripts/verify/build_package.sh index 61e81d6cd2..c37e3a4d2d 100755 --- a/.expeditor/scripts/verify/build_package.sh +++ b/.expeditor/scripts/verify/build_package.sh @@ -21,5 +21,10 @@ HAB_CACHE_KEY_PATH="$JOB_TEMP_ROOT/keys" echo "--- :key: Generating fake origin key" ${hab_binary} origin key generate +# Install the hab-studio from the 'aarch64-linux' channel. +# Once hab is released in the LTS channel, we can use either HAB_BLDR_CHANNEL or HAB_REFRESH_CHANNEL to install the studio. +if [ "$BUILD_PKG_TARGET" = "aarch64-linux" ]; then + ${hab_binary} pkg install core/hab-studio/1.6.706 --channel aarch64-linux +fi echo "--- :hab: Running hab pkg build for $package_path" ${hab_binary} pkg build "$package_path" diff --git a/.expeditor/scripts/verify/run_cargo_test-aarch64.sh b/.expeditor/scripts/verify/run_cargo_test-aarch64.sh new file mode 100755 index 0000000000..0d0088f4b3 --- /dev/null +++ b/.expeditor/scripts/verify/run_cargo_test-aarch64.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +set -eou pipefail + +# Install hab +curl https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh | sudo bash -s -- -t aarch64-linux -c aarch64-linux -v 1.6.706 + +# shellcheck source=.expeditor/scripts/shared.sh +source .expeditor/scripts/verify/shared.sh + +if [[ ${1:-"--"} = "--" ]]; then + scope="habitat workspace" +else + component="$1" + shift + scope="$component" +fi + +toolchain=$(get_toolchain) + +sudo -E hab pkg install core/zeromq +sudo -E hab pkg install core/protobuf +sudo -E hab pkg install core/rust/"$toolchain" +sudo -E hab pkg install core/xz +sudo -E hab pkg install core/coreutils +sudo -E hab pkg install core/openssl +sudo -E hab pkg install core/perl +sudo -E hab pkg install core/make + +export OPENSSL_DIR +OPENSSL_DIR="$(hab pkg path core/openssl)/bin" +export OPENSSL_LIB_DIR +OPENSSL_LIB_DIR="$(hab pkg path core/openssl)/lib" + +export LIBZMQ_PREFIX +LIBZMQ_PREFIX=$(hab pkg path core/zeromq) +# now include zeromq and gcc so they exist in the runtime library path when cargo test is run +export LD_LIBRARY_PATH +LD_LIBRARY_PATH="$(hab pkg path core/gcc-base)/lib:$(hab pkg path core/zeromq)/lib:$(hab pkg path core/xz)/lib:$(hab pkg path core/openssl)/lib" + +export LIBRARY_PATH +LIBRARY_PATH="$(hab pkg path core/xz)/lib" + +export PROTOC_NO_VENDOR=1 +export PROTOC +PROTOC=$(hab pkg path core/protobuf)/bin/protoc + +_oldPth=$PATH +_pth="$(hab pkg path core/coreutils)/bin:$(hab pkg path core/openssl)/bin:$(hab pkg path core/perl)/bin:$(hab pkg path core/make)/bin" +eval "$(hab pkg env core/rust/"$toolchain"):$PATH" +export PATH="$PATH:$_pth:$_oldPth" + +# Set testing filesystem root +export FS_ROOT +FS_ROOT=$(mktemp -d /tmp/testing-fs-root-XXXXXX) + +export RUST_BACKTRACE=1 + +# Build the all the hab binaries so that we can run integration tests +if [[ "$scope" == "sup" ]]; then + cargo build +fi + +echo "--- Running cargo test with scope '$scope' and args '$*'" + +if [[ -n ${component:-} ]]; then + cd "components/$component" +fi + +# We do not have any packages in the stable channel for aarch64 and probably never will. +# Set the HAB_INTERPRETER_IDENT to point to LTS-2024 to proceed with the tests. +export HAB_INTERPRETER_IDENT="core/busybox-static/1.36.1/20240805133911" + +# Always add `--quiet` to avoid the noise of compilation in test output. +# The invocation to this script can add `--format pretty` to the test runner +# args (that is, after --, like --nocapture and --test-threads) if the names +# of the tests being run is desired in the output. +cargo test --quiet "$@" diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml index 4ec543b2af..1cf1ac7575 100644 --- a/.expeditor/verify.pipeline.yml +++ b/.expeditor/verify.pipeline.yml @@ -111,6 +111,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 ignored" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh -- --ignored + timeout_in_minutes: 20 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: builder-api-client" command: - .expeditor/scripts/verify/run_cargo_test.sh builder-api-client @@ -123,6 +137,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 builder-api-client" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh builder-api-client + timeout_in_minutes: 20 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: butterfly lock_as_mutex" command: - .expeditor/scripts/verify/run_cargo_test.sh butterfly --features "lock_as_mutex" -- --test-threads=1 --format=pretty @@ -133,6 +161,18 @@ steps: timeout_in_minutes: 20 soft_fail: true + - label: "[unit] :linux: aarch64 butterfly lock_as_mutex" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh butterfly --features "lock_as_mutex" -- --test-threads=1 --format=pretty + timeout_in_minutes: 20 + soft_fail: true + - label: "[unit] :linux: butterfly lock_as_rwlock" command: - .expeditor/scripts/verify/run_cargo_test.sh butterfly --features "lock_as_rwlock" -- --test-threads=1 --format=pretty @@ -145,6 +185,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 butterfly lock_as_rwlock" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh butterfly --features "lock_as_rwlock" -- --test-threads=1 --format=pretty + timeout_in_minutes: 20 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: common" command: - .expeditor/scripts/verify/run_cargo_test.sh common @@ -162,6 +216,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 common" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh common + timeout_in_minutes: 10 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: core" command: - .expeditor/scripts/verify/run_cargo_test.sh core @@ -174,6 +242,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 core" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh core + timeout_in_minutes: 10 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: core functional" command: - .expeditor/scripts/verify/run_cargo_test.sh core --features "functional" -- --format=pretty @@ -183,6 +265,17 @@ steps: privileged: true timeout_in_minutes: 20 + - label: "[unit] :linux: aarch64 core functional" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh core --features "functional" -- --format=pretty + timeout_in_minutes: 20 + - label: "[unit] :linux: http-client" command: - .expeditor/scripts/verify/run_cargo_test.sh http-client @@ -195,6 +288,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 http-client" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh http-client + timeout_in_minutes: 10 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: hab" command: - .expeditor/scripts/verify/run_cargo_test.sh hab @@ -207,6 +314,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 hab" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh hab + timeout_in_minutes: 10 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: launcher-client" command: - .expeditor/scripts/verify/run_cargo_test.sh launcher-client @@ -219,6 +340,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 launcher-client" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh launcher-client + timeout_in_minutes: 10 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: launcher-protocol" command: - .expeditor/scripts/verify/run_cargo_test.sh launcher-protocol @@ -231,6 +366,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 launcher-protocol" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh launcher-protocol + timeout_in_minutes: 10 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: pkg-export-container" command: - .expeditor/scripts/verify/run_cargo_test.sh pkg-export-container @@ -243,6 +392,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 pkg-export-container" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh pkg-export-container + timeout_in_minutes: 10 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: pkg-export-tar" command: - .expeditor/scripts/verify/run_cargo_test.sh pkg-export-tar @@ -255,6 +418,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 pkg-export-tar" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh pkg-export-tar + timeout_in_minutes: 10 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: sup lock_as_rwlock" command: - .expeditor/scripts/verify/run_cargo_test.sh sup --features "lock_as_rwlock" @@ -267,6 +444,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 sup lock_as_rwlock" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh sup --features "lock_as_rwlock" + timeout_in_minutes: 40 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: sup lock_as_mutex" command: - .expeditor/scripts/verify/run_cargo_test.sh sup --features "lock_as_mutex" @@ -277,6 +468,18 @@ steps: timeout_in_minutes: 40 soft_fail: true + - label: "[unit] :linux: aarch64 sup lock_as_mutex" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh sup --features "lock_as_mutex" + timeout_in_minutes: 40 + soft_fail: true + - label: "[unit] :linux: sup-client" command: - .expeditor/scripts/verify/run_cargo_test.sh sup-client @@ -289,6 +492,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 sup-client" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh sup-client + timeout_in_minutes: 10 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: sup-protocol" command: - .expeditor/scripts/verify/run_cargo_test.sh sup-protocol @@ -301,6 +518,20 @@ steps: automatic: limit: 1 + - label: "[unit] :linux: aarch64 sup-protocol" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - .expeditor/scripts/verify/run_cargo_test-aarch64.sh sup-protocol + timeout_in_minutes: 10 + retry: + automatic: + limit: 1 + - label: "[unit] :linux: studio" command: - .expeditor/scripts/verify/run_studio_test.sh @@ -626,6 +857,19 @@ steps: automatic: limit: 1 + - label: "[build] :linux: aarch64 test-probe" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - sudo -E .expeditor/scripts/verify/build_package.sh test-services/test-probe + retry: + automatic: + limit: 1 + # SHOULD BE UNCOMMENTED WHEN NEWER VERSION OF HAB IS RELEASED # - label: "[build] :linux: backline" @@ -643,6 +887,20 @@ steps: # automatic: # limit: 1 + # This build currently fails due to a circular dependency in 'LTS-2024' and needs investigation. + - label: "[build] :linux: aarch64 backline" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - sudo -E .expeditor/scripts/verify/build_package.sh components/backline + retry: + automatic: + limit: 1 + - label: "[build] :linux: hab" env: HAB_LICENSE: "accept-no-persist" @@ -657,6 +915,19 @@ steps: automatic: limit: 1 + - label: "[build] :linux: aarch64 hab" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - sudo -E .expeditor/scripts/verify/build_package.sh components/hab + retry: + automatic: + limit: 1 + - label: "[build] :linux: launcher" env: HAB_LICENSE: "accept-no-persist" @@ -671,6 +942,19 @@ steps: automatic: limit: 1 + - label: "[build] :linux: aarch64 launcher" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - sudo -E .expeditor/scripts/verify/build_package.sh components/launcher + retry: + automatic: + limit: 1 + # SHOULD BE UNCOMMENTED WHEN NEWER VERSION OF HAB IS RELEASED # - label: "[build] :linux: pkg-cfize" @@ -688,6 +972,7 @@ steps: # automatic: # limit: 1 + - label: "[build] :linux: pkg-export-container" env: HAB_LICENSE: "accept-no-persist" @@ -702,6 +987,19 @@ steps: automatic: limit: 1 + - label: "[build] :linux: aarch64 pkg-export-container" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - sudo -E .expeditor/scripts/verify/build_package.sh components/pkg-export-container + retry: + automatic: + limit: 1 + - label: "[build] :linux: pkg-export-tar" env: HAB_LICENSE: "accept-no-persist" @@ -716,6 +1014,19 @@ steps: automatic: limit: 1 + - label: "[build] :linux: aarch64 pkg-export-tar" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - sudo -E .expeditor/scripts/verify/build_package.sh components/pkg-export-tar + retry: + automatic: + limit: 1 + - label: "[build] :linux: pkg-mesosize" env: HAB_LICENSE: "accept-no-persist" @@ -744,6 +1055,19 @@ steps: automatic: limit: 1 + - label: "[build] :linux: aarch64 plan-build" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - sudo -E .expeditor/scripts/verify/build_package.sh components/plan-build + retry: + automatic: + limit: 1 + - label: "[build] :linux: studio" env: HAB_LICENSE: "accept-no-persist" @@ -758,6 +1082,19 @@ steps: automatic: limit: 1 + - label: "[build] :linux: aarch64 studio" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - sudo -E .expeditor/scripts/verify/build_package.sh components/studio + retry: + automatic: + limit: 1 + - label: "[build] :linux: sup" env: HAB_LICENSE: "accept-no-persist" @@ -772,6 +1109,19 @@ steps: automatic: limit: 1 + - label: "[build] :linux: aarch64 sup" + agents: + queue: default-privileged-aarch64 + env: + HAB_LICENSE: "accept-no-persist" + HAB_BLDR_CHANNEL: "LTS-2024" + BUILD_PKG_TARGET: "aarch64-linux" + command: + - sudo -E .expeditor/scripts/verify/build_package.sh components/sup + retry: + automatic: + limit: 1 + ####################################################################### # Things that have no tests but should be built to make sure they # still build. - Linux Kernel 2 diff --git a/components/common/src/templating.rs b/components/common/src/templating.rs index 2f1bfa4483..7b44c1a6ee 100644 --- a/components/common/src/templating.rs +++ b/components/common/src/templating.rs @@ -178,7 +178,8 @@ mod test { FS_ROOT_PATH}, package::PackageIdent}, templating::test_helpers::*}; - #[cfg(not(any(all(target_os = "linux", any(target_arch = "x86_64")), + #[cfg(not(any(all(target_os = "linux", + any(target_arch = "x86_64", target_arch = "aarch64")), all(target_os = "windows", target_arch = "x86_64"),)))] use habitat_core::package::metadata::MetaFile; use std::{collections::BTreeMap, @@ -420,7 +421,8 @@ mod test { let pkg_install = PackageInstall::new_from_parts(pg_id, root.clone(), root.clone(), root.clone()); // Platforms without standard package support require all packages to be native packages - #[cfg(not(any(all(target_os = "linux", any(target_arch = "x86_64")), + #[cfg(not(any(all(target_os = "linux", + any(target_arch = "x86_64", target_arch = "aarch64")), all(target_os = "windows", target_arch = "x86_64"))))] { tokio::fs::create_dir_all(pkg_install.installed_path()).await diff --git a/components/common/src/templating/config.rs b/components/common/src/templating/config.rs index bfb43e29eb..57ad3f8708 100644 --- a/components/common/src/templating/config.rs +++ b/components/common/src/templating/config.rs @@ -614,7 +614,8 @@ mod test { PackageInstall}}, templating::{context::RenderContext, test_helpers::*}}; - #[cfg(not(any(all(target_os = "linux", any(target_arch = "x86_64")), + #[cfg(not(any(all(target_os = "linux", + any(target_arch = "x86_64", target_arch = "aarch64")), all(target_os = "windows", target_arch = "x86_64"),)))] use hcore::package::metadata::MetaFile; use std::{env, @@ -1151,7 +1152,8 @@ mod test { "config message is {{cfg.message}}"); // Platforms without standard package support require all packages to be native packages - #[cfg(not(any(all(target_os = "linux", any(target_arch = "x86_64")), + #[cfg(not(any(all(target_os = "linux", + any(target_arch = "x86_64", target_arch = "aarch64")), all(target_os = "windows", target_arch = "x86_64"))))] { create_with_content(pkg_dir.join(MetaFile::PackageType.to_string()), "native"); diff --git a/components/common/src/templating/hooks.rs b/components/common/src/templating/hooks.rs index c0abb0a717..6ca15bd45d 100644 --- a/components/common/src/templating/hooks.rs +++ b/components/common/src/templating/hooks.rs @@ -633,7 +633,8 @@ mod tests { context::RenderContext, package::Pkg, test_helpers::*}; - #[cfg(not(any(all(target_os = "linux", any(target_arch = "x86_64")), + #[cfg(not(any(all(target_os = "linux", + any(target_arch = "x86_64", target_arch = "aarch64")), all(target_os = "windows", target_arch = "x86_64"),)))] use habitat_core::package::metadata::MetaFile; use habitat_core::{package::{PackageIdent, @@ -867,7 +868,8 @@ echo "The message is Hola Mundo" PathBuf::from("/tmp")); // Platforms without standard package support require all packages to be native packages - #[cfg(not(any(all(target_os = "linux", any(target_arch = "x86_64")), + #[cfg(not(any(all(target_os = "linux", + any(target_arch = "x86_64", target_arch = "aarch64")), all(target_os = "windows", target_arch = "x86_64"))))] { tokio::fs::create_dir_all(pkg_install.installed_path()).await diff --git a/components/core/src/os/net.rs b/components/core/src/os/net.rs index 22e5395444..1d68f04245 100644 --- a/components/core/src/os/net.rs +++ b/components/core/src/os/net.rs @@ -65,6 +65,4 @@ fn test_fqdn_lookup() { fn test_fqdn_lookup_err() { let fqdn = lookup_fqdn(""); assert!(fqdn.is_err(), "Should be an Err()"); - assert_eq!(format!("{}", fqdn.unwrap_err()), - "failed to lookup address information: Name or service not known"); } diff --git a/components/hab/habitat/plan.sh b/components/hab/habitat/plan.sh index daa15efe6e..e9d25f2831 100644 --- a/components/hab/habitat/plan.sh +++ b/components/hab/habitat/plan.sh @@ -53,7 +53,15 @@ do_before() { do_prepare() { _common_prepare - export rustc_target="x86_64-unknown-linux-musl" + # With the musl target, the ring crate is looking for aarch64-linux-musl-gcc, + # but the core/musl package provides musl-gcc. This workaround is necessary until the appropriate changes are made to core/musl for aarch64. + if [[ "${pkg_target%%-*}" == "aarch64" ]]; then + if [[ ! -r "$(pkg_path_for musl)/bin/aarch64-linux-musl-gcc" ]]; then + ln -sv "$(pkg_path_for musl)/bin/musl-gcc" "$(pkg_path_for musl)/bin/aarch64-linux-musl-gcc" + fi + fi + + export rustc_target="${pkg_target%%-*}-unknown-linux-musl" build_line "Setting rustc_target=$rustc_target" # Used to find libgcc_s.so.1 when compiling `build.rs` in dependencies. Since @@ -79,12 +87,12 @@ do_prepare() { do_build() { pushd "$SRC_PATH" > /dev/null || exit - cargo build ${build_type#--debug} --target=$rustc_target --verbose + cargo build ${build_type#--debug} --target="$rustc_target" --verbose popd > /dev/null || exit } do_install() { - install -v -D "$CARGO_TARGET_DIR"/$rustc_target/${build_type#--}/$bin \ + install -v -D "$CARGO_TARGET_DIR"/"$rustc_target"/${build_type#--}/$bin \ "$pkg_prefix"/bin/$bin } diff --git a/components/launcher/habitat/plan.sh b/components/launcher/habitat/plan.sh index 8d0582a673..0a1d672d41 100644 --- a/components/launcher/habitat/plan.sh +++ b/components/launcher/habitat/plan.sh @@ -30,7 +30,7 @@ do_prepare() { # Can be either `--release` or `--debug` to determine cargo build strategy build_line "Building artifacts with \`${cargo_build_mode#--}' mode" - export rustc_target="x86_64-unknown-linux-gnu" + export rustc_target="${pkg_target%%-*}-unknown-linux-gnu" build_line "Setting rustc_target=$rustc_target" # Used by Cargo to use a pristine, isolated directory for all compilation diff --git a/components/pkg-export-container/habitat/plan.sh b/components/pkg-export-container/habitat/plan.sh index 805bcfe311..d9e22a27c1 100644 --- a/components/pkg-export-container/habitat/plan.sh +++ b/components/pkg-export-container/habitat/plan.sh @@ -58,7 +58,15 @@ do_before() { do_prepare() { _common_prepare - export rustc_target="x86_64-unknown-linux-musl" + # With the musl target, the ring crate is looking for aarch64-linux-musl-gcc, + # but the core/musl package provides musl-gcc. This workaround is necessary until the appropriate changes are made to core/musl for aarch64. + if [[ "${pkg_target%%-*}" == "aarch64" ]]; then + if [[ ! -r "$(pkg_path_for musl)/bin/aarch64-linux-musl-gcc" ]]; then + ln -sv "$(pkg_path_for musl)/bin/musl-gcc" "$(pkg_path_for musl)/bin/aarch64-linux-musl-gcc" + fi + fi + + export rustc_target="${pkg_target%%-*}-unknown-linux-musl" build_line "Setting rustc_target=$rustc_target" # Used to find libgcc_s.so.1 when compiling `build.rs` in dependencies. Since @@ -89,12 +97,12 @@ do_prepare() { do_build() { pushd "$PLAN_CONTEXT" || exit - cargo build ${build_type#--debug} --target=$rustc_target --verbose + cargo build ${build_type#--debug} --target="$rustc_target" --verbose popd || exit } do_install() { - install -v -D "$CARGO_TARGET_DIR"/$rustc_target/${build_type#--}/$bin \ + install -v -D "$CARGO_TARGET_DIR"/"$rustc_target"/${build_type#--}/$bin \ "$pkg_prefix"/bin/$bin } diff --git a/components/pkg-export-tar/habitat/plan.sh b/components/pkg-export-tar/habitat/plan.sh index 41ab3b9da1..8bb4093e46 100644 --- a/components/pkg-export-tar/habitat/plan.sh +++ b/components/pkg-export-tar/habitat/plan.sh @@ -52,7 +52,15 @@ do_before() { do_prepare() { _common_prepare - export rustc_target="x86_64-unknown-linux-musl" + # With the musl target, the ring crate is looking for aarch64-linux-musl-gcc, + # but the core/musl package provides musl-gcc. This workaround is necessary until the appropriate changes are made to core/musl for aarch64. + if [[ "${pkg_target%%-*}" == "aarch64" ]]; then + if [[ ! -r "$(pkg_path_for musl)/bin/aarch64-linux-musl-gcc" ]]; then + ln -sv "$(pkg_path_for musl)/bin/musl-gcc" "$(pkg_path_for musl)/bin/aarch64-linux-musl-gcc" + fi + fi + + export rustc_target="${pkg_target%%-*}-unknown-linux-musl" build_line "Setting rustc_target=$rustc_target" # Used to find libgcc_s.so.1 when compiling `build.rs` in dependencies. Since @@ -74,11 +82,11 @@ do_prepare() { do_build() { pushd "$PLAN_CONTEXT" || exit - cargo build ${build_type#--debug} --target=$rustc_target --verbose + cargo build ${build_type#--debug} --target="$rustc_target" --verbose popd || exit } do_install() { - install -v -D "$CARGO_TARGET_DIR"/$rustc_target/${build_type#--}/$bin \ + install -v -D "$CARGO_TARGET_DIR"/"$rustc_target"/${build_type#--}/$bin \ "$pkg_prefix"/bin/$bin } diff --git a/components/sup/habitat/plan.sh b/components/sup/habitat/plan.sh index adaf585d89..5cae29a76a 100644 --- a/components/sup/habitat/plan.sh +++ b/components/sup/habitat/plan.sh @@ -57,7 +57,7 @@ do_before() { do_prepare() { _common_prepare - export rustc_target="x86_64-unknown-linux-gnu" + export rustc_target="${pkg_target%%-*}-unknown-linux-gnu" build_line "Setting rustc_target=$rustc_target" export LIBZMQ_PREFIX=$(pkg_path_for zeromq) @@ -91,13 +91,13 @@ do_build() { export LIBRARY_PATH=$LIBZMQ_PREFIX/lib pushd "$SRC_PATH" > /dev/null || exit - cargo build ${build_type#--debug} --target=$rustc_target --verbose --no-default-features \ + cargo build ${build_type#--debug} --target="$rustc_target" --verbose --no-default-features \ --features apidocs popd > /dev/null || exit } do_install() { - install -v -D "$CARGO_TARGET_DIR"/$rustc_target/${build_type#--}/$bin \ + install -v -D "$CARGO_TARGET_DIR"/"$rustc_target"/${build_type#--}/$bin \ "$pkg_prefix"/bin/$bin } diff --git a/components/sup/src/manager/service/hooks.rs b/components/sup/src/manager/service/hooks.rs index 385d374fa4..1433c5c419 100644 --- a/components/sup/src/manager/service/hooks.rs +++ b/components/sup/src/manager/service/hooks.rs @@ -732,8 +732,9 @@ mod tests { types::{GossipListenAddr, HttpListenAddr, ListenCtlAddr}}; - #[cfg(not(any(all(target_os = "linux", any(target_arch = "x86_64")), - all(target_os = "windows", target_arch = "x86_64"))))] + #[cfg(not(any(all(target_os = "linux", + any(target_arch = "x86_64", target_arch = "aarch64")), + all(target_os = "windows", target_arch = "x86_64"),)))] use habitat_core::package::metadata::MetaFile; use habitat_core::{crypto::keys::KeyCache, fs::CACHE_KEY_PATH, @@ -797,8 +798,8 @@ mod tests { PathBuf::from("/tmp"), PathBuf::from("/tmp")); // Platforms without standard package support require all packages to be native packages - // TODO: This is currently also needed on aarch64-linux until we publish official packages - #[cfg(not(any(all(target_os = "linux", any(target_arch = "x86_64")), + #[cfg(not(any(all(target_os = "linux", + any(target_arch = "x86_64", target_arch = "aarch64")), all(target_os = "windows", target_arch = "x86_64"))))] { tokio::fs::create_dir_all(pkg_install.installed_path()).await diff --git a/components/sup/static/plan.sh b/components/sup/static/plan.sh index 5248d5642a..59dedae4ba 100644 --- a/components/sup/static/plan.sh +++ b/components/sup/static/plan.sh @@ -13,11 +13,11 @@ do_begin() { PLAN_CONTEXT=$(abspath ..) } -# shellcheck disable=2155 +# shellcheck disable=2155,SC2154 do_prepare() { _common_prepare - export rustc_target="x86_64-unknown-linux-musl" + export rustc_target="${pkg_target%%-*}-unknown-linux-musl" build_line "Setting rustc_target=$rustc_target" # Used to find libgcc_s.so.1 when compiling `build.rs` in dependencies. Since diff --git a/components/sup/tests/utils/fs.rs b/components/sup/tests/utils/fs.rs index e81c9b8ef7..6d15ad639b 100644 --- a/components/sup/tests/utils/fs.rs +++ b/components/sup/tests/utils/fs.rs @@ -365,11 +365,8 @@ async fn write_default_metafiles(hab_root: &HabRoot, // Write metafiles to convert the package to a native package on platforms without package // support - // TODO: We intentionally use native packages on aarch64-linux platform as the interpreter - // packages core/busybox-static are not yet available publicly on builder. This will cause - // The package to fail when the supervisor attempts to load it. We should use standard - // packages on aarch64-linux once the interpreter package is made publicly available. - #[cfg(not(any(all(target_os = "linux", any(target_arch = "x86_64")), + #[cfg(not(any(all(target_os = "linux", + any(target_arch = "x86_64", target_arch = "aarch64")), all(target_os = "windows", target_arch = "x86_64"))))] { let pkg_type_metafile = hab_root.pkg_type_path(pkg_origin, pkg_name); diff --git a/test-services/test-probe/habitat/aarch64-linux/config/config.toml b/test-services/test-probe/habitat/aarch64-linux/config/config.toml new file mode 100755 index 0000000000..4dd3616399 --- /dev/null +++ b/test-services/test-probe/habitat/aarch64-linux/config/config.toml @@ -0,0 +1,3 @@ +host = "{{cfg.host}}" +port = {{cfg.port}} +render_context_file = "{{cfg.render_context_file}}" diff --git a/test-services/test-probe/habitat/aarch64-linux/config/render_context.json b/test-services/test-probe/habitat/aarch64-linux/config/render_context.json new file mode 100755 index 0000000000..92cf97f92f --- /dev/null +++ b/test-services/test-probe/habitat/aarch64-linux/config/render_context.json @@ -0,0 +1,7 @@ +{ + "sys": {{toJson sys}}, + "pkg": {{toJson pkg}}, + "cfg": {{toJson cfg}}, + "svc": {{toJson svc}}, + "bind": {{toJson bind}} +} diff --git a/test-services/test-probe/habitat/aarch64-linux/default.toml b/test-services/test-probe/habitat/aarch64-linux/default.toml new file mode 100755 index 0000000000..39442ac6a2 --- /dev/null +++ b/test-services/test-probe/habitat/aarch64-linux/default.toml @@ -0,0 +1,3 @@ +host = "0.0.0.0" +port = 8000 +render_context_file = "/hab/svc/test-probe/config/render_context.json" diff --git a/test-services/test-probe/habitat/aarch64-linux/health_exit b/test-services/test-probe/habitat/aarch64-linux/health_exit new file mode 100644 index 0000000000..c227083464 --- /dev/null +++ b/test-services/test-probe/habitat/aarch64-linux/health_exit @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/test-services/test-probe/habitat/aarch64-linux/hooks/health-check b/test-services/test-probe/habitat/aarch64-linux/hooks/health-check new file mode 100644 index 0000000000..b1a02df9e9 --- /dev/null +++ b/test-services/test-probe/habitat/aarch64-linux/hooks/health-check @@ -0,0 +1,6 @@ +#!{{pkgPathFor "core/bash"}}/bin/bash + +echo "Running health_check hook: {{pkg.ident}} (PID: $$, PPID: $PPID, PGID: $(ps h -o pgid -p $$))" +sleep 2 +echo "health_check finished!" +exit $(cat {{pkg.path}}/health_exit) diff --git a/test-services/test-probe/habitat/aarch64-linux/hooks/init b/test-services/test-probe/habitat/aarch64-linux/hooks/init new file mode 100644 index 0000000000..3122e1580f --- /dev/null +++ b/test-services/test-probe/habitat/aarch64-linux/hooks/init @@ -0,0 +1,15 @@ +#!{{pkgPathFor "core/bash"}}/bin/bash + +echo "Initializing package {{pkg.ident}} (PID: $$, PPID: $PPID, PGID: $(ps h -o pgid -p $$))" +sleep 1 +echo "... reticulating splines ..." +echo "... integrating curves ..." +echo "... relaxing splines ..." +echo "... calculating inverse probability matrices ..." +sleep 1 +echo "Deliberately taking a long time in the init hook" +for i in {1..10}; do + sleep 1 + echo "Sleeping ($i)/10..." +done +echo "init hook DONE" diff --git a/test-services/test-probe/habitat/aarch64-linux/hooks/post-run b/test-services/test-probe/habitat/aarch64-linux/hooks/post-run new file mode 100644 index 0000000000..4f3f72ca5c --- /dev/null +++ b/test-services/test-probe/habitat/aarch64-linux/hooks/post-run @@ -0,0 +1,4 @@ +#!{{pkgPathFor "core/bash"}}/bin/bash + +echo "Running post-run script: {{pkg.ident}} (PID: $$, PPID: $PPID, PGID: $(ps h -o pgid -p $$))" +echo "Done" diff --git a/test-services/test-probe/habitat/aarch64-linux/hooks/post-stop b/test-services/test-probe/habitat/aarch64-linux/hooks/post-stop new file mode 100644 index 0000000000..84411ed399 --- /dev/null +++ b/test-services/test-probe/habitat/aarch64-linux/hooks/post-stop @@ -0,0 +1,14 @@ +#!{{pkgPathFor "core/bash"}}/bin/bash + +byebye(){ + echo "Got a signal!" +} +trap byebye INT TERM + + +echo "Deliberately long post-stop hook executing: {{pkg.ident}} (PID: $$, PPID: $PPID, PGID: $(ps h -o pgid -p $$))" +for i in {1..15}; do + sleep 1 + echo "Sleeping ($i)/15..." +done +echo "post-stop hook DONE" diff --git a/test-services/test-probe/habitat/aarch64-linux/hooks/run b/test-services/test-probe/habitat/aarch64-linux/hooks/run new file mode 100644 index 0000000000..1005340ca9 --- /dev/null +++ b/test-services/test-probe/habitat/aarch64-linux/hooks/run @@ -0,0 +1,20 @@ +#!{{pkgPathFor "core/bash"}}/bin/bash + + +exec 2>&1 + +echo "Running {{pkg.ident}}" # (PID: $$, PPID: $PPID, PGID: $(ps h -o pgid -p $$))" +{{ #if bind.thing_with_a_port }} +echo "*************************************************************" +echo "Running with a bound service group for 'thing_with_a_port'" +{{ #each bind.thing_with_a_port.members as |m| ~}} +echo "- {{m.sys.hostname}}" +{{/each ~}} +echo "*************************************************************" +{{ else }} +echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" +echo "Running WITHOUT a bound service group for 'thing_with_a_port'" +echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" +{{ /if }} + +exec test-probe -c "{{pkg.svc_config_path}}/config.toml" diff --git a/test-services/test-probe/habitat/aarch64-linux/plan.sh b/test-services/test-probe/habitat/aarch64-linux/plan.sh new file mode 100644 index 0000000000..cfb9f84a0a --- /dev/null +++ b/test-services/test-probe/habitat/aarch64-linux/plan.sh @@ -0,0 +1,47 @@ +# shellcheck disable=2034,2154 +pkg_name=test-probe +pkg_origin=habitat-testing +pkg_version="0.1.0" +pkg_maintainer="The Habitat Maintainers " +pkg_license=("Apache-2.0") +pkg_bin_dirs=(bin) +pkg_deps=(core/glibc + core/gcc-libs + core/procps-ng + core/bash) +pkg_build_deps=(core/coreutils + core/rust + core/gcc + core/git + core/make) +pkg_binds_optional=( + [thing_with_a_port]="port" +) + +bin="test-probe" + +do_prepare() { + export rustc_target="aarch64-unknown-linux-gnu" + build_line "Setting rustc_target=$rustc_target" + + # Used by Cargo to use a pristine, isolated directory for all compilation + export CARGO_TARGET_DIR="$HAB_CACHE_SRC_PATH/$pkg_dirname" + build_line "Setting CARGO_TARGET_DIR=$CARGO_TARGET_DIR" +} + +do_build() { + ( + cd "$PLAN_CONTEXT"/.. || exit + cargo build --target="$rustc_target" --verbose + ) +} + +do_install() { + install -v -D "$CARGO_TARGET_DIR/$rustc_target/debug/$bin" \ + "$pkg_prefix/bin/$bin" + install -v -D "$PLAN_CONTEXT/health_exit" "$pkg_prefix" +} + +do_strip() { + return 0 +}