Skip to content

Conversation

@akeeste
Copy link
Contributor

@akeeste akeeste commented Jun 21, 2021

This PR restructures the CI tests into class-based continuous integration tests. Right now there are classes for each:

  • regression tests
  • compilation tests
  • BEMIO
  • rotation tests
  • run from Simulink tests

Each class has specific setup, teardown and test methods. I also added tests for the BEMIO functions to ensure they are working correctly. This should make it easier to properly skip long tests (irregular Passive Yaw, MCR application, etc) by marking them "incomplete" instead of "failed".

I still need to work on improving the test runtime. Creating a draft PR so @H0R5E can review.

@akeeste akeeste added Tests/CI related WEC-Sim tests or Continuous Integration Feature new feature request labels Jun 21, 2021
@akeeste
Copy link
Contributor Author

akeeste commented Jun 22, 2021

In a few local trials I have the following approximate breakdown of runtime per test class, including the contributions of the longest individual tests. In total, the tests take about ~11 minutes when run on my laptop.

  • BEMIO tests: 10%
  • Compilation (application) tests: 51%
    • B2B case 4: 18%
    • MCR case: 8.5%
    • mooring case: 7.5%
  • Regression tests: 36%
    • regular cases: 5%
    • irregular cases: 4%
    • passive yaw cases: 27%
  • Rotation tests: 0.03%
  • Run from Simulink tests: 3%

If the application repo tests are removed as suggested in issue #619, in addition to skipping the passive yaw cases, this decreases the test runtime by ~80%. The integration tests can be gradually broken down into unit tests over time to prevent duplicate tests. This will improve runtime even further in the future.

@H0R5E
Copy link
Contributor

H0R5E commented Jun 23, 2021

See akeeste#7

Use test suites to control execution
@akeeste akeeste marked this pull request as ready for review July 6, 2021 16:12
@akeeste
Copy link
Contributor Author

akeeste commented Jul 6, 2021

A few additions since this PR has been opened:

  • removed applications tested from the WEC-Sim repo. Applications Repo PR 7 adds these tests to that repo.
  • moved the passive yaw regression tests to a separate class so that they can be turned on/off easily. By default they are skipped to decrease run time
  • Changed how the tests are called in wecSimTest. Now this function uses the run(suite) command instead of testRunner.run(suite) so that appropriate debugging information is collected in the test results.

As indicated in the above discussion, removing the applications and passive yaw tests significantly decreases run time. Now the tests take ~2 minutes locally, only 15% of the previous run time.

@H0R5E
Copy link
Contributor

H0R5E commented Jul 6, 2021

Adam, how much time is saved by not running the passive yaw regression test? My concern is that if they are not run by default, then they will never be run at all.

I would also consider replacing the test runner. If we are going to collect coverage info (which I think we should soon) we need to use a plugin on a test runner:

https://uk.mathworks.com/help/matlab/ref/matlab.unittest.plugins.codecoverageplugin-class.html

What is the difference in output between using run and using the test runner?

@akeeste
Copy link
Contributor Author

akeeste commented Jul 6, 2021

@H0R5E
That is a fair point, most users might not remember to turn on passive yaw when appropriate. Maybe we just remove the passive yaw regression altogether? The functionality will be covered in the Applications repository, though without a comparison to the previous result. After the compilation/Application tests are removed, the passive yaw tests take up ~50% of the runtime.

My problem with the test runner is that it currently does not give the same diagnostic information as the run command (in R2021a). For example, right now the first BEMIO test fails (the fix is already in dev).

When using the testRunner, results(1).Details is empty. Whereas the run(suites) command gives useful debugging information in Details.DiagnosticRecord such as Exception, Stack, Scope, Report that provide details on where the error occurred and the error message received.

This almost seems like a Matlab bug, I don't know why the testRunner would give less information than the standard run command. If the testRunner will be required for code coverage information, I can look again at how to get around this issue. However until code coverage is implemented, I think the run command is more insightful.

@H0R5E
Copy link
Contributor

H0R5E commented Jul 6, 2021 via email

@H0R5E
Copy link
Contributor

H0R5E commented Jul 6, 2021 via email

@akeeste
Copy link
Contributor Author

akeeste commented Jul 6, 2021

Hi Mat,

Yes I'll take a look at this today and can discuss with you over the next few days.

@akeeste
Copy link
Contributor Author

akeeste commented Jul 6, 2021

@H0R5E

I looked at the test plugins more today and discovered the one that seems to be recording diagnostic information in the testResult struct. I tested the following TestRunner options that contain the respective plugins:

TestRunner.withNoPlugins;      % no plugins
TestRunner.withDefaultPlugins; % ConciseProgressPlugin, DiagnosticsOutputPlugin, DiagnosticsRecordingPlugin
TestRunner.withTextOutput;     % TestRunProgressPlugin, DiagnosticsOutputPlugin

DiagnosticsRecordingPlugin is the option that adds the diagnostic information to the testResult object. This is included as the default plugin when run(suites) is used and why we were seeing different output. The testRunner class also has a note that the 'withDefaultPlugins' option will change across versions.

Given these items, I opted for the following setup, which will contain TestRunProgressPlugin, DiagnosticsOutputPlugin, DiagnosticsRecordingPlugin and CodeCoveragePlugin. This results in sufficient debugging information and allows code coverage in the future.

runner = TestRunner.withTextOutput;
runner.addPlugin(DiagnosticsRecordingPlugin);
runner.addPlugin(CodeCoveragePlugin.forFolder('./source'));

.

@H0R5E
Copy link
Contributor

H0R5E commented Jul 7, 2021

@akeeste, good work. It's kind of weird that the DiagnosticsRecordingPlugin gets added in certain situations but not others. I would say that is probably a bug.

Do you want me to review the PR?

@akeeste akeeste requested a review from H0R5E July 7, 2021 14:11
@akeeste
Copy link
Contributor Author

akeeste commented Jul 7, 2021

@H0R5E Yes that would be great. There should not be much changed since you pushed to this branch.

Last note--I am aware of one BEMIO test currently failing. The dev branch already contains the fix for this and the tests should all pass once the PR is merged.

Copy link
Contributor

@H0R5E H0R5E left a comment

Choose a reason for hiding this comment

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

Hi @akeeste, overall I think this is a really good update to the testing framework. I've got a few minor style changes that I suggested in comments, but I also think there are three "blockers" to merging this right now. These are:

  1. The test suite should not fail just because of the combine_bem test. I've added a solution to this in akeeste#8
  2. There is no documentation added to describe how to use the test suite. There should be something, even if its just a docstring for the wecSimTest function.
  3. I don't think we should skip the passive yaw tests by default. It was 200 seconds without and 260 seconds with on my machine and I think once you're in the minutes an extra one won't hurt. Explaining to users how to turn off the tests (in the doctring or whatever) is a better approach.

I'm happy to help out with any of these changes, so just give me a shout.

Mat

EDIT: It's best to look at my comments in the Files changed tab, rather than below.

hydro(end).body = {'cylinder_nemoh'};
hydro = Read_WAMIT(hydro,'..\..\WAMIT\Cylinder\cyl.out',[]);
hydro(end).body = {'cylinder_wamit'};
hydro = Combine_BEM(hydro);
Copy link
Contributor

Choose a reason for hiding this comment

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

It is better to skip this test as a known error, rather than leave it as a failure. The automated CI is always going to fail if we leave it like this. See akeeste#8 for the approach to skip this test based on a known failure

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 agree the test should be skipped if the fix is not already present. However since this PR is only merging into dev, the fix will be present and the test will pass as soon as the PR is merged. To simplify this I pulled dev into this branch so that all tests are passing before the merge.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see. Shouldn't we be putting this into master as well?

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 assumed this wouldn't happen until the entire dev branch is merged into master and a new release is tagged. I believe v4.3 was planned for the near future.

@H0R5E
Copy link
Contributor

H0R5E commented Jul 13, 2021

@akeeste, @kmruehl is there a reason that the mat files are not stored using LFS? They are super big, huh, so would LFS not be a better approach?

@H0R5E
Copy link
Contributor

H0R5E commented Jul 13, 2021

Offered an improvement to the docstring in akeeste#9

Improve docstring of wecSimTest.m
Copy link
Contributor

@H0R5E H0R5E left a comment

Choose a reason for hiding this comment

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

Looks great. Please go ahead and merge it (I would recommend a squash and merge).

@akeeste akeeste merged commit 8553761 into WEC-Sim:dev Jul 14, 2021
@akeeste akeeste deleted the ci_restructure branch July 14, 2021 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature new feature request Tests/CI related WEC-Sim tests or Continuous Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants