Skip to content

Create unit test cases for 'ConfigDriveBuilder' class#2674

Merged
DaanHoogland merged 5 commits intoapache:4.11from
rafaelweingartner:createUnitTestCasesForConfigDriveBuilder
Jun 4, 2018
Merged

Create unit test cases for 'ConfigDriveBuilder' class#2674
DaanHoogland merged 5 commits intoapache:4.11from
rafaelweingartner:createUnitTestCasesForConfigDriveBuilder

Conversation

@rafaelweingartner
Copy link
Member

@rafaelweingartner rafaelweingartner commented May 24, 2018

Description

@rhtyd, @DaanHoogland, @wido, and @mike-tutkowski here is the unit tests to remove the dependency of "genisoimage" when building ACS in other operating systems (running maven).

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)

Issues and PRs fixed by this PR

This solves #2671
Also solves #2665
Fixes #2677

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.

@rafaelweingartner rafaelweingartner added this to the 4.11.1.0 milestone May 24, 2018
@rafaelweingartner rafaelweingartner force-pushed the createUnitTestCasesForConfigDriveBuilder branch from c3e73c4 to 0f3d324 Compare May 24, 2018 11:29
public static String fileToBase64String(File isoFile) throws IOException {
byte[] encoded = Base64.encodeBase64(FileUtils.readFileToByteArray(isoFile));
return new String(encoded, StandardCharsets.US_ASCII);
return new String(encoded, com.cloud.utils.StringUtils.getPreferredCharset());
Copy link
Member

@yadvr yadvr May 24, 2018

Choose a reason for hiding this comment

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

@rafaelweingartner for base64 encoding should n't we keep it to US_ASCII? Bear in mind that this encoded string is passed over network to agents.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a good question. I noticed that in some places we were using US_ASCII and others the com.cloud.utils.StringUtils.getPreferredCharset(). I asked @DaanHoogland about it.
I can revert this change though. What do you guys think?

Copy link
Member

Choose a reason for hiding this comment

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

I think let's stick with US_ASCII for both encoding and decoding?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, i made the same comment

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, so I will change that

*/
static String generateAndRetrieveIsoAsBase64Iso(String isoFileName, String driveLabel, String tempDirName) throws IOException {
File tmpIsoStore = new File(tempDirName, isoFileName);
Script command = new Script("/usr/bin/genisoimage", Duration.standardSeconds(300), LOG);
Copy link
Member

Choose a reason for hiding this comment

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

Can you include Daan's change (or @DaanHoogland can you push your change?) around using genisoimage or mkisofs if either is available?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it in some other PR? I can take a look and include it here.

Copy link
Member

Choose a reason for hiding this comment

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

@rafaelweingartner yes, see Daan's comment here: #2665 (comment)

@yadvr
Copy link
Member

yadvr commented May 24, 2018

Thanks @rafaelweingartner - I dislike however getting those final removed :)
@blueorangutan package

@blueorangutan
Copy link

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@rafaelweingartner
Copy link
Member Author

ah the final keyword. I am quite picky with things that do not seem to add value to the code.
I can add them back though.

@yadvr
Copy link
Member

yadvr commented May 24, 2018

@rafaelweingartner I prefer keeping objects open to assignments/change only if necessary, so I keep adding final by default. I'm okay with your change, but generally prefer people adopting final often.

@rafaelweingartner
Copy link
Member Author

rafaelweingartner commented May 24, 2018

That is interesting. I am used to do the opposite. I only restrict something, when I want this behavior. Otherwise, I leave them open.

@blueorangutan
Copy link

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2086

public static String fileToBase64String(File isoFile) throws IOException {
byte[] encoded = Base64.encodeBase64(FileUtils.readFileToByteArray(isoFile));
return new String(encoded, StandardCharsets.US_ASCII);
return new String(encoded, com.cloud.utils.StringUtils.getPreferredCharset());
Copy link
Contributor

Choose a reason for hiding this comment

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

the default charset might be different on the MS and the host. something that we might want to force in a test.

Copy link
Member Author

Choose a reason for hiding this comment

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

I must change org.apache.cloudstack.storage.configdrive.ConfigDriveBuilder.base64StringToFile(String, String, String) as well, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

these must be symetrical and will be running on different host, so yes

Copy link
Member Author

Choose a reason for hiding this comment

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

ok. Done

This is another method that is causing Jenkins to fail for almost a month
@rafaelweingartner
Copy link
Member Author

@khos2ow I am also fixing that MockServerTest.testIsMockServerCanUpgradeConnectionToSsl().

@rafaelweingartner
Copy link
Member Author

@rhtyd and @DaanHoogland and finally Jenkins is Green!

@rafaelweingartner
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

@rafaelweingartner a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-2087

Copy link
Member

@GabrielBrascher GabrielBrascher left a comment

Choose a reason for hiding this comment

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

I could only raise a minor issue in the documentation.
All tests have passed and code LGTM.

/**
* This is the path to iso file relative to mount point
* @return config drive iso file path
* Created the path to ISO file relative to mount point.
Copy link
Member

Choose a reason for hiding this comment

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

What do you think of Creates the path to ... instead of Created?
Change formatt to format

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. Fixed!

@yadvr
Copy link
Member

yadvr commented May 25, 2018

@blueorangutan test

@blueorangutan
Copy link

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@DaanHoogland
Copy link
Contributor

jenkins is still red but I don't see this as config drive related. We should remove the infamous timeout test.

@rafaelweingartner
Copy link
Member Author

rafaelweingartner commented May 25, 2018

Ahaha. Everything was green until i fixed a typo :(
Let me force a new build

@rafaelweingartner rafaelweingartner force-pushed the createUnitTestCasesForConfigDriveBuilder branch from 305b78e to ad3504a Compare May 25, 2018 10:33
@rafaelweingartner rafaelweingartner force-pushed the createUnitTestCasesForConfigDriveBuilder branch from ad3504a to c92d1ba Compare May 25, 2018 14:23
@rafaelweingartner
Copy link
Member Author

People, all green again!

@blueorangutan
Copy link

Trillian test result (tid-2717)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 23960 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr2674-t2717-kvm-centos7.zip
Intermitten failure detected: /marvin/tests/smoke/test_deploy_virtio_scsi_vm.py
Intermitten failure detected: /marvin/tests/smoke/test_privategw_acl.py
Intermitten failure detected: /marvin/tests/smoke/test_ssvm.py
Intermitten failure detected: /marvin/tests/smoke/test_vpc_redundant.py
Intermitten failure detected: /marvin/tests/smoke/test_vpc_vpn.py
Smoke tests completed. 64 look OK, 3 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestDeployVirtioSCSIVM>:setup Error 0.00 test_deploy_virtio_scsi_vm.py
test_03_vpc_privategw_restart_vpc_cleanup Error 117.12 test_privategw_acl.py
test_04_rvpc_network_garbage_collector_nics Failure 268.69 test_vpc_redundant.py
test_05_rvpc_multi_tiers Failure 318.98 test_vpc_redundant.py
test_05_rvpc_multi_tiers Error 340.90 test_vpc_redundant.py

@DaanHoogland
Copy link
Contributor

DaanHoogland commented May 29, 2018

I will discuss with @PaulAngus before merging any more things in 4.11 while we have an RC out.

@yadvr
Copy link
Member

yadvr commented Jun 4, 2018

Let's merge this @PaulAngus @DaanHoogland ?

@DaanHoogland DaanHoogland merged commit 9b83337 into apache:4.11 Jun 4, 2018
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.

5 participants