Skip to content

Commit c04c89b

Browse files
author
Dingane Hlaluku
committed
Add marvin tests for all supported vm types
1 parent 658f0ea commit c04c89b

File tree

1 file changed

+173
-20
lines changed

1 file changed

+173
-20
lines changed

test/integration/smoke/test_diagnostics.py

Lines changed: 173 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
# under the License.
1717
""" BVT tests for remote diagnostics of system VMs
1818
"""
19+
import urllib
20+
21+
from marvin.cloudstackAPI import (runDiagnostics, getDiagnosticsData)
22+
from marvin.cloudstackTestCase import cloudstackTestCase
1923
# Import Local Modules
2024
from marvin.codes import FAILED
21-
from marvin.cloudstackTestCase import cloudstackTestCase
22-
from marvin.cloudstackAPI import (runDiagnostics, getDiagnosticsData)
23-
from marvin.lib.utils import (cleanup_resources)
2425
from marvin.lib.base import (Account,
2526
ServiceOffering,
2627
VirtualMachine)
@@ -29,7 +30,7 @@
2930
get_test_template,
3031
list_ssvms,
3132
list_routers)
32-
33+
from marvin.lib.utils import (cleanup_resources)
3334
from nose.plugins.attrib import attr
3435

3536

@@ -538,11 +539,11 @@ def test_12_traceroute_in_cpvm(self):
538539
'Failed to run remote Traceroute in CPVM'
539540
)
540541

541-
542542
'''
543543
Add Get Diagnostics data BVT
544544
'''
545-
@attr(tags=["advanced", "advancedns", "ssh", "smoke", "dingane"], required_hardware="true")
545+
546+
@attr(tags=["advanced", "advancedns", "ssh", "smoke"], required_hardware="true")
546547
def test_13_retrieve_vr_default_files(self):
547548
list_router_response = list_routers(
548549
self.apiclient,
@@ -554,28 +555,180 @@ def test_13_retrieve_vr_default_files(self):
554555
True,
555556
"Check list response returns a valid list"
556557
)
558+
559+
router = list_router_response[0]
560+
self.debug('Setting up VR with ID %s' % router.id)
561+
cmd = getDiagnosticsData.getDiagnosticsDataCmd()
562+
cmd.targetid = router.id
563+
564+
response = self.apiclient.getDiagnosticsData(cmd)
565+
is_valid_url = self.check_url(response.url)
566+
567+
self.assertEqual(
568+
True,
569+
is_valid_url,
570+
msg="Failed to create valid download url response"
571+
)
572+
573+
def check_url(self, url):
574+
import urllib2
575+
try:
576+
r = urllib.urlopen(url)
577+
if r.code == 200:
578+
return True
579+
except urllib2.HTTPError:
580+
return False
581+
except urllib2.URLError:
582+
return False
583+
return True
584+
585+
@attr(tags=["advanced", "advancedns", "ssh", "smoke"], required_hardware="true")
586+
def test_14_retrieve_vr_one_file(self):
587+
list_router_response = list_routers(
588+
self.apiclient,
589+
account=self.account.name,
590+
domainid=self.account.domainid
591+
)
592+
self.assertEqual(
593+
isinstance(list_router_response, list),
594+
True,
595+
"Check list response returns a valid list"
596+
)
597+
557598
router = list_router_response[0]
558-
self.debug('Setting up SSVM with ID %s' % router.id)
599+
self.debug('Setting up VR with ID %s' % router.id)
559600
cmd = getDiagnosticsData.getDiagnosticsDataCmd()
560601
cmd.targetid = router.id
561602
cmd.type = "/var/log/cloud.log"
562603

563604
response = self.apiclient.getDiagnosticsData(cmd)
564-
bool = None
565-
if not response.url:
566-
bool = False
567-
else:
568-
bool = True
569605

570-
self.assertEqual(bool, True, "Url response object not set")
606+
is_valid_url = self.check_url(response.url)
607+
608+
self.assertEqual(
609+
True,
610+
is_valid_url,
611+
msg="Failed to create valid download url response"
612+
)
613+
614+
@attr(tags=["advanced", "advancedns", "ssh", "smoke"], required_hardware="true")
615+
def test_15_retrieve_ssvm_default_files(self):
616+
list_ssvm_response = list_ssvms(
617+
self.apiclient,
618+
systemvmtype='secondarystoragevm',
619+
state='Running',
620+
)
621+
622+
self.assertEqual(
623+
isinstance(list_ssvm_response, list),
624+
True,
625+
'Check list response returns a valid list'
626+
)
627+
ssvm = list_ssvm_response[0]
628+
629+
self.debug('Setting up SSVM with ID %s' % ssvm.id)
630+
631+
cmd = getDiagnosticsData.getDiagnosticsDataCmd()
632+
cmd.targetid = ssvm.id
633+
634+
response = self.apiclient.getDiagnosticsData(cmd)
635+
636+
is_valid_url = self.check_url(response.url)
637+
638+
self.assertEqual(
639+
True,
640+
is_valid_url,
641+
msg="Failed to create valid download url response"
642+
)
643+
644+
@attr(tags=["advanced", "advancedns", "ssh", "smoke"], required_hardware="true")
645+
def test_16_retrieve_ssvm_single_file(self):
646+
list_ssvm_response = list_ssvms(
647+
self.apiclient,
648+
systemvmtype='secondarystoragevm',
649+
state='Running',
650+
)
651+
652+
self.assertEqual(
653+
isinstance(list_ssvm_response, list),
654+
True,
655+
'Check list response returns a valid list'
656+
)
657+
ssvm = list_ssvm_response[0]
658+
659+
self.debug('Setting up SSVM with ID %s' % ssvm.id)
660+
661+
cmd = getDiagnosticsData.getDiagnosticsDataCmd()
662+
cmd.targetid = ssvm.id
663+
cmd.type = "/var/log/cloud.log"
664+
665+
response = self.apiclient.getDiagnosticsData(cmd)
666+
667+
is_valid_url = self.check_url(response.url)
668+
669+
self.assertEqual(
670+
True,
671+
is_valid_url,
672+
msg="Failed to create valid download url response"
673+
)
674+
675+
@attr(tags=["advanced", "advancedns", "ssh", "smoke"], required_hardware="true")
676+
def test_17_retrieve_cpvm_default_files(self):
677+
list_cpvm_response = list_ssvms(
678+
self.apiclient,
679+
systemvmtype='consoleproxy',
680+
state='Running',
681+
)
682+
683+
self.assertEqual(
684+
isinstance(list_cpvm_response, list),
685+
True,
686+
'Check list response returns a valid list'
687+
)
688+
cpvm = list_cpvm_response[0]
689+
690+
self.debug('Setting up SSVM with ID %s' % cpvm.id)
691+
692+
cmd = getDiagnosticsData.getDiagnosticsDataCmd()
693+
cmd.targetid = cpvm.id
694+
695+
response = self.apiclient.getDiagnosticsData(cmd)
696+
697+
is_valid_url = self.check_url(response.url)
571698

699+
self.assertEqual(
700+
True,
701+
is_valid_url,
702+
msg="Failed to create valid download url response"
703+
)
572704

573-
pass
705+
@attr(tags=["advanced", "advancedns", "ssh", "smoke"], required_hardware="true")
706+
def test_18_retrieve_cpvm_single_file(self):
707+
list_cpvm_response = list_ssvms(
708+
self.apiclient,
709+
systemvmtype='consoleproxy',
710+
state='Running',
711+
)
574712

575-
@attr(tags=["advanced", "advancedns", "ssh", "smoke", "retrieve"], required_hardware="true")
576-
def test_14_retrieve_ssvm_default_files(self):
577-
pass
713+
self.assertEqual(
714+
isinstance(list_cpvm_response, list),
715+
True,
716+
'Check list response returns a valid list'
717+
)
718+
cpvm = list_cpvm_response[0]
719+
720+
self.debug('Setting up SSVM with ID %s' % cpvm.id)
578721

579-
@attr(tags=["advanced", "advancedns", "ssh", "smoke", "retrieve"], required_hardware="true")
580-
def test_15_retrieve_cpvm_default_files(self):
581-
pass
722+
cmd = getDiagnosticsData.getDiagnosticsDataCmd()
723+
cmd.targetid = cpvm.id
724+
cmd.type = "/var/log/cloud.log"
725+
726+
response = self.apiclient.getDiagnosticsData(cmd)
727+
728+
is_valid_url = self.check_url(response.url)
729+
730+
self.assertEqual(
731+
True,
732+
is_valid_url,
733+
msg="Failed to create valid download url response"
734+
)

0 commit comments

Comments
 (0)