firesim/.github/scripts/run-ini-api-tests.py

89 lines
3.3 KiB
Python
Raw Normal View History

Port to Python3 + Switch to GH-A CI (#878) * First pass at porting to python3 * Fix import errors | Setup user argcomplete * Update awstools CLI with user data file | Bump CI to use it * Wait until launch is complete * Add userdata as string | Use sudo for machine-launch-script * Remove execute permissions on machine-launch-script * Better match on machine-launch-script complete * Revert python-devel removal * Use python3 for pytests * Update more python3 items * Remove extra shebang * Port docs to python3 and add to CI * Add ISCA experiments to CI build check * Use yum not apt-get * Add make to doc section * Bump multilate-loadgen for sysroot fix * For BW test build don't use shebang * Fix docs Makefile options * Fix more doc warnings * Add first set of regression tests * Fix raw_input * Regression bump | Run workload fix * Add functools to topology * Fix linux poweroff test (nic still has issues) * Update regression scripts * Ignore machine-launch-script.sh in regression area * Fix map python3 issues * Get rid of shebangs * Fix more regressions * Print machine-launch.log on fail | More clarification on user_data * Transfer to CI some shorter regressions * Add a manual approval to fpga based tests * Fix indentation in config.yml * Fix test symlink * Use spot for CI manager instance | Try to use python3 for aws CI container | Version all pip packages * Make run-ini-api-tests an executable * Fix CI terminaterunfarm arg * Add firesim.pem file to manager * Bump python in CI instance * Bump pip in CI container * Remove pip sudo in CI container * Fix launch script pip version equals * Ini converted into strings * Properly pass test_dir to opts in CI * First pass at GH-A * Round 2 CI fixes * Try changes * Remove CircleCI | Switch to fancy GH-A * Rename self-host setup script * Update chmod * Use - instead of _ for env. vars * Rename some defs | Remove extra imports * Small comment updates * Forgot to import in ini-api tests | Small comment on Fabric timeouts * Add sys to linux poweroff * Update linux timeout, fix small imports * Update comment * Fix-up workflow-monitor.py * Avoid excessive logging in run-linux | Terminate spot instances after max-runtime * Add more workflow-monitor states | Add pty=False to running workloads * Update CI documentation | Add CI badge [ci skip] * Don't use spot instances * Update CI readme * Determine runner version from remote repo and check for runner setup * Address PR comments * Update CI_README location of where to find IPs | Forgot ret_code * Only run CI on prs/pushes to dev/main/master * Fix terminate_workflow_instances in init-manager.py * Cleanup FireSim repo cloning | Only run CI on PRs (since its runs on merge commit)
2022-01-21 03:03:37 +08:00
#!/usr/bin/env python3
from fabric.api import *
from common import manager_fsim_dir, manager_ci_dir, manager_fsim_pem, set_fabric_firesim_pem
import sys
def run_build_recipes_ini_api_tests():
""" Test config_{build, build_recipes}.ini APIs """
def commands_to_run(commands, opts):
""" Run a list of commands with the specified opts """
for command in commands:
with prefix('cd {} && source sourceme-f1-manager.sh'.format(manager_fsim_dir)):
rc = 0
with settings(warn_only=True):
rc = run("{} {}".format(command, opts)).return_code
if rc == 0:
print("{} passed unexpectedly.".format(command))
# exit since passing is not wanted
sys.exit(1)
def run_test(name):
# test files should exist on the manager already
test_dir = "{}/ini-tests/failing-buildafi-files/{}".format(manager_ci_dir, name)
commands_to_run(
["firesim buildafi"],
"-b {}/sample_config_build.ini -r {}/sample_config_build_recipes.ini".format(test_dir, test_dir))
run_test("invalid-build-section")
run_test("invalid-recipe-inst-type")
# test invalid config_build.ini
commands_to_run(["firesim buildafi"], "-b ~/GHOST_FILE")
# test invalid config_build_recipes.ini
commands_to_run(["firesim buildafi"], "-r ~/GHOST_FILE")
def run_runtime_hwdb_ini_api_tests():
""" Test config_{runtime, hwdb}.ini APIs """
def commands_to_run(commands, opts):
""" Run a list of commands with the specified opts """
for command in commands:
with prefix('cd {} && source sourceme-f1-manager.sh'.format(manager_fsim_dir)):
rc = 0
with settings(warn_only=True):
rc = run("{} {}".format(command, opts)).return_code
if rc == 0:
print("{} passed unexpectedly.".format(command))
# test passed so make sure to terminate runfarm
run("firesim terminaterunfarm -q {}".format(opts))
# exit since passing is not wanted
sys.exit(1)
def run_test(name):
# test files should exist on the manager already
test_dir = "{}/ini-tests/failing-runtime-files/{}".format(manager_ci_dir, name)
commands_to_run(
["firesim launchrunfarm", "firesim infrasetup", "firesim runworkload", "firesim terminaterunfarm -q"],
"-c {}/sample_config_runtime.ini -a {}/sample_config_hwdb.ini".format(test_dir, test_dir))
run_test("hwdb-invalid-afi")
run_test("runtime-invalid-hwconfig")
run_test("runtime-invalid-topology")
run_test("runtime-invalid-workloadname")
# test invalid config_runtime.ini
commands_to_run(["firesim launchrunfarm", "firesim infrasetup", "firesim runworkload", "firesim terminaterunfarm -q"], "-c ~/GHOST_FILE")
# test invalid config_hwdb.ini
commands_to_run(["firesim launchrunfarm", "firesim infrasetup", "firesim runworkload", "firesim terminaterunfarm -q"], "-a ~/GHOST_FILE")
def run_ini_api_tests():
""" Test manager .ini file APIs """
run_build_recipes_ini_api_tests()
run_runtime_hwdb_ini_api_tests()
if __name__ == "__main__":
set_fabric_firesim_pem()
execute(run_ini_api_tests, hosts=["localhost"])