Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
1ee9980
Initial commit
charles-phiri May 17, 2018
9f7eff1
some code to enhance the configure method in the Service Layer
charles-phiri May 17, 2018
987534e
refactored Service interface
charles-phiri May 17, 2018
4ef4c2f
refactored Service interface
charles-phiri May 23, 2018
6256e91
refactored Service interface
charles-phiri May 23, 2018
c7e5572
refactored Service interface
charles-phiri May 23, 2018
74822ce
refactored Service interface
charles-phiri May 24, 2018
e017c1c
refactored Service interface
charles-phiri May 24, 2018
9438236
refactored Service interface
charles-phiri May 28, 2018
99bb448
refactored Service interface
charles-phiri May 28, 2018
3cdb059
refactored Service interface
charles-phiri May 28, 2018
be2d1b3
refactored Service interface
charles-phiri May 29, 2018
6c76aa9
refactored Service interface
charles-phiri May 29, 2018
1e24faa
refactored Service interface
charles-phiri May 29, 2018
ee7907c
refactored Service interface
charles-phiri May 29, 2018
65b7d38
refactored Service interface
charles-phiri May 29, 2018
182dea9
Removed unused imports
charles-phiri May 29, 2018
395b246
refactored Service interface
charles-phiri May 29, 2018
aae408c
refactored Service interface
charles-phiri May 29, 2018
a4c6d5d
This is a compiled version of the work I have been doing so far. I am…
charles-phiri May 29, 2018
e8aa68b
Changed the schema script which was having errors when deploying the DB.
charles-phiri May 29, 2018
a10c798
Minor fixes on SQL schema file
charles-phiri May 30, 2018
e0292b5
Changed the schema script which was having errors when deploying the DB.
charles-phiri May 30, 2018
64a6185
Refactored some code in the API (Cmd) class.
charles-phiri May 30, 2018
135383d
Added some more functionality in the Service Layer class.
charles-phiri May 30, 2018
2be2e9d
Removed the code that was using generics in the class DiagnosticsKey.
charles-phiri May 30, 2018
943626e
Corrected code in my DiagnosticsConfigDepotImpl class that was using …
charles-phiri May 30, 2018
e187bc1
Corrected code in my RetrieveDiagnosticsVO class that was using the g…
charles-phiri May 30, 2018
98e2aa5
Yet still, removed some code using generics code.
charles-phiri May 30, 2018
3b97954
Added more code in the Service Layer class and refactored code in the…
charles-phiri May 31, 2018
987b6f7
Refactored code in Service Impl class.
charles-phiri May 31, 2018
2ff8287
Added code in spring xml file.
charles-phiri May 31, 2018
351f721
Created my own interface class for DiagnosticsConfigDepotImpl as I co…
charles-phiri May 31, 2018
94a2fb5
Changed most of the code in the DaO and VO classes including its usag…
charles-phiri Jun 4, 2018
8b57ee6
Refactored code in the Dao and VO, and also added one more method to …
charles-phiri Jun 5, 2018
8995e4f
Cleaned up the code and refactored code so that it has some of the ch…
charles-phiri Jun 6, 2018
e6c1029
Refactored code in the Service Layer impl.
charles-phiri Jun 6, 2018
974de4a
Made some code logic changes to the Service Layer when populating the…
charles-phiri Jun 7, 2018
fc5ef6f
Addressed comments on the code.
charles-phiri Jun 7, 2018
ca4dd82
Refactored code in the Service Layer for retrieving recodes from the …
charles-phiri Jun 7, 2018
ca5c308
Added unit test file to test the functionality in the Service Layer i…
charles-phiri Jun 12, 2018
fa129fa
Added unit test file to test the functionality in the Service Layer i…
charles-phiri Jun 12, 2018
e97895f
Removed the duplicated licence information.
charles-phiri Jun 12, 2018
f525aa9
1. Cleaned up code as per Daan's comments.
charles-phiri Jun 13, 2018
3e62161
Mgt-server could be running in a vm that does not have diskOffering. …
charles-phiri Jun 14, 2018
cc880d4
Added code to check capacity of the disk space and compare it to the …
charles-phiri Jun 14, 2018
91514d4
Added code to check capacity of the disk space and compare it to the …
charles-phiri Jun 14, 2018
141ab51
Added code to check capacity of the disk space and compare it to the …
charles-phiri Jun 14, 2018
2e55ec2
Added code to check capacity of the disk space and compare it to the …
charles-phiri Jun 19, 2018
d2b2d62
Added code to check capacity of the disk space and compare it to the …
charles-phiri Jun 20, 2018
45bd812
Added code to parse for a default value which is in square brackets, …
charles-phiri Jun 21, 2018
c9d7ad2
Inserted getters/setters for the script filename variables
charles-phiri Jun 21, 2018
dd5579d
Added skeleton scripts (still adding code) to retrieve files and run …
charles-phiri Jun 26, 2018
46098bc
Added code for the two command classes (ExecuteScriptCommand and Retr…
charles-phiri Jun 27, 2018
5d22c03
Added code for the two command classes (ExecuteScriptCommand and Retr…
charles-phiri Jun 27, 2018
5086e34
Added code for the two command classes (ExecuteScriptCommand and Retr…
charles-phiri Jun 27, 2018
555cc86
Add method to check disk space
charles-phiri Jun 27, 2018
94b414d
Minor changes in unit test
charles-phiri Jun 27, 2018
0f19d46
Still working on unit test
charles-phiri Jun 28, 2018
956a434
Added more unit tests.
charles-phiri Jun 28, 2018
76e5545
Skeleton implementation of the Garbage Collector.
charles-phiri Jun 28, 2018
c458261
Refactored code while testing, mostly in the Service Layer. Added a c…
charles-phiri Jul 8, 2018
9a6c5cf
Got rid of the cyclic dependencies that I was encountering when compi…
charles-phiri Jul 10, 2018
24f123a
Merge branch 'master' of https://github.com/apache/cloudstack into re…
charles-phiri Jul 10, 2018
f66c840
Refactored code in the Service Layer and the python scripts for retri…
charles-phiri Jul 17, 2018
1e4a426
Marvin tests for the RetrieveDiagnostics API
charles-phiri Jul 19, 2018
63f6b9b
Full complete code after refactoring. Addition of copyFileFromSystemV…
charles-phiri Jul 25, 2018
3acbfe4
Code cleanup and refactoring
charles-phiri Jul 26, 2018
d08cc7b
Complete RerieveDiagnostics API implementation for testing.
charles-phiri Jul 27, 2018
3c12e07
Complete RerieveDiagnostics API .
charles-phiri Jul 27, 2018
f88bde0
Minor bug fixes.
charles-phiri Jul 29, 2018
720da4c
Code for the RetrieveDiagnostics API.
charles-phiri Aug 8, 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 for the RetrieveDiagnostics API
  • Loading branch information
charles-phiri committed Jul 19, 2018
commit 1e4a42672d004833a1562812ba58a1e8980c1cf0
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.internal.util.reflection.Whitebox;
import org.mockito.runners.MockitoJUnitRunner;

import java.util.Arrays;
Expand Down Expand Up @@ -109,9 +110,6 @@ public void tearDown() throws Exception {
Mockito.reset(_agentManager);
Mockito.reset(instanceDao);
Mockito.reset(instanceVO);
//Mockito.reset(retrieveFilesCommand);
//Mockito.reset(executeScriptCommand);

}

@Test
Expand Down Expand Up @@ -214,4 +212,17 @@ public void runRetrieveDiagnosticsFilesTrueTest() throws Exception {
assertEquals(3, resultsMap.size());
}

@Test
public void testGarbageCollectStartExecution() throws Exception {
RetrieveDiagnosticsServiceImpl diagnosticsServiceMock = mock(RetrieveDiagnosticsServiceImpl.class);
when(diagnosticsServiceMock.start()).thenReturn(true);
Whitebox.setInternalState(retrieveDiagnosticsService, "RetrieveDiagnosticsFileAge", diagnosticsServiceMock);

try {
retrieveDiagnosticsService.start();
} catch (NullPointerException e) {
fail();
}
}

}
235 changes: 235 additions & 0 deletions test/integration/smoke/test_retrieve_diagnostics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
# Licensed to the Apache Software Foundation (ASF) under one
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 of structure I think this looks good, let me get back on this when I pick this up for testing and possibly point any missing scenario.

# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
""" BVT tests for retrieve diagnostics of system VMs
"""
# Import Local Modules
from marvin.codes import FAILED
from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.cloudstackAPI import retrieveDiagnostics
from marvin.lib.utils import (cleanup_resources)
from marvin.lib.base import (Account,
ServiceOffering,
VirtualMachine,
Configurations)
from marvin.lib.common import (get_domain,
get_zone,
get_test_template,
list_ssvms,
list_routers)

from nose.plugins.attrib import attr

class TestRetrieveDiagnostics(cloudstackTestCase):
"""
Test retrieve diagnostics with system VMs and VR as root admin
"""

@classmethod
def setUpClass(cls):

testClient = super(TestRetrieveDiagnostics, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.services = testClient.getParsedTestDataConfig()

# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.hypervisor = testClient.getHypervisorInfo()
cls.services['mode'] = cls.zone.networktype
template = get_test_template(
cls.apiclient,
cls.zone.id,
cls.hypervisor
)
if template == FAILED:
cls.fail("get_test_template() failed to return template")

cls.services["virtual_machine"]["zoneid"] = cls.zone.id

# Create an account, network, VM and IP addresses
cls.account = Account.create(
cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
cls.service_offering = ServiceOffering.create(
cls.apiclient,
cls.services["service_offerings"]["tiny"]
)
cls.vm_1 = VirtualMachine.create(
cls.apiclient,
cls.services["virtual_machine"],
templateid=template.id,
accountid=cls.account.name,
domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id
)
cls.cleanup = [
cls.account,
cls.service_offering,
cls.vm_1
]

@classmethod
def tearDownClass(cls):
try:
cls.apiclient = super(
TestRetrieveDiagnostics,
cls
).getClsTestClient().getApiClient()
# Clean up, terminate the created templates
cleanup_resources(cls.apiclient, cls.cleanup)

except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)

def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.dbClient = self.testClient.getDbConnection()
self.hypervisor = self.testClient.getHypervisorInfo()

@attr(tags=["advanced", "smoke", "eip", "advancedns", "sg"], required_hardware="true")
def test_ssvm_retrieve_files_success(self):
list_ssvm_response = list_ssvms(
self.apiclient,
systemvmId='secondarystoragevm',
state='Running',
)

self.assertEqual(
isinstance(list_ssvm_response, list),
True,
'Check list response returns a valid list'
)
ssvm = list_ssvm_response[0]
cmd = retrieveDiagnostics.retrieveDiagnosticsCmd()
cmd.systemvmId = ssvm.id
cmd.type = "LOGFILES"
cmd.details = "/var/log/cloudstack/agent/agent.log,/var/log/yum.log,/var/log/cloudstack/agent/security_group.log"
response = self.apiclient.getDiagnosticsFiles(cmd)
self.assertEqual(len(response), 1)
self.assertEqual(response[0].name, 'url')

@attr(tags=["advanced", "smoke", "eip", "advancedns", "sg"], required_hardware="true")
def test_router_retrieve_files_success(self):
list_router_response = list_ssvms(
self.apiclient,
systemvmId='domainrouter',
state='Running',
)

self.assertEqual(
isinstance(list_router_response, list),
True,
'Check list response returns a valid list'
)
ssvm = list_router_response[0]
cmd = retrieveDiagnostics.retrieveDiagnosticsCmd()
cmd.systemvmId = ssvm.id
cmd.type = "LOGFILES"
cmd.details = "/var/log/cloudstack/agent/agent.log,/var/log/cloudstack/agent/security_group.log,[IPTABLES]"
response = self.apiclient.getDiagnosticsFiles(cmd)
self.assertEqual(len(response), 1)
self.assertEqual(response[0].name, 'Log file downloaded successfully')

@attr(tags=["advanced", "smoke", "eip", "advancedns", "sg"], required_hardware="true")
def test_cpvm_retrieve_files_success(self):
list_cpvm_response = list_ssvms(
self.apiclient,
systemvmId='consoleproxy',
state='Running',
)

self.assertEqual(
isinstance(list_cpvm_response, list),
True,
'Check list response returns a valid list'
)
ssvm = list_cpvm_response[0]
cmd = retrieveDiagnostics.retrieveDiagnosticsCmd()
cmd.systemvmId = ssvm.id
cmd.type = "LOGFILES"
cmd.details = "/var/log/cloudstack/agent/agent.log,/var/log/cloudstack/agent/security_group.log,[IPTABLES]"
response = self.apiclient.getDiagnosticsFiles(cmd)
self.assertEqual(len(response), 1)
self.assertEqual(response[0].name, 'Log file downloaded successfully')

@attr(tags=["advanced", "smoke", "eip", "advancedns", "sg"], required_hardware="true")
def test_ssvm_retrieve_files_failure(self):
list_ssvm_response = list_ssvms(
self.apiclient,
systemvmId='consoleproxy',
state='Running',
)

self.assertEqual(
isinstance(list_ssvm_response, list),
True,
'Check list response returns a valid list'
)
ssvm = list_ssvm_response[0]
cmd = retrieveDiagnostics.retrieveDiagnosticsCmd()
cmd.systemvmId = ssvm.id
cmd.type = "FILES"
cmd.details = "agent.log,cloud.log"
response = self.apiclient.getDiagnosticsFiles(cmd)
self.assertEqual(len(response), 1)
self.assertEqual(response[0].name, 'Failed to locate files from the system vm, check if the directory specified is correct.')

@attr(tags=["advanced", "smoke", "eip", "advancedns", "sg"], required_hardware="true")
def test_router_retrieve_files_failure(self):
list_router_response = list_ssvms(
self.apiclient,
systemvmId='domainrouter',
state='Running',
)

self.assertEqual(
isinstance(list_router_response, list),
True,
'Check list response returns a valid list'
)
ssvm = list_router_response[0]
cmd = retrieveDiagnostics.retrieveDiagnosticsCmd()
cmd.systemvmId = ssvm.id
cmd.type = "FILES"
cmd.details = "[IPTABLES],[IFCONFIG]"
response = self.apiclient.getDiagnosticsFiles(cmd)
self.assertEqual(len(response), 1)
self.assertEqual(response[0].name, 'Diagnostic type specified is not supported.')

@attr(tags=["advanced", "smoke", "eip", "advancedns", "sg"], required_hardware="true")
def test_cpvm_retrieve_files_failure(self):
list_cpvm_response = list_ssvms(
self.apiclient,
systemvmId='testingvm',
state='Running',
)

self.assertEqual(
isinstance(list_cpvm_response, list),
True,
'Check list response returns a valid list'
)
ssvm = list_cpvm_response[0]
cmd = retrieveDiagnostics.retrieveDiagnosticsCmd()
cmd.systemvmId = ssvm.id
cmd.type = "FILES"
cmd.details = "[IPTABLES],[IFCONFIG]"
response = self.apiclient.getDiagnosticsFiles(cmd)
self.assertEqual(len(response), 1)
self.assertEqual(response[0].name, 'Failed to find the system vm specified.')