This repository was archived by the owner on Mar 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Adding system tests #399
Merged
Merged
Adding system tests #399
Changes from 24 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
122d4da
Refactor existing tests
Vahila 95fabb5
Add system tests for Run MATLAB Command step
Vahila db9eb7c
Set up main.yml to run system tests
Vahila 42a5d44
Update maven goal
Vahila 60e88f8
Update version
Vahila 9e9f57c
Update test set up
Vahila 309b23d
Add tests for Matrix project
Vahila 42730cc
Add tests for Run MATLAB Tests build step
Vahila b8921ad
Add tests for Artifacts generation
Vahila 2ce87ae
Add tests for Customize Test Run
Vahila dc4aab5
Add tests for MATLAB Global Tool
Vahila 21763ac
Add tests for Start Up options
Vahila 62dcd17
Add test data
Vahila 71a7d4c
Update main.yml
Vahila e96379a
Add tests for MPMinstall feature
Vahila 1e85a8f
Update FilterTestData.zip
Vahila 14276c4
Use Java 11 in set up
Vahila 0140125
Add tests for Run MATLAB Build step
Vahila eba0e3f
Refactor tests
Vahila a52b697
Use mvn verify
Vahila 53be112
Update failing test
Vahila e0d7182
Merge branch 'integ_tests' of https://github.com/mathworks/jenkins-ma…
Vahila bcb085d
Delete MPMInstallIT.java
Vahila de3da63
Refactor tests
Vahila c50d60a
Merge branch '2.16.0-SNAPSHOT-Qualification' into integ_tests
Vahila 3df9592
Address review comments
Vahila 7f26d59
Remove scratch file related tests
Vahila 30e5eb0
Update indentation
Vahila 0abb319
Remove sleep statements
Vahila 191def8
Add verify goal for failsafe plugin
Vahila 1dbb9b1
Update package
Vahila d69e644
Use teat data
Vahila 87dd4e6
Update package name
Vahila 004d7c9
Use maven in batch mode
Vahila b6fdbf7
Update failing test
Vahila 35e5f1d
Remove unused function
Vahila 5a6ab02
Delete azure-pipelines.yml
Vahila c73c73a
Remove timeout
Vahila b19294f
Merge remote-tracking branch 'origin/dev_main' into integ_tests
Vahila File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,28 @@ | ||
| name: using mpm to install MATLAB | ||
| on: push | ||
| jobs: | ||
| my-job: | ||
Vahila marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest, macos-latest] | ||
| name: Run System tests | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Setup Java 11 | ||
| uses: actions/setup-java@v3 | ||
| with: | ||
| java-version: '11' | ||
| distribution: 'temurin' | ||
|
|
||
Vahila marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Setup MATLAB | ||
| id: setup-matlab | ||
| uses: matlab-actions/setup-matlab@v2 | ||
|
|
||
| - name: Running tests | ||
| run: mvn verify | ||
| env: | ||
| MATLAB_ROOT: ${{ steps.setup-matlab.outputs.matlabroot }} | ||
| MLM_LICENSE_TOKEN: ${{ secrets.MLM_LICENSE_TOKEN}} | ||
This file contains hidden or 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
272 changes: 136 additions & 136 deletions
272
...athworks/ci/actions/MatlabActionTest.java → ...athworks/ci/actions/MatlabActionTest.java
This file contains hidden or 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 |
|---|---|---|
| @@ -1,136 +1,136 @@ | ||
| package unit.com.mathworks.ci.actions; | ||
Vahila marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Copyright 2024, The MathWorks Inc. | ||
| */ | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.io.PrintStream; | ||
| import java.nio.file.Files; | ||
|
|
||
| import org.junit.Test; | ||
| import org.junit.Before; | ||
| import org.junit.runner.RunWith; | ||
| import static org.junit.Assert.*; | ||
|
|
||
| import org.mockito.InOrder; | ||
| import org.mockito.Mock; | ||
| import org.mockito.junit.MockitoJUnitRunner; | ||
|
|
||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.Mockito.*; | ||
|
|
||
| import hudson.FilePath; | ||
| import hudson.model.Run; | ||
| import hudson.model.TaskListener; | ||
|
|
||
| import com.mathworks.ci.MatlabBuilderConstants; | ||
| import com.mathworks.ci.BuildArtifactAction; | ||
| import com.mathworks.ci.BuildConsoleAnnotator; | ||
| import com.mathworks.ci.MatlabExecutionException; | ||
| import com.mathworks.ci.actions.RunMatlabCommandAction; | ||
| import com.mathworks.ci.utilities.MatlabCommandRunner; | ||
| import com.mathworks.ci.parameters.CommandActionParameters; | ||
|
|
||
| @RunWith(MockitoJUnitRunner.Silent.class) | ||
| public class MatlabActionTest { | ||
| @Mock | ||
| CommandActionParameters params; | ||
| @Mock | ||
| BuildConsoleAnnotator annotator; | ||
| @Mock | ||
| MatlabCommandRunner runner; | ||
| @Mock | ||
| PrintStream out; | ||
| @Mock | ||
| TaskListener listener; | ||
| @Mock | ||
| Run build; | ||
|
|
||
| @Mock | ||
| FilePath tempFolder; | ||
|
|
||
| private boolean setup = false; | ||
| private RunMatlabCommandAction action; | ||
|
|
||
| // Not using @BeforeClass to avoid static fields. | ||
| @Before | ||
| public void init() { | ||
| if (!setup) { | ||
| setup = true; | ||
| action = new RunMatlabCommandAction(runner, annotator, params); | ||
|
|
||
| when(runner.getTempFolder()).thenReturn(tempFolder); | ||
| when(tempFolder.getRemote()).thenReturn("/path/less/traveled"); | ||
|
|
||
| when(params.getTaskListener()).thenReturn(listener); | ||
| when(listener.getLogger()).thenReturn(out); | ||
|
|
||
| when(params.getBuild()).thenReturn(build); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldCopyPluginsToTempDirectory() throws IOException, InterruptedException, MatlabExecutionException { | ||
| action.run(); | ||
|
|
||
| InOrder inOrder = inOrder(runner); | ||
|
|
||
| inOrder.verify(runner) | ||
| .copyFileToTempFolder(MatlabBuilderConstants.DEFAULT_PLUGIN, MatlabBuilderConstants.DEFAULT_PLUGIN); | ||
| inOrder.verify(runner) | ||
| .copyFileToTempFolder(MatlabBuilderConstants.BUILD_REPORT_PLUGIN, | ||
| MatlabBuilderConstants.BUILD_REPORT_PLUGIN); | ||
| inOrder.verify(runner) | ||
| .copyFileToTempFolder(MatlabBuilderConstants.TASK_RUN_PROGRESS_PLUGIN, | ||
| MatlabBuilderConstants.TASK_RUN_PROGRESS_PLUGIN); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldOverrideDefaultBuildtoolPlugin() | ||
| throws IOException, InterruptedException, MatlabExecutionException { | ||
| action.run(); | ||
|
|
||
| verify(runner).addEnvironmentVariable( | ||
| "MW_MATLAB_BUILDTOOL_DEFAULT_PLUGINS_FCN_OVERRIDE", | ||
| "ciplugins.jenkins.getDefaultPlugins"); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldCopyBuildResultsToRootAndAddAction() | ||
| throws IOException, InterruptedException, MatlabExecutionException { | ||
| File tmp = Files.createTempDirectory("temp").toFile(); | ||
| tmp.deleteOnExit(); | ||
|
|
||
| File dest = Files.createTempDirectory("dest").toFile(); | ||
| dest.deleteOnExit(); | ||
|
|
||
| File json = new File(tmp, "buildArtifact.json"); | ||
| json.createNewFile(); | ||
|
|
||
| doReturn(new FilePath(tmp)).when(runner).getTempFolder(); | ||
| doReturn(dest).when(build).getRootDir(); | ||
|
|
||
| action.run(); | ||
|
|
||
| // Should have deleted original file | ||
| assertFalse(json.exists()); | ||
| // Should have copied file to root dir | ||
| assertTrue(new File(dest, "buildArtifact" + action.getActionID() + ".json").exists()); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldNotAddActionIfNoBuildResult() throws IOException, InterruptedException, MatlabExecutionException { | ||
| action.run(); | ||
|
|
||
| verify(build, never()).addAction(any(BuildArtifactAction.class)); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldRemoveTempFolder() throws IOException, InterruptedException, MatlabExecutionException { | ||
| action.run(); | ||
|
|
||
| verify(runner).removeTempFolder(); | ||
| } | ||
| } | ||
| package unit.com.mathworks.ci.actions; | ||
|
|
||
| /** | ||
| * Copyright 2024, The MathWorks Inc. | ||
| */ | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.io.PrintStream; | ||
| import java.nio.file.Files; | ||
|
|
||
| import org.junit.Test; | ||
| import org.junit.Before; | ||
| import org.junit.runner.RunWith; | ||
| import static org.junit.Assert.*; | ||
|
|
||
| import org.mockito.InOrder; | ||
| import org.mockito.Mock; | ||
| import org.mockito.junit.MockitoJUnitRunner; | ||
|
|
||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.Mockito.*; | ||
|
|
||
| import hudson.FilePath; | ||
| import hudson.model.Run; | ||
| import hudson.model.TaskListener; | ||
|
|
||
| import com.mathworks.ci.MatlabBuilderConstants; | ||
| import com.mathworks.ci.BuildArtifactAction; | ||
| import com.mathworks.ci.BuildConsoleAnnotator; | ||
| import com.mathworks.ci.MatlabExecutionException; | ||
| import com.mathworks.ci.actions.RunMatlabCommandAction; | ||
| import com.mathworks.ci.utilities.MatlabCommandRunner; | ||
| import com.mathworks.ci.parameters.CommandActionParameters; | ||
|
|
||
| @RunWith(MockitoJUnitRunner.Silent.class) | ||
| public class MatlabActionTest { | ||
| @Mock | ||
| CommandActionParameters params; | ||
| @Mock | ||
| BuildConsoleAnnotator annotator; | ||
| @Mock | ||
| MatlabCommandRunner runner; | ||
| @Mock | ||
| PrintStream out; | ||
| @Mock | ||
| TaskListener listener; | ||
| @Mock | ||
| Run build; | ||
|
|
||
| @Mock | ||
| FilePath tempFolder; | ||
|
|
||
| private boolean setup = false; | ||
| private RunMatlabCommandAction action; | ||
|
|
||
| // Not using @BeforeClass to avoid static fields. | ||
| @Before | ||
| public void init() { | ||
| if (!setup) { | ||
| setup = true; | ||
| action = new RunMatlabCommandAction(runner, annotator, params); | ||
|
|
||
| when(runner.getTempFolder()).thenReturn(tempFolder); | ||
| when(tempFolder.getRemote()).thenReturn("/path/less/traveled"); | ||
|
|
||
| when(params.getTaskListener()).thenReturn(listener); | ||
| when(listener.getLogger()).thenReturn(out); | ||
|
|
||
| when(params.getBuild()).thenReturn(build); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldCopyPluginsToTempDirectory() throws IOException, InterruptedException, MatlabExecutionException { | ||
| action.run(); | ||
|
|
||
| InOrder inOrder = inOrder(runner); | ||
|
|
||
| inOrder.verify(runner) | ||
| .copyFileToTempFolder(MatlabBuilderConstants.DEFAULT_PLUGIN, MatlabBuilderConstants.DEFAULT_PLUGIN); | ||
| inOrder.verify(runner) | ||
| .copyFileToTempFolder(MatlabBuilderConstants.BUILD_REPORT_PLUGIN, | ||
| MatlabBuilderConstants.BUILD_REPORT_PLUGIN); | ||
| inOrder.verify(runner) | ||
| .copyFileToTempFolder(MatlabBuilderConstants.TASK_RUN_PROGRESS_PLUGIN, | ||
| MatlabBuilderConstants.TASK_RUN_PROGRESS_PLUGIN); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldOverrideDefaultBuildtoolPlugin() | ||
| throws IOException, InterruptedException, MatlabExecutionException { | ||
| action.run(); | ||
|
|
||
| verify(runner).addEnvironmentVariable( | ||
| "MW_MATLAB_BUILDTOOL_DEFAULT_PLUGINS_FCN_OVERRIDE", | ||
| "ciplugins.jenkins.getDefaultPlugins"); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldCopyBuildResultsToRootAndAddAction() | ||
| throws IOException, InterruptedException, MatlabExecutionException { | ||
| File tmp = Files.createTempDirectory("temp").toFile(); | ||
| tmp.deleteOnExit(); | ||
|
|
||
| File dest = Files.createTempDirectory("dest").toFile(); | ||
| dest.deleteOnExit(); | ||
|
|
||
| File json = new File(tmp, "buildArtifact.json"); | ||
| json.createNewFile(); | ||
|
|
||
| doReturn(new FilePath(tmp)).when(runner).getTempFolder(); | ||
| doReturn(dest).when(build).getRootDir(); | ||
|
|
||
| action.run(); | ||
|
|
||
| // Should have deleted original file | ||
| assertFalse(json.exists()); | ||
| // Should have copied file to root dir | ||
| assertTrue(new File(dest, "buildArtifact" + action.getActionID() + ".json").exists()); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldNotAddActionIfNoBuildResult() throws IOException, InterruptedException, MatlabExecutionException { | ||
| action.run(); | ||
|
|
||
| verify(build, never()).addAction(any(BuildArtifactAction.class)); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldRemoveTempFolder() throws IOException, InterruptedException, MatlabExecutionException { | ||
| action.run(); | ||
|
|
||
| verify(runner).removeTempFolder(); | ||
| } | ||
| } | ||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.