From e842f895fc190d694867f46720cccf9d8dd298cf Mon Sep 17 00:00:00 2001 From: rohan2794 Date: Fri, 6 Sep 2024 13:28:15 +0530 Subject: [PATCH] add github action to run lvm tests Signed-off-by: rohan2794 --- .github/workflows/e2e-test.yml | 46 +++++++++++++++++++ scripts/e2e-test.sh | 46 +++++++++++++++++++ scripts/e2e_util.py | 27 +++++++++++ scripts/exec-tests.sh | 4 +- scripts/go-checks.sh | 10 ++-- scripts/k8s/deployer.sh | 1 + scripts/testlists.py | 46 +++++++++++++++++++ .../lvm_volume_provisioning_test.go | 2 +- testplans/common.yaml | 8 ++++ testplans/hostpath.yaml | 8 ++++ testplans/lvm.yaml | 8 ++++ testplans/selfci.yaml | 8 ++++ testplans/zfs.yaml | 8 ++++ 13 files changed, 214 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/e2e-test.yml create mode 100755 scripts/e2e-test.sh create mode 100644 scripts/e2e_util.py create mode 100644 scripts/testlists.py create mode 100644 testplans/common.yaml create mode 100644 testplans/hostpath.yaml create mode 100644 testplans/lvm.yaml create mode 100644 testplans/selfci.yaml create mode 100644 testplans/zfs.yaml diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml new file mode 100644 index 0000000..8ab1053 --- /dev/null +++ b/.github/workflows/e2e-test.yml @@ -0,0 +1,46 @@ +name: e2e tests +on: + pull_request: + types: ['opened', 'edited', 'reopened', 'synchronize'] +# Since the on property is required, using the workflow_dispatch event, +# which allows you to manually trigger the workflow from the GitHub Actions interface. +# on: +# workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@v11 + with: + kvm: true + - uses: DeterminateSystems/magic-nix-cache-action@v6 + - name: Pre-populate nix-shell + run: | + export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r) + echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV + nix-shell shell.nix --run "echo" + - name: Go checks + run: | + nix-shell shell.nix --run "./scripts/go-checks.sh" + lvm: + needs: ['lint'] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@v11 + with: + kvm: true + - uses: DeterminateSystems/magic-nix-cache-action@v6 + - name: Pre-populate nix-shell + run: | + export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r) + echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV + nix-shell shell.nix --run "echo" + - name: BootStrap k8s cluster + run: | + nix-shell shell.nix --run "./scripts/k8s/deployer.sh start --zfs --lvm" + - name: Lvm e2e test + run: | + nix-shell shell.nix --run "./scripts/e2e-test.sh --testplan lvm" diff --git a/scripts/e2e-test.sh b/scripts/e2e-test.sh new file mode 100755 index 0000000..c3a5013 --- /dev/null +++ b/scripts/e2e-test.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +set -eu + +SCRIPTDIR=$(dirname "$(realpath "$0")") +EXITV_INVALID_OPTION=1 + +help() { + cat < /dev/null 2>&1 ; then cd "$GOSRCDIRAPPS" || exit 1 echo "## linting apps ##" - if ! golangci-lint run -v --allow-parallel-runners ; then + if ! golangci-lint run -v --allow-parallel-runners --timeout=120s ; then exitv=1 fi cd "$GOSRCDIRCOMMON" || exit 1 echo "" echo "## linting common ##" - if ! golangci-lint run -v --allow-parallel-runners ; then + if ! golangci-lint run -v --allow-parallel-runners --timeout=120s ; then exitv=1 fi cd "$GOSRCDIRE2EAGENT" || exit 1 echo "" echo "## linting e2e-agent ##" - if ! golangci-lint run -v --allow-parallel-runners ; then + if ! golangci-lint run -v --allow-parallel-runners --timeout=120s ; then exitv=1 fi cd "$GOSRCDIRE2EPROXY" || exit 1 echo "" echo "## linting e2e-proxy ##" - if ! golangci-lint run -v --allow-parallel-runners ; then + if ! golangci-lint run -v --allow-parallel-runners --timeout=120s ; then exitv=1 fi cd "$GOSRCDIRSRC" || exit 1 - if ! golangci-lint run -v --allow-parallel-runners ; then + if ! golangci-lint run -v --allow-parallel-runners --timeout=120s ; then exitv=1 fi diff --git a/scripts/k8s/deployer.sh b/scripts/k8s/deployer.sh index 2409f70..51c84cf 100755 --- a/scripts/k8s/deployer.sh +++ b/scripts/k8s/deployer.sh @@ -130,6 +130,7 @@ fi # Install prerequisites if ["$SETUP_MAYASTOR" = "true" ]; then "$SCRIPT_DIR"/setup-io-prereq.sh --hugepages "$HUGE_PAGES" --mayastor $DRY_RUN +fi if [ "$SETUP_ZFS" = "true" ]; then "$SCRIPT_DIR"/setup-io-prereq.sh --zfs $DRY_RUN diff --git a/scripts/testlists.py b/scripts/testlists.py new file mode 100644 index 0000000..451c82e --- /dev/null +++ b/scripts/testlists.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +""" +Load a test list definition yaml file and +output the list of tests for a specified profile +The default delimiter is a space +Optionally + - change the delimiter + - sort the list of tests alphbetically + - return a list where each test is bracketed by install and uninstall + - return a list which starts with install and ends with uninstall +""" + +import e2e_util + +def main(args): + """ + The real main function + """ + tests = e2e_util.load_testplan(args.testplan) + if args.install: + tests.insert(0, 'install') + if args.uninstall: + tests.append('uninstall') + for test in tests: + # Code to execute for each element + print(test) + + + + + + +if __name__ == '__main__': + from argparse import ArgumentParser + + parser = ArgumentParser() + parser.add_argument('--testplan', dest='testplan', default=None, required=True, + help='testplan') + parser.add_argument('--install', dest='install', action='store_true', + default=None, + help='Add install before test list') + parser.add_argument('--uninstall', dest='uninstall', action='store_true', + default=None, + help='Add uninstall after test list') + + main(parser.parse_args()) diff --git a/src/tests/lvm/lvm_volume_provisioning/lvm_volume_provisioning_test.go b/src/tests/lvm/lvm_volume_provisioning/lvm_volume_provisioning_test.go index 0de75fd..4eb72f3 100644 --- a/src/tests/lvm/lvm_volume_provisioning/lvm_volume_provisioning_test.go +++ b/src/tests/lvm/lvm_volume_provisioning/lvm_volume_provisioning_test.go @@ -35,7 +35,7 @@ func volumeProvisioningTest(decor string, engine common.OpenEbsEngine, volType c ImgDir: "/tmp", } - workerNodes, err := lvm.ListLvmNode(common.NSMayastor()) + workerNodes, err := lvm.ListLvmNode(common.NSOpenEBS()) Expect(err).ToNot(HaveOccurred(), "failed to list worker node") nodeConfig = lvm.LvmNodesDevicePvVgConfig{ diff --git a/testplans/common.yaml b/testplans/common.yaml new file mode 100644 index 0000000..b4f1158 --- /dev/null +++ b/testplans/common.yaml @@ -0,0 +1,8 @@ +meta: + environment: {} + name: 'install uninstall' + description: 'install and uninstall tests' + comment: This file includes the common set of testsuites for given testplan +testsuites: + - install + - uninstall \ No newline at end of file diff --git a/testplans/hostpath.yaml b/testplans/hostpath.yaml new file mode 100644 index 0000000..a550c8e --- /dev/null +++ b/testplans/hostpath.yaml @@ -0,0 +1,8 @@ +meta: + environment: {} + name: 'hostpath' + description: 'hostpath e2e tests' + include: + - common +testsuites: + - hostpath_volume_provisioning \ No newline at end of file diff --git a/testplans/lvm.yaml b/testplans/lvm.yaml new file mode 100644 index 0000000..100309c --- /dev/null +++ b/testplans/lvm.yaml @@ -0,0 +1,8 @@ +meta: + environment: {} + name: 'lvm' + description: 'lvm e2e tests' + include: + - common +testsuites: + - lvm_volume_provisioning \ No newline at end of file diff --git a/testplans/selfci.yaml b/testplans/selfci.yaml new file mode 100644 index 0000000..c40d41b --- /dev/null +++ b/testplans/selfci.yaml @@ -0,0 +1,8 @@ +meta: + environment: {} + name: 'selfci' + description: 'tests for e2e code validation' + include: + - common +testsuites: + - lvm_volume_provisioning diff --git a/testplans/zfs.yaml b/testplans/zfs.yaml new file mode 100644 index 0000000..61e72b5 --- /dev/null +++ b/testplans/zfs.yaml @@ -0,0 +1,8 @@ +meta: + environment: {} + name: 'zfs' + description: 'zfs e2e tests' + include: + - common +testsuites: + - zfs_volume_provisioning \ No newline at end of file