From 3ade6828c80700e4b9d7517e4d3abd1afba9c87a Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Tue, 3 Oct 2023 15:46:40 -0700 Subject: [PATCH] chore(ci): Add a test to assert conf files aren't overwritten (#18728) * chore(ci): Add a test to assert conf files aren't overwritten Signed-off-by: Jesse Szwedko * shell check Signed-off-by: Jesse Szwedko --------- Signed-off-by: Jesse Szwedko --- .github/workflows/publish.yml | 18 ++++-------------- scripts/verify-install.sh | 30 +++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index be635885a5ee9..0280e44156c73 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -316,14 +316,9 @@ jobs: with: name: vector-${{ env.VECTOR_VERSION }}-x86_64-unknown-linux-gnu path: target/artifacts - - name: First install of DEB package. + - name: Verify install of DEB package. run: | - dpkg -i target/artifacts/vector_${{ env.VECTOR_VERSION }}-1_amd64.deb - ./scripts/verify-install.sh - - name: Second install of DEB package. - run: | - dpkg -i target/artifacts/vector_${{ env.VECTOR_VERSION }}-1_amd64.deb - ./scripts/verify-install.sh + ./scripts/verify-install.sh target/artifacts/vector_${{ env.VECTOR_VERSION }}-1_amd64.deb rpm-verify: name: Verify RPM Packages @@ -372,14 +367,9 @@ jobs: with: name: vector-${{ env.VECTOR_VERSION }}-x86_64-unknown-linux-gnu path: target/artifacts - - name: First install of RPM package. - run: | - rpm -i --replacepkgs target/artifacts/vector-${{ env.VECTOR_VERSION }}-1.x86_64.rpm - ./scripts/verify-install.sh - - name: Second install of RPM package. + - name: Verify install of RPM package. run: | - rpm -i --replacepkgs target/artifacts/vector-${{ env.VECTOR_VERSION }}-1.x86_64.rpm - ./scripts/verify-install.sh + ./scripts/verify-install.sh target/artifacts/vector-${{ env.VECTOR_VERSION }}-1.x86_64.rpm macos-verify: name: Verify macOS Package diff --git a/scripts/verify-install.sh b/scripts/verify-install.sh index 35d8404bc92c5..48e80ee36ffa0 100755 --- a/scripts/verify-install.sh +++ b/scripts/verify-install.sh @@ -1,12 +1,40 @@ #!/usr/bin/env bash set -euo pipefail -# verify-install.sh +# verify-install.sh # # SUMMARY # # Verifies vector packages have been installed correctly +package="${1:?must pass package as argument}" + +install_package () { + case "$1" in + *.deb) + dpkg -i "$1" + ;; + *.rpm) + rpm -i --replacepkgs "$1" + ;; + esac +} + +install_package "$package" + +getent passwd vector || (echo "vector user missing" && exit 1) +getent group vector || (echo "vector group missing" && exit 1) +vector --version || (echo "vector --version failed" && exit 1) +test -f /etc/default/vector || (echo "/etc/default/vector doesn't exist" && exit 1) +test -f /etc/vector/vector.yaml || (echo "/etc/vector/vector.yaml doesn't exist" && exit 1) + +echo "FOO=bar" > /etc/default/vector +echo "foo: bar" > /etc/vector/vector.yaml + +install_package "$package" + getent passwd vector || (echo "vector user missing" && exit 1) getent group vector || (echo "vector group missing" && exit 1) vector --version || (echo "vector --version failed" && exit 1) +grep -q "FOO=bar" "/etc/default/vector" || (echo "/etc/default/vector has incorrect contents" && exit 1) +grep -q "foo: bar" "/etc/vector/vector.yaml" || (echo "/etc/vector/vector.yaml has incorrect contents" && exit 1)