-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit! Hurray! Refer readme for more info.
- Loading branch information
1 parent
ef7c863
commit 1e241c8
Showing
66 changed files
with
7,875 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
*.pyc | ||
/workspace/TestRuns/* | ||
/workspace/* | ||
docs/build/* | ||
/.vs | ||
/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,63 @@ | ||
# ocp-diag-ctam | ||
# CTAM Compliance Tool for Accelerator Management | ||
|
||
This tool provides acceptance testing for Accelerator Management in cloud data centers. | ||
|
||
## Getting Started | ||
|
||
1. Optional: create python virtual environment | ||
2. Run | ||
python -m pip install -r pip-requirements.txt | ||
3. For full documentation, from /docs directory, run | ||
./make html | ||
Open docs/build/html/index.html for full documentation including architecture and test case details | ||
4. To run suite, | ||
cd ctam | ||
python ctam.py -w ..\example_workspace | ||
Logs will be created under example_workspace\TestRuns | ||
5. To list all test cases | ||
cd ctam | ||
python ctam.py -l | ||
|
||
To run a test/suite, you will need to create a workspace with the relevant support files. | ||
Refer json_spec for the needed input files for format. Feel free to reach out to the contributors for help here. | ||
|
||
|
||
6. To run a specific test case | ||
cd ctam | ||
python ctam.py -w ..\example_workspace -t <test case id> | ||
Logs will be created under example_workspace\TestRuns | ||
7. To run test cases of a specifc test group | ||
cd ctam | ||
python ctam.py -w ..\example_workspace -g <test group name> | ||
Logs will be created under example_workspace\TestRuns | ||
8. Choose test cases to run by using tags and specifying the tags to include/exclude in test_runner.json | ||
|
||
|
||
|
||
## VS Code | ||
|
||
VS Code is not required for development, however it does have workspace configurations to assist in development. | ||
In lieu of VS Code usage, the following items should be configured for other editors or the developer should perform | ||
steps manually to ensure the consistency of the code base. | ||
|
||
To use VS Code, open the ctam.code-workspace | ||
|
||
1. automatic file formatting using python black formatter on file save. | ||
a. "--line-length", "120" | ||
2. Indent set to 4 spaces | ||
3. Auto docstring configured for sphinx, type 3 double quotes below python class or function and the documentation header is automatically stubbed out. | ||
4. Automatic mypy checking of code | ||
5. spell checking | ||
6. useful git extensions | ||
7. Useful debugger configurations defined in launch.json, extensible | ||
8. Useful Code snippets to jump start new test development | ||
a. Snippets for interfaces, test groups and test cases simplify new tests. | ||
b. easy replace of TODO in the snippet creates runnable test case quickly. | ||
|
||
## Upcoming changes | ||
|
||
1. More test cases | ||
2. Logging improvements | ||
3. Ability to set test sequence | ||
4. PLDM validator, and auto creation of PLDM bundles with error injection. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "." | ||
} | ||
], | ||
"settings": { | ||
"editor.detectIndentation": false, | ||
"editor.indentSize": "tabSize", | ||
"editor.formatOnSave": true, | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter" | ||
}, | ||
"python.formatting.provider": "none", | ||
"python.formatting.blackArgs": [ | ||
"--line-length", | ||
"120" | ||
], | ||
"autoDocstring.startOnNewLine": true, | ||
"autoDocstring.docstringFormat": "sphinx", | ||
"python.linting.mypyEnabled": true, | ||
"mypy.targets": [], | ||
"cSpell.words": [ | ||
"comptool", | ||
"ctam", | ||
"mypy", | ||
"ocptv", | ||
"rtype", | ||
"testgroup", | ||
"testrun" | ||
] | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# Copyright (c) Microsoft Corporation | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
import os | ||
import argparse | ||
import sys | ||
from test_hierarchy import TestHierarchy | ||
from test_runner import TestRunner | ||
import traceback | ||
|
||
|
||
def parse_args(): | ||
""" | ||
:Description: Parse command line arguments | ||
:returns: Parsed arguments list | ||
:rtype: List | ||
""" | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"-t", | ||
"--testcase", | ||
help="Runs a single test case. Overrides test_runner.json in the workspace", | ||
type=str, | ||
) | ||
|
||
parser.add_argument("-s", "--Suite", help="Run full ACT Suite", action="store_true") | ||
|
||
parser.add_argument( | ||
"-g", | ||
"--group", | ||
help="Run tests for a single group. Overrides test_runner.json in the workspace", | ||
type=str, | ||
) | ||
|
||
parser.add_argument( | ||
"-d", "--Discovery", help="Perform System Discovery", action="store_true" | ||
) | ||
|
||
parser.add_argument( | ||
"-w", | ||
"--workspace", | ||
required="-l" not in sys.argv and "--list" not in sys.argv, | ||
help="Path to workspace directory that contains test run files", | ||
) | ||
|
||
parser.add_argument( | ||
"-l", | ||
"--list", | ||
help="List all test cases. If combined with -G then list all cases of the chosen group ", | ||
action="store_true", | ||
) | ||
|
||
return parser.parse_args() | ||
|
||
|
||
if __name__ == "__main__": | ||
args = parse_args() | ||
|
||
try: | ||
# builds hierarchy of test groups and associated test cases | ||
test_hierarchy = TestHierarchy( | ||
os.path.join(os.getcwd(), "tests"), os.path.join(os.getcwd(), "interfaces") | ||
) | ||
|
||
if args.list: | ||
test_hierarchy.print_test_groups_test_cases(args.group) | ||
exit(0) | ||
|
||
if not os.path.isdir(args.workspace): | ||
print("Invalid workspace specified") | ||
exit(1) | ||
required_workspace_files = [ | ||
"dut_info.json", | ||
"package_info.json", | ||
"test_runner.json", | ||
"redfish_uri_config.json", | ||
".netrc", | ||
] | ||
|
||
missing_files = [ | ||
file | ||
for file in required_workspace_files | ||
if not os.path.isfile(os.path.join(args.workspace, file)) | ||
] | ||
|
||
if missing_files: | ||
for file_name in missing_files: | ||
print(f"The required file {file_name} does not exist in the workspace.") | ||
exit(1) | ||
print(f"Worlspace : {args.workspace}") | ||
test_runner_json = os.path.join(args.workspace, "test_runner.json") | ||
dut_info_json = os.path.join(args.workspace, "dut_info.json") | ||
package_info_json = os.path.join(args.workspace, "package_info.json") | ||
redfish_uri_config = os.path.join(args.workspace, "redfish_uri_config.json") | ||
net_rc = os.path.join(args.workspace, ".netrc") | ||
|
||
if args.testcase: | ||
runner = TestRunner( | ||
test_hierarchy=test_hierarchy, | ||
test_runner_json_file=test_runner_json, | ||
dut_info_json_file=dut_info_json, | ||
package_info_json_file=package_info_json, | ||
redfish_uri_config_file=redfish_uri_config, | ||
net_rc=net_rc, | ||
single_test_override=args.testcase, | ||
) | ||
elif args.group: | ||
runner = TestRunner( | ||
test_hierarchy=test_hierarchy, | ||
test_runner_json_file=test_runner_json, | ||
dut_info_json_file=dut_info_json, | ||
package_info_json_file=package_info_json, | ||
redfish_uri_config_file=redfish_uri_config, | ||
net_rc=net_rc, | ||
single_group_override=args.group, | ||
) | ||
else: | ||
runner = TestRunner( | ||
test_hierarchy=test_hierarchy, | ||
test_runner_json_file=test_runner_json, | ||
dut_info_json_file=dut_info_json, | ||
package_info_json_file=package_info_json, | ||
net_rc=net_rc, | ||
redfish_uri_config_file=redfish_uri_config, | ||
) | ||
|
||
runner.run() | ||
|
||
except (NotImplementedError, Exception) as e: | ||
exception_details = traceback.format_exc() | ||
print(f"Test Run Failed: {exception_details}") | ||
exit(1) |
Empty file.
Oops, something went wrong.