Skip to content

Commit

Permalink
Adding CI tests
Browse files Browse the repository at this point in the history
Signed-off-by: Vishnu Challa <[email protected]>
  • Loading branch information
Vishnu Challa committed Aug 1, 2024
1 parent 4a48d24 commit 9b7e372
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 5 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/builders.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Builders
on:
workflow_call:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: build and install
run: |
pip install .
23 changes: 23 additions & 0 deletions .github/workflows/ci-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI tests
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
lint:
uses: ./.github/workflows/pylint.yaml

build:
uses: ./.github/workflows/builders.yaml

tests:
needs: build
uses: ./.github/workflows/tests.yaml
secrets: inherit

File renamed without changes.
11 changes: 6 additions & 5 deletions .github/workflows/pylint.yml → .github/workflows/pylint.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
name: Pylint

on: [push,pull_request]

on:
workflow_call:
jobs:
build:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install -r requirements.txt
pip install .
- name: Analysing the code with pylint
run: |
pylint -d C0103 -d R0912 $(git ls-files '*/*.py' '*.py')
47 changes: 47 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Execute tests
on:
workflow_call:
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:

- name: Install bats
uses: bats-core/[email protected]
with:
bats-version: 1.10.0
support-install: false
assert-install: false
detik-install: false
file-install: false

- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install -r requirements.txt
pip install .
- name: Execute Tests
run: |
bats -F pretty -T --print-output-on-failure test.bats
env:
TERM: linux
QE_ES_HOST: ${{ secrets.QE_ES_HOST }}
QE_ES_USERNAME: ${{ secrets.QE_ES_USERNAME }}
QE_ES_PASSWORD: ${{ secrets.QE_ES_PASSWORD }}
71 changes: 71 additions & 0 deletions test.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bats
# vi: ft=bash
# shellcheck disable=SC2086,SC2030,SC2031,SC2164


check_file_list() {
for f in "${@}"; do
if [[ ! -f ${f} ]]; then
echo "File ${f} not found"
echo "Content of $(dirname ${f}):"
ls -l "$(dirname ${f})"
return 1
fi
if [[ $(jq .[0].metricName ${f}) == "" ]]; then
echo "Incorrect format in ${f}"
cat "${f}"
return 1
fi
done
return 0
}

run_cmd(){
echo "$@"
${@}
}

setup() {
export ES_SERVER="https://$QE_ES_USERNAME:$QE_ES_PASSWORD@search-ocp-qe-perf-scale-test-elk-hcm7wtsqpxy7xogbu72bor4uve.us-east-1.es.amazonaws.com"
export es_metadata_index="perf_scale_ci*"
export es_benchmark_index="ripsaw-kube-burner*"
}

@test "orion cmd label small scale cluster density with hunter-analyze" {
run_cmd orion cmd --config "examples/label-small-scale-cluster-density.yaml" --lookback 5d --hunter-analyze
}

@test "orion cmd payload scale 4.15" {
run_cmd orion cmd --config "examples/payload-scale-415.yaml" --lookback 5d
}

@test "orion cmd payload scale 4.16 without lookback period" {
run_cmd orion cmd --config "examples/payload-scale-416.yaml"
}

@test "orion cmd readout control plane cdv2 with text output" {
run_cmd orion cmd --config "examples/readout-control-plane-cdv2.yaml" --lookback 5d --hunter-analyze --output-format text --save-output-path=output.txt
check_file_list output_cluster-density-v2-24nodes.txt
}

@test "orion cmd readout control plane node-density with json output" {
run_cmd orion cmd --config "examples/readout-control-plane-node-density.yaml" --lookback 5d --hunter-analyze --output-format json --save-output-path=output.json
check_file_list output_node-density-heavy-24nodes.json
}

@test "orion cmd readout netperf tcp with junit output" {
run_cmd orion cmd --config "examples/readout-netperf-tcp.yaml" --lookback 5d --output-format junit --hunter-analyze --save-output-path=output.xml
check_file_list output_k8s-netperf-tcp.xml
}

@test "orion cmd small scale cluster density with anomaly detection" {
run_cmd orion cmd --config "examples/small-scale-cluster-density.yaml" --lookback 5d --anomaly-detection
}

@test "orion cmd small scale node density cni with anomaly detection with a window" {
run_cmd orion cmd --config "examples/small-scale-node-density-cni.yaml" --anomaly-detection --anomaly-window 3
}

@test "orion cmd trt external payload cluster density with anomaly detection with minimum percentage" {
run_cmd orion cmd --config "examples/trt-external-payload-cluster-density.yaml" --anomaly-detection --anomaly-window 3 --min-anomaly-percent 5
}

0 comments on commit 9b7e372

Please sign in to comment.