From d13efdd8ec02908f01fa16b16ee4932d72560cb7 Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Fri, 29 Sep 2023 13:13:30 -0700 Subject: [PATCH 1/2] chore(ci): Add a test to assert conf files aren't overwritten Signed-off-by: Jesse Szwedko --- .github/workflows/publish.yml | 18 ++++-------------- scripts/verify-install.sh | 31 ++++++++++++++++++++++++++++++- 2 files changed, 34 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..35dd80490e644 100755 --- a/scripts/verify-install.sh +++ b/scripts/verify-install.sh @@ -1,12 +1,41 @@ #!/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 () { + echo $1 + 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) From ebfa4ffa6790887affd6d0b1456114b98b9a7741 Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Mon, 2 Oct 2023 16:16:48 -0700 Subject: [PATCH 2/2] shell check Signed-off-by: Jesse Szwedko --- scripts/verify-install.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/verify-install.sh b/scripts/verify-install.sh index 35dd80490e644..48e80ee36ffa0 100755 --- a/scripts/verify-install.sh +++ b/scripts/verify-install.sh @@ -10,18 +10,17 @@ set -euo pipefail package="${1:?must pass package as argument}" install_package () { - echo $1 case "$1" in *.deb) - dpkg -i $1 + dpkg -i "$1" ;; *.rpm) - rpm -i --replacepkgs $1 + rpm -i --replacepkgs "$1" ;; esac } -install_package $package +install_package "$package" getent passwd vector || (echo "vector user missing" && exit 1) getent group vector || (echo "vector group missing" && exit 1) @@ -32,7 +31,7 @@ test -f /etc/vector/vector.yaml || (echo "/etc/vector/vector.yaml doesn't exist" echo "FOO=bar" > /etc/default/vector echo "foo: bar" > /etc/vector/vector.yaml -install_package $package +install_package "$package" getent passwd vector || (echo "vector user missing" && exit 1) getent group vector || (echo "vector group missing" && exit 1)