Uh oh!
There was an error while loading. Please reload this page.
Refactor system VM default network creation - #1360
Conversation
pedro-martins
commented
Jan 23, 2016
Could you replace the logic in your 'if' at lines 673 and 523 "(networks == null || networks.size() == 0)" |
There was a problem hiding this comment.
@ProjectMoon Could you please create a documentation and a test case for this method ("com.cloud.consoleproxy.ConsoleProxyManagerImpl.getDefaultNetworkForCreation(DataCenter)")?
GabrielBrascher
commented
Jan 23, 2016
@ProjectMoon Could you please do the following changes (1, 2, 3 and 4)? 1 - create a method for the code between lines 672 and 676; With that, the code would be clean, well documented and with tests specific for each logic flow (with and without advanced network). Thank you. |
ProjectMoon
commented
Jan 25, 2016
I've added the changes requested, minus the tests (still working on those). I am pushing the changes now for review. @pedro-martins The CollectionUtils library that shows up on my classpath is not from org.apache.commons.collections4, but instead org.apache.commons.collections. Is that what you meant or am I missing a compile-time dependency? |
There was a problem hiding this comment.
@ProjectMoon Nice, the method is cleaner and well documented. Just need to add the getDefaultNetworkForBasicZone(DataCenter dc) at the "else" execution flow. Thanks.
There was a problem hiding this comment.
Yeah kind of forgot to put it in there. It's there now.
pedro-martins
commented
Jan 25, 2016
Yes, your import is correct, I've done a mistake, the collections4 (new collection version) isn't used by ACS, sry for that ^_^' |
ProjectMoon
commented
Jan 25, 2016
Also, where is the best place to put tests for the secondary storage manager? Is there already a test for it? |
pedro-martins
commented
Jan 25, 2016
There isn't a test for this class if you want a suggestion, create a new folder named test in cloud-controller-secondary-storage project and create a new package in this folder named org.apache.cloudstack.secondarystorage with a class named SecondaryStorageManagerTest.java I think that is the correct pattern. |
ProjectMoon
commented
Jan 26, 2016
I have created the unit tests. They are in one commit. The tests test the protected methods delegated to by getDefaultNetworkForCreation. It tests all 4 possible code paths + 2 invalid input types. |
ProjectMoon
commented
Jan 27, 2016
Seems the Jenkins build is complaining about license missing. Don't see what file it is, but I assume it's the new unit test file? |
GabrielBrascher
commented
Jan 27, 2016
@ProjectMoon Yes, just need to add the license in "SecondaryStorageManagerTest" class. |
ProjectMoon
commented
Jan 27, 2016
License has been added. |
GabrielBrascher
commented
Jan 27, 2016
@ProjectMoon The code is better now, well documented and with tests. |
ProjectMoon
commented
Jan 29, 2016
Should the three commits be squashed? Or left in three? I suggest perhaps splitting the unit test commit into two, and putting each unit test with its corresponding refactor commit, so the end result is two commits, each refactoring one part of system VM network selection and providing an associated unit test. |
rodrigo93
commented
Jan 31, 2016
Hi @ProjectMoon, |
GabrielBrascher
commented
Feb 1, 2016
@rodrigo93 I think that a JIRA ticket wouldn't help much, considering that JIRA is for report issues (not PRs). I think that the point here is to analyze the code and give suggestions that could improve this code; if the work done by @ProjectMoon is ok, then a LGTM would do. |
ProjectMoon
commented
Feb 1, 2016
I would prefer just leaving one pull request here, but with two commits. Each commit would have the file changes + unit tests for the SSVM and CPVM, respectively. Not sure a JIRA ticket is really needed for this in my opinion. |
rodrigo93
commented
Feb 1, 2016
@GabrielBrascher@ProjectMoon, You are right. I thought I saw a some section in Jira for minor improvements, but I was wrong. Besides that, the code and work done here LGTM. |
ProjectMoon
commented
Feb 3, 2016
I now consider the pull request ready to be merged. The unit test commit has been split out and merged into the two commits for the console proxy and SSVM changes, so each commit refactors the class and provides new unit tests for the refactoring. The PR has also been rebased against latest master. |
ProjectMoon
commented
Feb 18, 2016
PR rebased against latest master. |
It is now broken into separate methods for more readability and flexibility. Each zone type (basic, advanced) has its own method for getting the default network when creating the VM.
It is now broken into separate methods based on zone. Each zone type (basic, advanced) has its own method to select the default network when starting the VM.
| } | ||
| @Test | ||
| public void getDefaultNetworkForAdvancedSG() { |
There was a problem hiding this comment.
I don't see any security group related check in getDefaultNetworkForBasicZone(). Why do you need tests for SG/non-SG in case basic zone?
There was a problem hiding this comment.
To cover all scenarios. Even if there is no security group-related checks in getDefaultNetworkForBasicZone, client code doesn't necessarily know this and the unit tests should make sure all possible combinations work.
There was a problem hiding this comment.
@ProjectMoon The unit tests getDefaultNetworkForBasicNonSG() and getDefaultNetworkForBasicSG() are same since SG has no impact on the method being tested.
The line "when(dc.isSecurityGroupEnabled()).thenReturn(true or false);" doesn't impact test outcome. Thats what I mentioned in my initial comment.
swill
commented
May 18, 2016
CI RESULTSSummary of the problem(s): Associated Uploads
Uploads will be available until Comment created by |
swill
commented
May 18, 2016
I think this one is ready. The CI is coming back pretty clean and I have the required code review. |
swill
commented
May 20, 2016
CI RESULTSSummary of the problem(s): Associated Uploads
Uploads will be available until Comment created by |
swill
commented
May 20, 2016
Ran again because the error was not something I had seen often. The errors in the new run are not related to this PR. |
…k-creation Refactor system VM default network creationTwo small commits which moves the retrieval of the default network for the console proxy and the SSVM into a separate protected method. It's a small change that makes the code more readable/maintainable and also makes the class more suitable for overriding should one want to do this. It's forward-ported from our 4.2 branch. No new tests since this should not change any functionality, and thus should be covered by the existing unit tests. Now on the master branch (#1359 was on the wrong branch). * pr/1360: Refactor ssvm default network retrieval. Refactor console proxy default network retrieval. Signed-off-by: Will Stevens <williamstevens@gmail.com>
bvbharatk
commented
May 26, 2016
ACS CI BVT RunSumarry: Link to logs Folder (search by build_no):https://www.dropbox.com/sh/yj3wnzbceo9uef2/AAB6u-Iap-xztdm6jHX9SjPja?dl=0 Failed tests:
Skipped tests: Passed test suits: |
Two small commits which moves the retrieval of the default network for the console proxy and the SSVM into a separate protected method. It's a small change that makes the code more readable/maintainable and also makes the class more suitable for overriding should one want to do this. It's forward-ported from our 4.2 branch.
No new tests since this should not change any functionality, and thus should be covered by the existing unit tests.
Now on the master branch (#1359 was on the wrong branch).