Skip to content

Commit

Permalink
add github action to run lvm tests
Browse files Browse the repository at this point in the history
Signed-off-by: rohan2794 <[email protected]>
  • Loading branch information
rohan2794 committed Sep 6, 2024
1 parent eaaab40 commit e842f89
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 8 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -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"
46 changes: 46 additions & 0 deletions scripts/e2e-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

set -eu

SCRIPTDIR=$(dirname "$(realpath "$0")")
EXITV_INVALID_OPTION=1

help() {
cat <<EOF
Usage: $0 [OPTIONS]
Options:
--testplan Test plan[lvm, zfs, hostpath, selfci etc.]
Examples:
$0 --testplan lvm
EOF
}

# Parse arguments
while [ "$#" -gt 0 ]; do
case "$1" in
-T|--testplan)
shift
testplan="$1"
;;
*)
echo "Unknown option: $1"
help
exit $EXITV_INVALID_OPTION
;;
esac
shift
done

echo "Testplan: $testplan"
# Get the array elements from the command-line argument
array_str=$(python3 $SCRIPTDIR/testlists.py --testplan $testplan --install)

# Split the string into an array
array=($array_str)

# Iterate through the array
for test in "${array[@]}"; do
echo "Test: $test"
$SCRIPTDIR/exec-tests.sh --tests $test --local true --product openebs --replicated_engine false
done
27 changes: 27 additions & 0 deletions scripts/e2e_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'''
Utility functions for e2e python3 scripts
'''

import os
import sys
import yaml

e2e_root = os.path.realpath(sys.path[0] + '/..')

def yaml_load(filename):
'''
utility function to load a yaml file
'''
with open(filename, encoding='UTF-8') as jfp:
return yaml.safe_load(jfp.read())


def load_testplan(testplan):
'''
load a testplan, return testcases and array of testplan meta data
'''
tplan = yaml_load(e2e_root + f'/testplans/{testplan}.yaml')
testsuites = tplan.get('testsuites', [])

return testsuites

4 changes: 2 additions & 2 deletions scripts/exec-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ echo "list of tests: $tests"
for testname in $tests; do
# Defer uninstall till after other tests have been run.
if [ "$testname" != "uninstall" ]; then
if [ -d "$TESTDIR/tests/$testname" ]; then
if [ -d "$TESTDIR/tests/lvm/$testname" ]; then
testrootdir=$TESTDIR
fqtestname="tests/$testname"
fqtestname="tests/lvm/$testname"
elif [ -d "$TESTDIR/$testname" ]; then
testrootdir=$TESTDIR
fqtestname="$testname"
Expand Down
10 changes: 5 additions & 5 deletions scripts/go-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,29 @@ fi
if golangci-lint > /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

Expand Down
1 change: 1 addition & 0 deletions scripts/k8s/deployer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions scripts/testlists.py
Original file line number Diff line number Diff line change
@@ -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())
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
8 changes: 8 additions & 0 deletions testplans/common.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions testplans/hostpath.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
meta:
environment: {}
name: 'hostpath'
description: 'hostpath e2e tests'
include:
- common
testsuites:
- hostpath_volume_provisioning
8 changes: 8 additions & 0 deletions testplans/lvm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
meta:
environment: {}
name: 'lvm'
description: 'lvm e2e tests'
include:
- common
testsuites:
- lvm_volume_provisioning
8 changes: 8 additions & 0 deletions testplans/selfci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
meta:
environment: {}
name: 'selfci'
description: 'tests for e2e code validation'
include:
- common
testsuites:
- lvm_volume_provisioning
8 changes: 8 additions & 0 deletions testplans/zfs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
meta:
environment: {}
name: 'zfs'
description: 'zfs e2e tests'
include:
- common
testsuites:
- zfs_volume_provisioning

0 comments on commit e842f89

Please sign in to comment.