Skip to content

Commit

Permalink
test: add basic sanity test for upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: Niladri Halder <[email protected]>
  • Loading branch information
niladrih committed Nov 9, 2024
1 parent 9ea6869 commit 3d5da12
Show file tree
Hide file tree
Showing 14 changed files with 518 additions and 10 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/k8s-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ jobs:
id: build
run: |
TAG=$(nix-shell ./shell.nix --run './scripts/python/generate-test-tag.sh')
BIN=$(mktemp -p . -d -t test-bin-XXXXXX)
TEST_DIR=$(realpath $(mktemp -d ./test-dir-XXXXXX))
nix-shell ./shell.nix --run "./scripts/python/tag-chart.sh $TAG"
RUSTFLAGS="-C debuginfo=0 -C strip=debuginfo" ./scripts/release.sh --tag $TAG --build-bins --build-binary-out $BIN --no-static-linking --skip-publish --debug
RUSTFLAGS="-C debuginfo=0 -C strip=debuginfo" ./scripts/release.sh --tag $TAG --build-binary-out $TEST_DIR --no-static-linking --skip-publish --debug
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "bin=$BIN" >> $GITHUB_OUTPUT
echo "bin=$TEST_DIR" >> $GITHUB_OUTPUT
- name: BootStrap k8s cluster
run: |
nix-shell ./scripts/k8s/shell.nix --run "./scripts/k8s/deployer.sh start --label"
- name: Load images to Kind cluster
run: nix-shell ./scripts/k8s/shell.nix --run "./scripts/k8s/load-images-to-kind.sh --tag ${{ steps.build.outputs.tag }} --trim-debug-suffix"
- name: Run Pytests
run: nix-shell ./shell.nix --run './scripts/python/test.sh'
run: |
export UPGRADE_TARGET_VERSION=${{ steps.build.outputs.tag }}
export TEST_DIR=${{ steps.build.outputs.bin }}
nix-shell ./shell.nix --run "./scripts/python/test.sh"
- name: The job has failed
if: ${{ failure() }}
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ __pycache__
/kubectl-plugin

# Pytest assets
/test-bin-*
/test-dir-*
tests/bdd/venv
pytest.log
7 changes: 7 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[pytest]
log_cli = true
log_cli_level = INFO
log_cli_format = %(asctime)s [%(levelname)s] %(message)s
log_cli_date_format = %Y-%m-%d %H:%M:%S
log_file = pytest.log
log_file_level = DEBUG
4 changes: 0 additions & 4 deletions scripts/helm/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ die() {
exit "${_return}"
}

nvme_ana_check() {
cat /sys/module/nvme_core/parameters/multipath
}

while [ "$#" -gt 0 ]; do
case $1 in
-h|--help)
Expand Down
1 change: 1 addition & 0 deletions scripts/python/generate-test-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]:-"$0"}")")"
ROOT_DIR="$SCRIPT_DIR/../.."

# Imports
source "$ROOT_DIR"/scripts/utils/log.sh
source "$ROOT_DIR"/scripts/utils/repo.sh

Expand Down
Empty file added scripts/python/pytest_fmt.sh
Empty file.
3 changes: 3 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ in
mkShell {
name = "extensions-shell";
buildInputs = [
autoflake
black
cacert
cargo-expand
cargo-udeps
Expand All @@ -27,6 +29,7 @@ mkShell {
cowsay
git
helm-docs
isort
kubectl
kubernetes-helm-wrapped
llvmPackages.libclang
Expand Down
17 changes: 17 additions & 0 deletions tests/bdd/common/environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import logging
import os

logger = logging.getLogger(__name__)


def get_env(variable: str):
try:
value = os.getenv(variable)
if len(value) == 0:
raise ValueError("Env {variable} is empty")
logger.info(f"Found env {variable}={value}")
return value

except Exception as e:
logger.error(f"Failed to get env {variable}: {e}")
return None
Loading

0 comments on commit 3d5da12

Please sign in to comment.