Skip to content

{CI} Enable incremental test on commnad modules only#12657

Merged
haroldrandom merged 9 commits intodevfrom
incremental-test-old-azdev
Mar 23, 2020
Merged

{CI} Enable incremental test on commnad modules only#12657
haroldrandom merged 9 commits intodevfrom
incremental-test-old-azdev

Conversation

@haroldrandom
Copy link
Contributor

@haroldrandom haroldrandom commented Mar 19, 2020

Scenario of modified files:

  1. Modified files in src/azure-cli-core/azure/cli/core ([CI] Incremental test on modifying core #12658) - 83mins
  2. Modified files in src/azure-cli-telemetry/ ([CI] test on modifying telemetry #12662) - 53mins
  3. Modified files in src/azure-cli/azure/cli/command_modules/network ([CI] incremental test on modifying network test #12661) take 11 mins.
  4. Modified files in srv/azure-cli/azure/cli/command_modules/vm ([CI] incremental test on modifying vm test #12664) take 11 mins.
  5. Modified files in src/azure-cli-testsdk/ ([CI] Incremental test on modifying testsdk #12666) - 48mins
  6. Modified files in vm and network ([CI] Incremental test on vm and network #12665) - 14mins.
  7. Modified files in network and storage ([CI] Incremental Test on command modules: network and storage #12676), - 14 mins.

This checklist is used to make sure that common guidelines for a pull request are followed.

@Azure Azure deleted a comment from azure-pipelines bot Mar 19, 2020
@Azure Azure deleted a comment from azure-pipelines bot Mar 19, 2020
@haroldrandom haroldrandom marked this pull request as ready for review March 19, 2020 08:06
@yonzhan
Copy link
Collaborator

yonzhan commented Mar 19, 2020

incremental test

@haroldrandom haroldrandom requested a review from arrownj March 19, 2020 08:45
Copy link
Member

@qianwens qianwens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Comment on lines +113 to +122
else:
test_paths = set()
for mod in modified_modules:
try:
test_paths.add(os.path.normpath(test_index[mod]))
except KeyError:
display("no tests found in module: {}".format(mod))
args.tests = test_paths

selected_modules = []
Copy link
Member

@fengzhou-msft fengzhou-msft Mar 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the below code, both selected_modules and args.tests are set, but here you cleaned selected_modules instead of setting to modified_modules. What's the difference?

else:
# Otherwise run specific tests
args.tests = args.tests or []
# Add any tests from file
if args.src_file:
with open(args.src_file, 'r') as f:
for line in f.readlines():
line = line.strip('\r\n')
line = line.strip('\n')
if line not in args.tests:
args.tests.append(line)
test_paths = []
selected_modules = []
for t in args.tests:
try:
test_path = os.path.normpath(test_index[t])
mod_name = extract_module_name(test_path)
test_paths.append(test_path)
if mod_name not in selected_modules:
selected_modules.append(mod_name)
except KeyError:
display("Test '{}' not found.".format(t))
continue
selected_modules = filter_user_selected_modules_with_tests(selected_modules, args.profile)
args.tests = test_paths

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selected_modules is a list of tuple which consist of 3 elements, like:

selected_modules = [('All modules', 'azure.cli', 'azure.cli'),
('CLI Linter', 'automation.cli_linter', 'automation.cli_linter')]

The last element of the tuple is a Python Namesapce.

In the incremental test case, I identify module from modified files and then extract module name from it.
So the modified_modules is a list of Python module name like core, vm, storage.
Then I extract corresponding tests from testIndex.json which is generated from get_test_index().

In the runner:

def run_tests(modules, parallel, run_live, tests):
if not modules and not tests:
display('No tests set to run.')
sys.exit(1)
display("""
=============
Run Tests
=============
""")
if modules:
display('Modules: {}'.format(', '.join(name for name, _, _ in modules)))
# set environment variable
if run_live:
os.environ['AZURE_TEST_RUN_LIVE'] = 'True'
test_paths = tests or [p for _, _, p in modules]
display('Drive test by nosetests')
runner = get_nose_runner(parallel=parallel, process_timeout=3600 if run_live else 600)
results = runner([path for path in test_paths])
return results, []

tests has higher priority than the module.
So, when I have the extract test need to run, no need to provide selected_module.

@haroldrandom haroldrandom changed the title {CI} Enable incremental test on commnad modules {CI} Enable incremental test on commnad modules only Mar 20, 2020
@yonzhan yonzhan added this to the S167 milestone Mar 20, 2020
@haroldrandom haroldrandom merged commit 1ba462d into dev Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants