Skip to content

configdrive: run unit test only for Linux#2665

Closed
yadvr wants to merge 8 commits intoapache:4.11from
shapeblue:testfix-genisoimage
Closed

configdrive: run unit test only for Linux#2665
yadvr wants to merge 8 commits intoapache:4.11from
shapeblue:testfix-genisoimage

Conversation

@yadvr
Copy link
Member

@yadvr yadvr commented May 23, 2018

This runs a platform dependent test only on Linux, otherwise skips.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

GitHub Issue/PRs

Screenshots (if appropriate):

How Has This Been Tested?

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
    Testing
  • I have added tests to cover my changes.
  • All relevant new and existing integration tests have passed.
  • A full integration testsuite with all test that can run on my environment has passed.

@yadvr yadvr added this to the 4.11.1.0 milestone May 23, 2018
@yadvr yadvr modified the milestones: 4.11.1.0, 4.11.2.0 May 23, 2018
This runs a platform dependent test only on Linux, otherwise skips.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
@yadvr yadvr force-pushed the testfix-genisoimage branch from 763471f to 2d33a64 Compare May 23, 2018 09:36
Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

this should not be a unit test on linux either. mkisofs is available for macos as well. I don't like the trend this is setting. Let's find another solution.

@wido
Copy link
Contributor

wido commented May 23, 2018

I am with this on @DaanHoogland

This could only lead to Mac developers thinking everything is just fine and they merge a PR with broken code.

@DaanHoogland
Copy link
Contributor

jenkins is failing with this as well now (on #2664):
testConfigDriveBuild(org.apache.cloudstack.storage.configdrive.ConfigDriveBuilderTest) Time elapsed: 0.206 sec <<< ERROR!
com.cloud.utils.exception.CloudRuntimeException: Unable to create iso file: i-x-y.iso due to java.io.IOException: Cannot run program "/usr/bin/genisoimage": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at com.cloud.utils.script.Script.execute(Script.java:215)
at com.cloud.utils.script.Script.execute(Script.java:183)

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
@yadvr
Copy link
Member Author

yadvr commented May 23, 2018

@wido @DaanHoogland I've removed the integration like unit test. @borisstoyanov can you help create a different PR that fixes the configdrive in future?

@borisstoyanov
Copy link
Contributor

I'm not sure if I can for unit tests @rhtyd, if you're referring to the component tests maybe we can write them from scratch since they are bond with some nuage utilities and test data, which we don't get with normal marvin installation

@yadvr
Copy link
Member Author

yadvr commented May 23, 2018

@borisstoyanov I was referring to the marvin based integration test (I'm okay if it's a new one or fixing the existing one).

@borisstoyanov
Copy link
Contributor

Okay @rhtyd

@DaanHoogland
Copy link
Contributor

either jenkins didn't restart or it is still failing on the lack of /usr/bin/genisoimage, whuich seems strange.

@DaanHoogland
Copy link
Contributor

testing locally

@DaanHoogland
Copy link
Contributor

by the looks of it testAddPasswordAndUserData() has now become an integration type test, consequentially.

@yadvr yadvr closed this May 23, 2018
@yadvr yadvr reopened this May 23, 2018
@yadvr
Copy link
Member Author

yadvr commented May 23, 2018

@DaanHoogland @wido are you both okay with removal of test and submission of proper integration test in future? I've tried to rekick Jenkins using close+open of the PR but it does do not look like it worked (but Travis got re-kicked).

@yadvr yadvr modified the milestones: 4.11.2.0, 4.11.1.0 May 23, 2018
@DaanHoogland
Copy link
Contributor

@rhtyd as a consequence of the original change testAddPasswordAndUserData() is now an integration test as well. Can we change that to an integration test as well?

@wido
Copy link
Contributor

wido commented May 23, 2018

Well, I would like to see this tested ofcourse, but I'm ok with removal for now.

@yadvr
Copy link
Member Author

yadvr commented May 23, 2018

@DaanHoogland I see, I can do some mocking tomorrow on static methods that should get rid of the integration side of things.

@yadvr yadvr removed this from the 4.11.1.0 milestone May 23, 2018
@yadvr yadvr added this to the 4.11.2.0 milestone May 23, 2018
@yadvr
Copy link
Member Author

yadvr commented May 23, 2018

Since this only affects developers (non_linux envs) I've moved it to 4.11.2.0 milestone. I'll get back on this soon (but if I've time, will focus on 4.11.1.0 related issues first).

@DaanHoogland
Copy link
Contributor

jenkins fails because of this so I'd say this is high urgency, even when not a blocker.

@rafaelweingartner
Copy link
Member

Folks I am almost finished with unit test for ConfigDriveBuilder class. It is taking a little longer than I expected because of static methods mocking.

@yadvr
Copy link
Member Author

yadvr commented May 24, 2018

Okay @rafaelweingartner, feel free to push your changes to this PR. Thanks.


assertTrue(createCommand.isCreate());
assertTrue(createCommand.getIsoData().length() > 0);
assertTrue(createCommand.getIsoFile().equals(ConfigDrive.createConfigDrivePath(profile.getInstanceName())));
Copy link
Member Author

Choose a reason for hiding this comment

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

@DaanHoogland we don't need to remove this unit test, instead just mock the call that addPasswordAndUserdata makes to the ConfigDriveBuilder static method which is tricky but do-able.

Copy link
Contributor

Choose a reason for hiding this comment

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

whatever solution is fine by me. for now I want to see jenkins pass. We can revert when we have a better solution.

@DaanHoogland
Copy link
Contributor

@fmaximus there is a nuage specific config drive test suite. Can you verify that these tstill pass? And do those all need to be nuage specific? Maybe we can generify the config drives ones to run as generic regression tests.

@DaanHoogland
Copy link
Contributor

as for running on macos, i think the following might do:

diff --git a/engine/storage/configdrive/src/org/apache/cloudstack/storage/configdrive/ConfigDriveBuilder.java b/engine/storage/configdrive/src/org/apache/cloudstack/storage/configdrive/ConfigDriveBuilder.java
index d847aa1d1d..b975e12154 100644
--- a/engine/storage/configdrive/src/org/apache/cloudstack/storage/configdrive/ConfigDriveBuilder.java
+++ b/engine/storage/configdrive/src/org/apache/cloudstack/storage/configdrive/ConfigDriveBuilder.java
@@ -136,7 +136,18 @@ public class ConfigDriveBuilder {
             }

             File tmpIsoStore = new File(tempDirName, new File(isoFileName).getName());
-            Script command = new Script("/usr/bin/genisoimage", Duration.standardSeconds(300), LOG);
+            File isoCreator = new File("/usr/bin/genisoimage");
+            if (!isoCreator.exists()) {
+                isoCreator = new File("/usr/local/bin/mkisofs"); // are these all the paths we search?
+                if(!isoCreator.exists()) {
+                    throw new CloudRuntimeException("cannot create iso for config drive using any know tool.");
+                }
+            }
+            if(!isoCreator.canExecute()) {
+                throw new CloudRuntimeException("cannot create iso for config drive using " + isoCreator.getCanonicalPath());
+            }
+
+            Script command = new Script(isoCreator.getCanonicalPath(), Duration.standardSeconds(300), LOG);
             command.add("-o", tmpIsoStore.getAbsolutePath());
             command.add("-ldots");
             command.add("-allow-lowercase");

I'll test and add to this PR (or separately if we feel it needs to be.

@DaanHoogland
Copy link
Contributor

As for @rhtyd 's comment above, after jenkins passes I will revert the removal of the test and extract line 350 of ConfigDriveNetworkElement,

        final String isoData = ConfigDriveBuilder.buildConfigDrive(profile.getVmData(), ConfigDrive.CONFIGDRIVEFILENAME, profile.getConfigDriveLabel());

, into a separate method to be mocked. That hopefully will do the trick.

@DaanHoogland DaanHoogland dismissed their stale review May 24, 2018 09:13

now involved in the code, other reviewers wanted

@rafaelweingartner
Copy link
Member

@DaanHoogland I am almost finished with the complete set of unit tests for the static methods as you originally designed this code. Could you just wait a bit more? Therefore, there would be no need to do the changes you are doing here that are intended to facilitate your mocking.

I know writing unit tests for static method is a pain, that is why I started doing yesterday, but I was not able to finish yesterday.

@fmaximus
Copy link
Contributor

@DaanHoogland @borisstoyanov The test in the component directory is a test which can run without any need for Nuage. It started as a copy of the Nuage specific test in plugins/nuagevsp, and recently I have moved the common code to a separate class in the component test, so I can reuse it from the nuage test. PR #2673 has some more fixes for issues I encountered when trying to run it.

@yadvr
Copy link
Member Author

yadvr commented Jun 4, 2018

Closing this as #2674 addresses the issues.

@yadvr yadvr closed this Jun 4, 2018
@yadvr
Copy link
Member Author

yadvr commented Jun 4, 2018

@DaanHoogland I just saw you had made some additional changes on top of my PR, can you move/check those changes in Rafael's PR in #2674 .

@DaanHoogland
Copy link
Contributor

check

@DaanHoogland
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants