diff --git a/README.md b/README.md index 3f3a0ff..2500358 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,3 @@ # ci A set of scripts intended to facilitate Continuous Integration (CI) testing for the various Stratis projects. - -## CI scripts: - -"stratisd.sh": stratisd test suite CI script (for the rust tests) - -# Running the stratisd test with real devices - -To run the stratisd test with scratch test devices, create the file `/etc/stratis/test_config.json`. - -The stratisd test requires four scratch devices, which should be at least about 8 GiB in size. - -The contents of the `test_config.json` file should be a JSON array of paths to the scratch devices. For example: - -``` -{ - "ok_to_destroy_dev_array_key": [ - "/dev/vdb", - "/dev/vdc", - "/dev/vdd", - "/dev/vde" - ] -} -``` - -Be sure that the last item in the array does not have a trailing comma. diff --git a/blackbox/README.md b/blackbox/README.md deleted file mode 100644 index 2d128b8..0000000 --- a/blackbox/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Stratis blackbox test run script - -The stratis-blackbox-run.sh script runs a series of "blackbox" tests against the stratisd and stratis-cli packages installed on the system. - -The blackbox test requires three scratch devices, loaded from the `/etc/stratis/test_config.json` file, which contains a JSON array of paths to the scratch devices. - -Example `/etc/stratis/test_config.json` file: - -``` -{ - "ok_to_destroy_dev_array_key": [ - "/dev/vdb", - "/dev/vdc", - "/dev/vdd" - ] -} -``` - -This blackbox test is intended to execute on a Red Hat Enterprise Linux test system. diff --git a/blackbox/parse_json.py b/blackbox/parse_json.py deleted file mode 100755 index 026873b..0000000 --- a/blackbox/parse_json.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/python3 -""" -Helper module for parsing a JSON configuration file into a usable -format for bash. -""" - -import json -import sys - - -def parse_json(path): - """ - Opens the provided JSON file and searches for the required key. - The return value is a comma-delimited string of device names. - """ - - with open(path, encoding="utf-8") as test_config_file: - json_string = test_config_file.read() - - json_data = json.loads(json_string) - ok_to_destroy = json_data.get("ok_to_destroy_dev_array_key") - if ok_to_destroy is None: - raise RuntimeError( - f"Required JSON key 'ok_to_destroy_dev_array_key' is missing in file {path}" - ) - print(",".join(ok_to_destroy)) - - -if __name__ == "__main__": - try: - TEST_CONFIG_PATH = sys.argv[1] - except IndexError as err: - raise RuntimeError( - "Required argument of test_config.json path is missing" - ) from err - - try: - parse_json(TEST_CONFIG_PATH) - except Exception as err: - raise RuntimeError(f"Parsing JSON in {TEST_CONFIG_PATH} failed: {err}") from err diff --git a/blackbox/stratis-blackbox-run.sh b/blackbox/stratis-blackbox-run.sh deleted file mode 100755 index 8f0dc9a..0000000 --- a/blackbox/stratis-blackbox-run.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -set -e - -export STRATIS_DBUS_TIMEOUT=300000 - -if [ ! -e /etc/stratis/test_config.json ]; then - echo "No test device config found; create a test_config.json" - echo "file in /etc/stratis with three devices that can be" - echo "overwritten for testing." - exit 8 -fi - -# Create an array of test devices from the test_config.json file. -TESTDEVS_RESULT=$(./parse_json.py /etc/stratis/test_config.json) -IFS="," read -a TESTDEVS <<<"$(echo $TESTDEVS_RESULT)" - -# Start running blackbox tests. -RC_BLACKBOX_STRATISD=0 -RC_BLACKBOX_STRATIS_CLI=0 - -if [ -d testing ]; then - rm -rf testing -fi - -git clone https://github.com/stratis-storage/testing - -echo "----------" -echo "Stratisd dbus timeout: $STRATIS_DBUS_TIMEOUT" -echo "Test devices: ${TESTDEVS[0]} ${TESTDEVS[1]} ${TESTDEVS[2]}" -echo "Executing blackbox test 'python3 stratisd_cert.py' against test devices..." -python3 ./testing/stratisd_cert.py -v --disk ${TESTDEVS[0]} --disk ${TESTDEVS[1]} --disk ${TESTDEVS[2]} || RC_BLACKBOX_STRATISD=1 - -echo "----------" -echo "Stratisd dbus timeout: $STRATIS_DBUS_TIMEOUT" -echo "Test devices: ${TESTDEVS[0]} ${TESTDEVS[1]} ${TESTDEVS[2]}" -echo "Executing blackbox test 'python3 stratis_cli_cert.py' against test devices..." -python3 ./testing/stratis_cli_cert.py -v --disk ${TESTDEVS[0]} --disk ${TESTDEVS[1]} --disk ${TESTDEVS[2]} || RC_BLACKBOX_STRATIS_CLI=1 - -echo "stratisd_cert result: $RC_BLACKBOX_STRATISD" -echo "stratis_cli_cert result: $RC_BLACKBOX_STRATIS_CLI" - -if [ $RC_BLACKBOX_STRATISD -gt 0 ] && [ $RC_BLACKBOX_STRATIS_CLI -gt 0 ]; then - exit 3 -fi - -if [ $RC_BLACKBOX_STRATIS_CLI -gt 0 ]; then - exit 2 -fi - -if [ $RC_BLACKBOX_STRATISD -gt 0 ]; then - exit 1 -fi diff --git a/misc_scripts/generate_test_config.py b/misc_scripts/generate_test_config.py deleted file mode 100755 index df057bd..0000000 --- a/misc_scripts/generate_test_config.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright 2021 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -generate_test_config: generate JSON text to use in a stratis test -config file (with path /etc/stratis/test_config.json), using the -given arguments as the array items. - -Example: "generate_test_config /dev/vdb1 /dev/vdb2 /dev/vdb3" -""" - -import json -import sys - - -def main(): - """ - Main method - """ - drives = sys.argv[1:] - jsonout = json.dumps({"ok_to_destroy_dev_array_key": (drives)}, indent=4) - print(jsonout) - - -if __name__ == "__main__": - main() diff --git a/stratisd.sh b/stratisd.sh deleted file mode 100755 index 3102f7c..0000000 --- a/stratisd.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -set -e - -export PATH="$HOME/.cargo/bin:$PATH" -export RUST_LOG=stratisd=debug -export TEST_BLOCKDEVS_FILE=/etc/stratis/test_config.json - -TARGET=$1 - -if [ -z $TARGET ]; then - echo "Usage: $0 test-loop | test-real" - exit 1 -fi - -# Set WORKSPACE to the top level directory that contains the stratisd git repo -if [ -z $WORKSPACE ]; then - echo "Required WORKSPACE variable not set. Set WORKSPACE to directory that contains" - echo "stratisd git repo." - exit 1 -fi - -if [ ! -d $WORKSPACE/tests/ ]; then - echo "$WORKSPACE/tests/ does not exist. Verify WORKSPACE is set to correct directory." - exit 1 -fi - -# Each CI system must have a TEST_BLOCKDEVS_FILE file populated with -# block devices that are safe to use/overwrite on the system. -# Only check for this for "make test-real". -if [ $TARGET == "test-real" ]; then - if [ -s "$TEST_BLOCKDEVS_FILE" ]; then - cp $TEST_BLOCKDEVS_FILE $WORKSPACE/tests/. - else - echo "Required file $TEST_BLOCKDEVS_FILE not found." - exit 1 - fi -fi - -cd $WORKSPACE - -# Check to see if rustup is installed. -# If so, use it to set the rust version. -# Otherwise, run with the current rust version. -set +e -which rustup 1>/dev/null 2>&1 -RC_WHICHRUSTUP=$? -set -e - -if [ $RC_WHICHRUSTUP -eq 0 ]; then - rustup default 1.74.0 -fi - -make clean -cargo clean -PROFILEDIR=debug make build-all -PROFILEDIR=debug make install -make clean-primary -make $TARGET diff --git a/teardown.sh b/teardown.sh deleted file mode 100755 index 914563b..0000000 --- a/teardown.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -echo "Terminating test processes:" -ps -ef | egrep 'stratisd.sh|make|cargo|libstratis|PPID' | grep -v grep -ps aux | egrep 'stratisd.sh|make|cargo|libstratis|RSS' | grep -v grep -pkill 'stratisd.sh|make|cargo|libstratis' -pkill 'stratisd.sh|make|cargo|libstratis' -for j in $(ps aux | grep target/debug/stratisd\ --sim | grep -v grep | awk '{print $2}'); do - echo "Terminating target/debug/stratisd --sim process $j" - kill $j -done -echo - -# Wait for a few seconds for the I/O to finish. -sleep 4 - -lsblk -i -dmsetup info -c - -# If the thin-pool devices are suspended, the next steps will fail. -# Therefore, resume them now. -# (If they're not suspended, nothing will happen.) -for j in $(dmsetup ls | grep thinpool-pool | awk '{print $1}'); do - echo "Ensuring thin-pool device is not suspended" - dmsetup resume $j - echo -done - -echo "Unmounting active stratis test mounts (if any):" -for j in $(grep stratis_testing /proc/mounts | awk '{print $2}'); do - echo $j - umount $j -done -echo - -# Now tear down the remnant stratis component devices, top to bottom. -for i in thin-fs thinpool-pool flex-thinmeta flex-thindata flex-mdv physical-originsub stratis_test_ stratis-.*private-.*-crypt; do - for j in $(dmsetup ls | grep $i | awk '{print $1}'); do - echo "Removing device:" - dmsetup info -c $j - dmsetup table $j - dmsetup remove $j - echo - done -done - -for testdevs in $(grep /dev /etc/stratis/test_config.json | tr -d \"\,); do - for wipetgt in $(blkid -p $testdevs | grep stratis | awk '{print $1}' | tr -d \:); do - echo "Wiping signature on $wipetgt:" - wipefs -a $wipetgt - done -done