-
Notifications
You must be signed in to change notification settings - Fork 746
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into support_qos_kvm
- Loading branch information
Showing
99 changed files
with
5,487 additions
and
1,721 deletions.
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
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,12 @@ | ||
steps: | ||
- script: | | ||
set -x | ||
pip3 install natsort | ||
python3 ./.azure-pipelines/markers_check/markers_check.py tests | ||
if [[ $? -ne 0 ]]; then | ||
echo "##vso[task.complete result=Failed;]Markers check fails." | ||
exit 1 | ||
fi | ||
displayName: "Markers Check" |
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,70 @@ | ||
import re | ||
import os | ||
import sys | ||
import logging | ||
|
||
from natsort import natsorted | ||
|
||
|
||
def collect_scripts_without_topology_markers(): | ||
""" | ||
This function collects all test scripts under the folder 'tests/' and check the topology type marked in the script. | ||
Returns: | ||
List: A list of test scripts without the topology type marker. | ||
""" | ||
location = sys.argv[1] | ||
|
||
# Recursively find all scripts starting with "test_" and ending with ".py" | ||
# Note: The full path and name of files are stored in a list named "scripts" | ||
scripts = [] | ||
for root, dirs, script in os.walk(location): | ||
for s in script: | ||
if s.startswith("test_") and s.endswith(".py"): | ||
scripts.append(os.path.join(root, s)) | ||
scripts = natsorted(scripts) | ||
|
||
# Open each script and search for regex pattern | ||
pattern = re.compile(r"[^@]pytest\.mark\.topology\(([^\)]*)\)") | ||
|
||
scripts_without_marker = [] | ||
|
||
for s in scripts: | ||
has_markers = False | ||
# Remove prefix from file name: | ||
script_name = s[len(location) + 1:] | ||
try: | ||
with open(s, 'r') as script: | ||
for line in script: | ||
# Get topology type of script from marker `pytest.mark.topology` | ||
match = pattern.search(line) | ||
if match: | ||
has_markers = True | ||
break | ||
|
||
if not has_markers: | ||
scripts_without_marker.append(script_name) | ||
|
||
except Exception as e: | ||
raise Exception('Exception occurred while trying to get marker in {}, error {}'.format(s, e)) | ||
|
||
return scripts_without_marker | ||
|
||
|
||
def main(): | ||
try: | ||
scripts_without_marker = collect_scripts_without_topology_markers() | ||
|
||
if scripts_without_marker: | ||
for script in scripts_without_marker: | ||
print("\033[31mPlease add mark `pytest.mark.topology` in script {}\033[0m".format(script)) | ||
sys.exit(1) | ||
|
||
sys.exit(0) | ||
except Exception as e: | ||
logging.error(e) | ||
sys.exit(2) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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
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
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
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
Oops, something went wrong.