Skip to content

Conversation

@GabrielBrascher
Copy link
Member

This allows computers with Windows or MacOS to run the tests without scanning for /proc/meminfo path.

At the class MemStat.java, the refresh() method (called in MemStat constructor) has the following lines:

public void refresh() {
        File f = new File(MEMINFO_FILE);
        try (Scanner scanner = new Scanner(f,"UTF-8")) {
            parseFromScanner(scanner);
        } catch (FileNotFoundException ex) {
            throw new RuntimeException("File " + MEMINFO_FILE + " not found:" + ex.toString());
        }
}

When executing Scanner scanner = new Scanner(f,"UTF-8") it scans the file MEMINFO_FILE (/proc/meminfo); however, if the OS running this test is not a Linux then it throws FileNotFoundException, failing the test.

Thus, by Mocking the Scanner constructor, the new Scanner(f,"UTF-8") execution returns the desired Scanner.

Description

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)

Screenshots (if appropriate):

How Has This Been Tested?

@GabrielBrascher
Copy link
Member Author

Ping for review @kiwiflyer @nathanejohnson @DaanHoogland and others.

@nathanejohnson
Copy link
Member

nathanejohnson commented Feb 11, 2019

Still getting failures on mac:

  <testcase name="getMemInfoParseTest" classname="org.apache.cloudstack.utils.linux.MemStatTest" time="0.058">
    <error message="File /proc/meminfo not found:java.io.FileNotFoundException: /proc/meminfo (No such file or directory)" type="java.lang.RuntimeException">java.lang.RuntimeException: File /proc/meminfo not found:java.io.FileNotFoundException: /proc/meminfo (No such file or directory)
        at org.apache.cloudstack.utils.linux.MemStatTest.getMemInfoParseTest(MemStatTest.java:43)
</error>
  </testcase>

mac_mem_test_fail.tar.gz

(njohnson@greyeagle:~/src/cloudstack)$ git branch
  master
* test-running-only-on-linux
(njohnson@greyeagle:~/src/cloudstack)$ git remote -v
origin	https://github.com/PCextreme/cloudstack.git (fetch)
origin	https://github.com/PCextreme/cloudstack.git (push)
(njohnson@greyeagle:~/src/cloudstack)$ 

This allows non linux machines to run the tests without scanning for a
non existing /proc/meminfo.
@GabrielBrascher GabrielBrascher force-pushed the test-running-only-on-linux branch from b4dcd9a to b83a172 Compare February 11, 2019 17:57
@GabrielBrascher
Copy link
Member Author

Updated the code with a setup method and removed a variable that I left without mocking. Thanks for testing @nathanejohnson. Could you please test it again to make sure that it has been fixed?

@nathanejohnson
Copy link
Member

still getting failures, but in a new place. I've attached logs

mac_test_fail.tar.gz

@GabrielBrascher
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

@GabrielBrascher 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-2609

@GabrielBrascher
Copy link
Member Author

@blueorangutan test

@blueorangutan
Copy link

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

@GabrielBrascher
Copy link
Member Author

GabrielBrascher commented Feb 12, 2019

still getting failures, but in a new place. I've attached logs

@nathanejohnson that is good. At least this PR fixed the test failures from MemStatTest.java.
It looks like we have more tests to take a look into as well. Thanks for pointing that!

@wido wido self-requested a review February 12, 2019 14:56
Copy link
Contributor

@wido wido left a comment

Choose a reason for hiding this comment

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

LGTM based on code

@DaanHoogland
Copy link
Contributor

MemStatTest passes @GabrielBrascher . The following remains:

[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   LibvirtComputingResourceTest.diskUuidToSerialTest:437 » Runtime File /proc/mem...
[ERROR]   LibvirtComputingResourceTest.testAddExtraConfigComponentEmptyExtraConfig:5235 » Runtime
[ERROR]   LibvirtComputingResourceTest.testAddExtraConfigComponentNotEmptyExtraConfig:5242 » Runtime
[ERROR]   LibvirtComputingResourceTest.testCreateVMFromSpec:324 » Runtime File /proc/mem...
[ERROR]   LibvirtComputingResourceTest.testCreateVMFromSpecLegacy:224 » Runtime File /pr...
[ERROR]   LibvirtComputingResourceTest.testCreateVMFromSpecWithTopology4:288 » Runtime F...
[ERROR]   LibvirtComputingResourceTest.testCreateVMFromSpecWithTopology6:256 » Runtime F...
[ERROR]   LibvirtComputingResourceTest.testGetVmStat:509 » Runtime File /proc/meminfo no...
[ERROR]   LibvirtComputingResourceTest.testIsInterface:5118 » Runtime File /proc/meminfo...
[ERROR]   LibvirtComputingResourceTest.testKnownCommand:5222 » Runtime File /proc/meminf...
[ERROR]   LibvirtComputingResourceTest.testMemoryFreeInKBsDomainReturningNoMemoryStatistics:5149 » Runtime
[ERROR]   LibvirtComputingResourceTest.testMemoryFreeInKBsDomainReturningOfSomeMemoryStatistics:5138 » Runtime
[ERROR]   LibvirtComputingResourceTest.testSetQuotaAndPeriod:5178 » Runtime File /proc/m...
[ERROR]   LibvirtComputingResourceTest.testSetQuotaAndPeriodMinQuota:5202 » Runtime File...
[ERROR]   LibvirtComputingResourceTest.testSetQuotaAndPeriodNoCpuLimitUse:5190 » Runtime
[ERROR]   LibvirtComputingResourceTest.testUUID:444 » Runtime File /proc/meminfo not fou...
[ERROR]   LibvirtComputingResourceTest.testUnknownCommand:5210 » Runtime File /proc/memi...
[ERROR]   LibvirtVifDriverTest.setUp:54 » Runtime File /proc/meminfo not found:java.io.F...
[ERROR]   LibvirtVifDriverTest.setUp:54 » Runtime File /proc/meminfo not found:java.io.F...
[ERROR]   LibvirtVifDriverTest.setUp:54 » Runtime File /proc/meminfo not found:java.io.F...
[ERROR]   LibvirtVifDriverTest.setUp:54 » Runtime File /proc/meminfo not found:java.io.F...
[ERROR]   LibvirtVifDriverTest.setUp:54 » Runtime File /proc/meminfo not found:java.io.F...
[ERROR]   LibvirtVifDriverTest.setUp:54 » Runtime File /proc/meminfo not found:java.io.F...
[ERROR]   LibvirtVifDriverTest.setUp:54 » Runtime File /proc/meminfo not found:java.io.F...
[ERROR]   LibvirtMigrateCommandWrapperTest.deleteOrDisconnectDisksOnSourcePoolTest:410 » Runtime
[ERROR]   LibvirtMigrateCommandWrapperTest.testMigrationUri:333 » Runtime File /proc/mem...
[ERROR]   LibvirtMigrateCommandWrapperTest.testMigrationUriException »  Unexpected excep...
[ERROR]   LibvirtNetworkElementCommandWrapperTest.setUp:217 » Runtime File /proc/meminfo...
[ERROR]   LibvirtNetworkElementCommandWrapperTest.setUp:217 » Runtime File /proc/meminfo...
[ERROR]   LibvirtReplugNicCommandWrapperTest.setUp:189 » Runtime File /proc/meminfo not ...
[INFO]
[ERROR] Tests run: 214, Failures: 0, Errors: 30, Skipped: 2

@blueorangutan
Copy link

Trillian test result (tid-3404)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 34170 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr3173-t3404-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_accounts.py
Intermittent failure detected: /marvin/tests/smoke/test_iso.py
Intermittent failure detected: /marvin/tests/smoke/test_templates.py
Intermittent failure detected: /marvin/tests/smoke/test_volumes.py
Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
Smoke tests completed. 66 look OK, 4 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestTemplateHierarchy>:setup Error 1516.38 test_accounts.py
test_04_extract_Iso Failure 1.05 test_iso.py
test_04_extract_template Failure 1.06 test_templates.py
test_06_download_detached_volume Failure 9.27 test_volumes.py

Copy link
Contributor

@borisstoyanov borisstoyanov left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@dhlaluku dhlaluku left a comment

Choose a reason for hiding this comment

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

LGTM

@rohityadavcloud
Copy link
Member

Is this good to merge @GabrielBrascher @wido ?

@DaanHoogland
Copy link
Contributor

DaanHoogland commented Mar 26, 2019

@rhtyd I submitted some additions to @GabrielBrascher . I hope these can be included in this PR: CLDIN#3

DaanHoogland and others added 2 commits March 28, 2019 11:46
* powermock costructor for libvirt wrappers

* run test only on linux, don't assume we're on linux

* import
@GabrielBrascher
Copy link
Member Author

@rhtyd @DaanHoogland I updated the branch with the changes proposed by Daan.

@DaanHoogland
Copy link
Contributor

@nathanejohnson can you give this a test, please? #worksforme

@DaanHoogland
Copy link
Contributor

travis test run 7 always seems to fail, lately :(

@GabrielBrascher
Copy link
Member Author

@DaanHoogland yes, test 7 has been failing constantly, not only in this PR. #3267 looks like a fix for the Travis-CI timeout.

@GabrielBrascher
Copy link
Member Author

@nathanejohnson are you ok with this PR?

@nathanejohnson
Copy link
Member

@GabrielBrascher sorry for the late response, builds on my machine now! LGTM!

@nathanejohnson nathanejohnson self-requested a review April 23, 2019 20:54
@DaanHoogland DaanHoogland merged commit 8f7b27b into apache:master Apr 24, 2019
pbankonier pushed a commit to pbankonier/cloudstack that referenced this pull request Apr 24, 2019
…3173)

* Mock Scanner, instead of scan the computer running the test.

This allows non linux machines to run the tests without scanning for a
non existing /proc/meminfo.

* test fixes on 'other' platforms libvirt wrapper unit tests (apache#3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants