Skip to content

test: run openedx and common tests with both lms and cms settings - #29676

Merged
mraarif merged 2 commits into
masterfrom
iamsobanjaved/BOM-3103
Jan 21, 2022
Merged

test: run openedx and common tests with both lms and cms settings#29676
mraarif merged 2 commits into
masterfrom
iamsobanjaved/BOM-3103

Conversation

@iamsobanjaved

Copy link
Copy Markdown
Contributor

Previously some tests from openedx and common were running in both lms and cms test suite under Jenkins. But after shifting CI to GHA, those tests were running only with lms settings so now updated that run with both settings.

More details: BOM-3103

@mraarif
mraarif force-pushed the iamsobanjaved/BOM-3103 branch 6 times, most recently from 7b0a319 to d6fe637 Compare January 3, 2022 16:46
@mraarif
mraarif requested a review from jmbowman January 3, 2022 16:47
Comment thread .github/workflows/unit-test-shards.json Outdated
"common-1": "common/djangoapps/",
"common-2": "common/lib/"
"lms-1": {
"path": ["lms/djangoapps/badges/","lms/djangoapps/branding/","lms/djangoapps/bulk_email/","lms/djangoapps/bulk_enroll/","lms/djangoapps/bulk_user_retirement/","lms/djangoapps/ccx/","lms/djangoapps/certificates/","lms/djangoapps/commerce/"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please format this list with one item per line so that diffs will make more sense. (Also, "path" is an odd name for a list of paths?)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

current formatting is more readable since it shows which apps are being tested against cms or lms settings, in my opinion, this is easier to understand for developers not aware of the whole sharding strategy
we can change the formatting but we'd have to scroll to the end to see the config for each shard

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, I worded it poorly. I was suggesting it look like this:

{
  "lms-1": {
    "settings": "lms.envs.test",
    "paths": [
      "lms/djangoapps/badges/",
      "lms/djangoapps/branding/",
      "lms/djangoapps/bulk_email/",
      "lms/djangoapps/bulk_enroll/",
      ..etc..
    ]
  },
  "lms-2": {
    ...
  },
  ...
}

Comment thread .github/workflows/verify-gha-unit-tests-count.yml
Comment thread scripts/gha_unit_tests_collector.py Outdated
sys.stdout.write(unit_test_paths)
modules = get_unit_test_modules("cms") if argument.cms_only else get_unit_test_modules("lms")
paths_output = ' '.join(modules)
sys.stdout.write(paths_output)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's no reason to use sys.stdout.write. Just use print.


unit_test_paths = ' '.join(modules)
sys.stdout.write(unit_test_paths)
modules = get_unit_test_modules("cms") if argument.cms_only else get_unit_test_modules("lms")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
modules = get_unit_test_modules("cms") if argument.cms_only else get_unit_test_modules("lms")
modules = get_unit_test_modules("cms" if argument.cms_only else "lms")

Comment thread scripts/unit_test_shards_parser.py Outdated

def get_test_paths_for_shard(shard_name):
def load_unit_test_shards(shard_name):
unit_tests_json = f'{os.getcwd()}/.github/workflows/unit-test-shards.json'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's no need to put getcwd into this path, the current directory is the default for opening files.

Comment thread scripts/unit_test_shards_parser.py Outdated
def load_unit_test_shards(shard_name):
unit_tests_json = f'{os.getcwd()}/.github/workflows/unit-test-shards.json'
with open(unit_tests_json) as file:
unit_test_workflow_shards = json.loads(file.read())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
unit_test_workflow_shards = json.loads(file.read())
unit_test_workflow_shards = json.load(file)

Comment thread scripts/unit_test_shards_parser.py Outdated
Comment on lines +33 to +35
output = get_settings_for_shard(argument.shard_name) if argument.output == "settings" \
else " ".join(get_test_paths_for_shard(argument.shard_name))
sys.stdout.write(output)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't use an if expression if you have to split it across lines:

Suggested change
output = get_settings_for_shard(argument.shard_name) if argument.output == "settings" \
else " ".join(get_test_paths_for_shard(argument.shard_name))
sys.stdout.write(output)
if argument.output == "settings":
print(get_settings_for_shard(argument.shard_name))
else:
print(" ".join(get_test_paths_for_shard(argument.shard_name))



def get_modules_except_cms():
def get_unit_test_modules(module_name="lms"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you always call the function with an explicit argument, it's better to leave off the default.

Comment thread scripts/gha_unit_tests_collector.py Outdated
Comment thread scripts/gha_unit_tests_collector.py Outdated
@mraarif
mraarif force-pushed the iamsobanjaved/BOM-3103 branch 3 times, most recently from b6cce2c to 4fa6cf8 Compare January 11, 2022 11:34
@mraarif
mraarif requested a review from nedbat January 11, 2022 11:52
@mraarif
mraarif force-pushed the iamsobanjaved/BOM-3103 branch from 4fa6cf8 to ca08b63 Compare January 11, 2022 11:54
Comment thread scripts/gha_unit_tests_collector.py Outdated
@nedbat

nedbat commented Jan 11, 2022

Copy link
Copy Markdown
Contributor

I was first looking at this code because I had a PR failing because the test counts were wrong. I couldn't figure out how to fix things. Will you be adding some explanation about what to do if the check fails?

@mraarif
mraarif force-pushed the iamsobanjaved/BOM-3103 branch 2 times, most recently from 6297ffd to f4ecded Compare January 12, 2022 09:15
@mraarif
mraarif requested a review from nedbat January 12, 2022 09:18
Comment thread scripts/gha-shards-readme.md Outdated
Comment thread scripts/gha-shards-readme.md Outdated
Comment thread scripts/gha-shards-readme.md Outdated
Comment thread scripts/gha-shards-readme.md Outdated
Comment thread scripts/gha-shards-readme.md Outdated
Comment thread scripts/gha-shards-readme.md Outdated
Comment thread scripts/gha-shards-readme.md Outdated
Comment thread scripts/gha-shards-readme.md Outdated
@mraarif
mraarif force-pushed the iamsobanjaved/BOM-3103 branch 2 times, most recently from 6b2ed1d to 504596c Compare January 12, 2022 11:03

@nedbat nedbat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the write-up!

Comment thread scripts/gha-shards-readme.md Outdated
Comment thread scripts/gha-shards-readme.md Outdated
@mraarif
mraarif force-pushed the iamsobanjaved/BOM-3103 branch from 504596c to 1b4d236 Compare January 12, 2022 15:56

@nedbat nedbat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One real question: how to decide where to add new apps?

Comment thread scripts/gha-shards-readme.md Outdated
Comment thread scripts/gha-shards-readme.md Outdated
@mraarif
mraarif force-pushed the iamsobanjaved/BOM-3103 branch from 319534a to 2aa13fd Compare January 12, 2022 17:46
Comment thread .github/workflows/unit-test-shards.json Outdated
@mraarif
mraarif force-pushed the iamsobanjaved/BOM-3103 branch 2 times, most recently from 226abee to 606d4ab Compare January 17, 2022 17:40
@mraarif
mraarif force-pushed the iamsobanjaved/BOM-3103 branch from 606d4ab to 4700a70 Compare January 21, 2022 06:29
@mraarif
mraarif merged commit 4e22a38 into master Jan 21, 2022
@mraarif
mraarif deleted the iamsobanjaved/BOM-3103 branch January 21, 2022 06:58
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

1 similar comment
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

ztraboo added a commit to CUCWD/edx-platform that referenced this pull request Apr 7, 2022
Agrendalath pushed a commit to open-craft/openedx-platform that referenced this pull request Jun 7, 2022
Agrendalath pushed a commit to open-craft/openedx-platform that referenced this pull request Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants