Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More deterministic tests #3336

Merged
merged 3 commits into from
Sep 9, 2019
Merged

Conversation

matthewrmshin
Copy link
Contributor

@matthewrmshin matthewrmshin commented Aug 29, 2019

Remove many sleeps in favour of detecting events.

test_header: new function to install, validate and run reference test.

  • Fewer lines and flavours for many test files.

test_header: dedicated poll related functions to simplify usage patterns.

  • Also reversed the logic of the poll function, as most usage were doing poll ! ....

New function to poll suite log in cylc/flow/etc/job.sh. Will follow in #3346.

Remove unit tests duplicated in battery.

Move cylc.wallclock tests from battery to unit test.

These changes partially address #3046.

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Already covered by existing tests.
  • No change log entry required (why? e.g. invisible to users).
  • No documentation update required.

out Outdated Show resolved Hide resolved
tests/cylc-cat-log/00-local.t Outdated Show resolved Hide resolved
tests/cylc-cat-log/06-log-rotation.t Outdated Show resolved Hide resolved
while test "$(grep -cF 'Reload completed' "${CYLC_SUITE_LOG_DIR}/log")" -ne "$1"
do
sleep 1
done
Copy link
Member

Choose a reason for hiding this comment

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

Might want to add some form of timeout to these tests prevent them from hanging.

Copy link
Member

Choose a reason for hiding this comment

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

Use the poll function from test_header - it now aborts after a minute if condition not met.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if there is an easy way to expose the test battery poll function in the job scripts.

Copy link
Member

Choose a reason for hiding this comment

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

Set PATH at the suite level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No straightforward. It is a shell function in the test_header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the purpose of this change, we should have a way to share the shell function, because the pattern is repeated in many places. I wonder if we should just add the function to cylc/flow/etc/job.sh? Maybe users can make use of a poll function in their task jobs as well?

Copy link
Member

Choose a reason for hiding this comment

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

There are multiple test functions it might be useful to run from within a suite. How about moving the functions out of the test header into another file which can easily be sourced in a pre-script or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, a library of shell functions is definitely useful, but probably outside the scope of this PR.

Copy link
Member

Choose a reason for hiding this comment

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

New issue for this: #3346

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a function to cylc/flow/etc/job.sh to allow job scripts that have the same poll suite log pattern to simple call a function. We can generalise this as part of #3346.

tests/triggering/fam-finish-any/suite.rc Show resolved Hide resolved
@matthewrmshin
Copy link
Contributor Author

matthewrmshin commented Sep 3, 2019

This is not done yet. I have yet to do capture:

  • All the files that run a basic validate + reference test.
  • A few more unnecessary sleeps.

@matthewrmshin
Copy link
Contributor Author

matthewrmshin commented Sep 3, 2019

The tests are definitely more stable, but I am not really seeing any overall speed gain (although most of the heavily modified tests do run faster individually), so removing the faster bit from the title.

@matthewrmshin matthewrmshin changed the title Faster and more deterministic tests More deterministic tests Sep 3, 2019
@matthewrmshin
Copy link
Contributor Author

Tests very stable in my environment, but not so on Travis CI. I'll continue to monitor.

@matthewrmshin matthewrmshin force-pushed the fix-tests-again branch 4 times, most recently from 1e71f28 to 58fe9aa Compare September 4, 2019 22:14
@matthewrmshin matthewrmshin marked this pull request as ready for review September 6, 2019 08:37
@hjoliver
Copy link
Member

hjoliver commented Sep 6, 2019

Is this ready to for a final review or are you still working on it?

@matthewrmshin
Copy link
Contributor Author

This is ready. (More work can be done in follow-on PRs.)

try:
assert get_unix_time_from_time_string(time_str) == time_sec
finally:
CALENDAR.set_mode(mode)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change replaces tests/cylc.wallclock/00-single.t

#-------------------------------------------------------------------------------
run_ok "${TEST_NAME_BASE}-cycling-iso8601" python3 -m 'cylc.flow.cycling.iso8601'
run_ok "${TEST_NAME_BASE}-cycling-integer" python3 -m 'cylc.flow.cycling.integer'
run_ok "${TEST_NAME_BASE}-cycling" python3 -c 'import cylc.flow.cycling'
Copy link
Member

Choose a reason for hiding this comment

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

Huh, I guess this used to actually run some primitive unit tests in the source modules, and we forgot to delete it once we started doing unit tests separately.

Copy link
Member

@hjoliver hjoliver left a comment

Choose a reason for hiding this comment

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

Looks good, no problems found 👍

Remove many sleeps in favour of detecting events.

test_header: new function to install, validate and run reference test.
Dedicated functions for the usage patterns.
Positive poll logic.
This is a temporary measure to address the repeated pattern in various test
suites where we have to repeatedly poll the suite log for events.
@matthewrmshin
Copy link
Contributor Author

Re-based to pick up and test with latest changes.

@oliver-sanders oliver-sanders merged commit 5899d66 into cylc:master Sep 9, 2019
@matthewrmshin matthewrmshin removed this from the cylc-8.0a2 milestone Sep 9, 2019
@matthewrmshin matthewrmshin added this to the cylc-8.0a1 milestone Sep 9, 2019
@matthewrmshin matthewrmshin deleted the fix-tests-again branch September 9, 2019 17:44
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.

3 participants