Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0658e24
Beginning to End workflow for Virtual Router
May 15, 2018
bbe380d
Refactoring unused code
May 17, 2018
836bcb1
Testing agent-manager connection error
May 21, 2018
67669db
Minor Fixes on Command/Answer class
May 24, 2018
95e8e57
Initial successful test with VR and Ping command
May 28, 2018
17dc1e1
Modified code to allow for all system VMs and all three ICMP commands
May 30, 2018
8cf67d3
Fixing typos
May 31, 2018
c9d4458
Fixing merge conflicts
May 31, 2018
259a459
Migrating to python based script
May 31, 2018
cd5e623
Renaming packages to diagnostics
May 31, 2018
bf01218
Removing nested comments
Jun 1, 2018
448fb44
Working on unit test impl
Jun 1, 2018
1e60bdc
Migrated to python based script, and added validation for optional pa…
Jun 5, 2018
9b9cb89
Removing unsused imports
Jun 5, 2018
72f7023
Adding Marvin tests
Jun 5, 2018
05483de
Adding traceroute command to Marvin tests
Jun 6, 2018
1df8855
Renaming packages to diagnostics and code refactoring
Jun 11, 2018
1ff1298
Refactoring API response object to include STDOUT, STDERR and EXITCODE
Jun 12, 2018
6a09386
Marvin tests complete
Jun 12, 2018
0c45874
Adding unit tests
Jun 13, 2018
289a4ed
For rebuilding testing packages
Jun 14, 2018
e3f2bef
Using AgentManager's EasySend
Jun 18, 2018
7645c07
Testing VMware hypervisor
Jun 18, 2018
9801b9f
Removing unused import
Jun 18, 2018
149f422
Fix issue with packaging failures
Jun 18, 2018
97e560d
Setting executeInSequence for VMware tests
Jun 18, 2018
50d152f
For testing VMware fix
Jun 19, 2018
93a3cfb
Fix typos in Answer class
Jun 19, 2018
5571123
Testing Fix for system vm access details
Jun 20, 2018
6a11767
Removed commented code
Jun 20, 2018
2ddb21b
Adding fix for VMware and ammending unit tests to capture changes
Jun 20, 2018
11a818b
Removed hard-coded values in Cmd class
Jun 21, 2018
2f5767c
Changed API name to runDiagnostics
Jun 22, 2018
80058c2
Updated marvin and unit test to use new API name, also changed from i…
Jun 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Marvin tests complete
  • Loading branch information
Dingane Hlaluku committed Jun 12, 2018
commit 6a093864b844f55180c6a6df16127cf034281e14
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
response.setStdout(answerMap.get("STDOUT"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Change the .get() to get based on a known constant than a hardcoded string like STDOUT, STDERR and EXITCODE.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

response.setStderr(answerMap.get("STDERR"));
response.setExitCode(answerMap.get("EXITCODE"));
response.setResult(answerMap.get("SUCCESS"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

as discussed: considder not returning success but only exitcode.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed success return

response.setObjectName("diagnostics");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should the name contain some noun or verb indicating that it contains the resiult of a test/diagnostic command-run?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe involve Paul in that discussion

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changed it to diagnostics results

response.setResponseName(getCommandName());
this.setResponseObject(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ public DiagnosticsAnswer(DiagnosticsCommand cmd, boolean result, String details)
public Map<String, String> getExecutionDetails() {
final Map<String, String> executionDetailsMap = new HashMap<>();
final String[] parseDetails = details.split("}");
executionDetailsMap.put("STDOUT", parseDetails[0]);
executionDetailsMap.put("STDERR", parseDetails[1]);
executionDetailsMap.put("EXITCODE", parseDetails[2]);
executionDetailsMap.put("STDOUT", parseDetails[0].trim());
executionDetailsMap.put("STDERR", parseDetails[1].trim());
executionDetailsMap.put("EXITCODE", String.valueOf(parseDetails[2]).trim());
executionDetailsMap.put("SUCCESS", String.valueOf(result));
return executionDetailsMap;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
import com.cloud.utils.Pair;
import com.cloud.utils.component.Manager;
import com.cloud.vm.VirtualMachine.PowerState;
import org.apache.cloudstack.diagnostics.DiagnosticsAnswer;
import org.apache.cloudstack.diagnostics.DiagnosticsCommand;

import java.util.HashMap;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if only the order of imports has changed you better revert this

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

import java.util.Map;
Expand Down Expand Up @@ -99,8 +97,6 @@ public interface MockVmManager extends Manager {

CheckRouterAnswer checkRouter(CheckRouterCommand cmd);

DiagnosticsAnswer executeDiagnostics(DiagnosticsCommand cmd);

Answer cleanupNetworkRules(CleanupNetworkRulesCmd cmd, SimulatorInfo info);

Answer scaleVm(ScaleVmCommand cmd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@
import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.VirtualMachine.PowerState;
import org.apache.cloudstack.diagnostics.DiagnosticsAnswer;
import org.apache.cloudstack.diagnostics.DiagnosticsCommand;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if only the order of imports has changed you better revert this

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -273,14 +271,6 @@ public CheckRouterAnswer checkRouter(final CheckRouterCommand cmd) {
}
}

@Override
public DiagnosticsAnswer executeDiagnostics(final DiagnosticsCommand cmd) {
final String router_name = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
final MockVm vm = _mockVmDao.findByVmName(router_name);

return new DiagnosticsAnswer(cmd, true, null);
}

@Override
public Map<String, PowerState> getVmStates(final String hostGuid) {
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
// under the License.
package com.cloud.agent.manager;

import java.util.HashMap;
import java.util.Map;

import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.StoragePoolInfo;
Expand All @@ -29,6 +26,9 @@
import com.cloud.utils.component.Manager;
import com.cloud.vm.VirtualMachine.PowerState;

import java.util.HashMap;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if only the order of imports has changed you better revert this

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

import java.util.Map;

public interface SimulatorManager extends Manager {
public static final String Name = "simulator manager";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
import com.google.gson.stream.JsonReader;
import org.apache.cloudstack.ca.SetupCertificateCommand;
import org.apache.cloudstack.ca.SetupKeyStoreCommand;
import org.apache.cloudstack.diagnostics.DiagnosticsCommand;
import org.apache.cloudstack.storage.command.DeleteCommand;
import org.apache.cloudstack.storage.command.DownloadCommand;
import org.apache.cloudstack.storage.command.DownloadProgressCommand;
Expand Down Expand Up @@ -389,8 +388,6 @@ public Answer simulate(final Command cmd, final String hostGuid) {
answer = _mockVmMgr.getVmStats((GetVmStatsCommand)cmd);
} else if (cmd instanceof CheckRouterCommand) {
answer = _mockVmMgr.checkRouter((CheckRouterCommand) cmd);
}else if (cmd instanceof DiagnosticsCommand) {
answer = _mockVmMgr.executeDiagnostics((DiagnosticsCommand)cmd);
} else if (cmd instanceof GetDomRVersionCmd) {
answer = _mockVmMgr.getDomRVersion((GetDomRVersionCmd)cmd);
} else if (cmd instanceof CopyVolumeCommand) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public class DiagnosticsServiceImpl extends ManagerBase implements PluggableServ
@Inject
private ConfigurationDao configurationDao;


@Override
public Map<String, String> runDiagnosticsCommand(final ExecuteDiagnosticsCmd cmd) throws AgentUnavailableException, InvalidParameterValueException {
final Long vmId = cmd.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,24 @@
// specific language governing permissions and limitations
// under the License.
//

package org.apache.cloudstack.diagnostics;

import com.cloud.exception.InvalidParameterValueException;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.dao.VMInstanceDao;
import junit.framework.TestCase;
import org.apache.cloudstack.api.command.admin.diagnostics.ExecuteDiagnosticsCmd;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class DiagnosticsServiceImplTest extends TestCase {

@Mock
private VMInstanceDao vmInstanceDao;
@Mock
private ExecuteDiagnosticsCmd executeDiagnosticsCmd;
@InjectMocks
private DiagnosticsServiceImpl diagnosticsService = new DiagnosticsServiceImpl();
public class DiagnosticsServiceImplTest {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove extra newline.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
executeDiagnosticsCmd = Mockito.mock(ExecuteDiagnosticsCmd.class);
Mockito.when(executeDiagnosticsCmd.getId()).thenReturn(1L);
Mockito.when(executeDiagnosticsCmd.getAddress()).thenReturn("8.8.8.8");
Mockito.when(executeDiagnosticsCmd.getType().getValue()).thenReturn("ping");
Mockito.when(executeDiagnosticsCmd.getOptionalArguments()).thenReturn("-c");
}

@Test(expected = InvalidParameterValueException.class)
public void testExecuteDiagnosticsToolInSystemVmThrowsException() throws Exception {
Mockito.when(vmInstanceDao.findByIdTypes(executeDiagnosticsCmd.getId(), VirtualMachine.Type.ConsoleProxy,
VirtualMachine.Type.DomainRouter, VirtualMachine.Type.SecondaryStorageVm)).thenReturn(null);
diagnosticsService.runDiagnosticsCommand(executeDiagnosticsCmd);
@After
public void tearDown() throws Exception {
}

@Test
public void runDiagnosticsCommand() {
}
}
}
1 change: 0 additions & 1 deletion systemvm/debian/opt/cloud/bin/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import sys


# Execute shell command
def run_cmd(command):
if command is not None:
p = subprocess.Popen(shlex.split(command), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand Down
Loading