mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	CLOUDSTACK-8145: Adding new test to test blocker bugs and modifying other test case to work around the bug
Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
		
							parent
							
								
									9056e4c3fb
								
							
						
					
					
						commit
						f11e570796
					
				| @ -106,7 +106,6 @@ class Services: | |||||||
|                         "sleep": 180, |                         "sleep": 180, | ||||||
|                      } |                      } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class TestTemplate(cloudstackTestCase): | class TestTemplate(cloudstackTestCase): | ||||||
| 
 | 
 | ||||||
|     def setUp(self): |     def setUp(self): | ||||||
| @ -253,7 +252,6 @@ class TestTemplate(cloudstackTestCase): | |||||||
|                         ) |                         ) | ||||||
|         return |         return | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| class TestNATRules(cloudstackTestCase): | class TestNATRules(cloudstackTestCase): | ||||||
| 
 | 
 | ||||||
|     @classmethod |     @classmethod | ||||||
| @ -1005,3 +1003,147 @@ class TestTemplates(cloudstackTestCase): | |||||||
|                             "Check the name of the template" |                             "Check the name of the template" | ||||||
|                         ) |                         ) | ||||||
|         return |         return | ||||||
|  | 
 | ||||||
|  | class TestDataPersistency(cloudstackTestCase): | ||||||
|  | 
 | ||||||
|  |     @classmethod | ||||||
|  |     def setUpClass(cls): | ||||||
|  | 
 | ||||||
|  |         cls.testClient = super(TestDataPersistency, cls).getClsTestClient() | ||||||
|  |         cls.api_client = cls.testClient.getApiClient() | ||||||
|  | 
 | ||||||
|  |         cls.services = cls.testClient.getParsedTestDataConfig() | ||||||
|  |         # Get Zone, Domain and templates | ||||||
|  |         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) | ||||||
|  |         cls.domain = get_domain(cls.api_client) | ||||||
|  |         cls.services['mode'] = cls.zone.networktype | ||||||
|  |         template = get_template( | ||||||
|  |                             cls.api_client, | ||||||
|  |                             cls.zone.id, | ||||||
|  |                             cls.services["ostype"] | ||||||
|  |                             ) | ||||||
|  |         cls.services["virtual_machine"]["zoneid"] = cls.zone.id | ||||||
|  | 
 | ||||||
|  |         #Create an account, network, VM and IP addresses | ||||||
|  |         cls.account = Account.create( | ||||||
|  |                                      cls.api_client, | ||||||
|  |                                      cls.services["account"], | ||||||
|  |                                      domainid=cls.domain.id | ||||||
|  |                                      ) | ||||||
|  | 
 | ||||||
|  |         cls.userapiclient = cls.testClient.getUserApiClient( | ||||||
|  |                             UserName=cls.account.name, | ||||||
|  |                             DomainName=cls.account.domain) | ||||||
|  | 
 | ||||||
|  |         cls.service_offering = ServiceOffering.create( | ||||||
|  |                                             cls.api_client, | ||||||
|  |                                             cls.services["service_offering"] | ||||||
|  |                                             ) | ||||||
|  |         cls.virtual_machine = VirtualMachine.create( | ||||||
|  |                                     cls.api_client, | ||||||
|  |                                     cls.services["virtual_machine"], | ||||||
|  |                                     templateid=template.id, | ||||||
|  |                                     accountid=cls.account.name, | ||||||
|  |                                     domainid=cls.account.domainid, | ||||||
|  |                                     serviceofferingid=cls.service_offering.id, | ||||||
|  |                                     mode=cls.services["mode"] | ||||||
|  |                                     ) | ||||||
|  |         cls.cleanup = [ | ||||||
|  |                        cls.account, | ||||||
|  |                        cls.service_offering | ||||||
|  |                        ] | ||||||
|  |         return | ||||||
|  | 
 | ||||||
|  |     @classmethod | ||||||
|  |     def tearDownClass(cls): | ||||||
|  |         try: | ||||||
|  |             #Clean up, terminate the created templates | ||||||
|  |             cleanup_resources(cls.api_client, cls.cleanup) | ||||||
|  | 
 | ||||||
|  |         except Exception as e: | ||||||
|  |             raise Exception("Warning: Exception during cleanup : %s" % e) | ||||||
|  |         return | ||||||
|  | 
 | ||||||
|  |     def setUp(self): | ||||||
|  |         self.apiclient = self.testClient.getApiClient() | ||||||
|  |         return | ||||||
|  | 
 | ||||||
|  |     def tearDown(self): | ||||||
|  |         # No need | ||||||
|  |         return | ||||||
|  | 
 | ||||||
|  |     @attr(tags=["advanced", "basic", "advancedns", "eip"], required_hardware="true") | ||||||
|  |     def test_01_data_persistency_root_disk(self): | ||||||
|  |         """ | ||||||
|  |         Test the timing issue of root disk data sync | ||||||
|  | 
 | ||||||
|  |         # 1. Write data to root disk of a VM | ||||||
|  |         # 2. Create a template from the root disk of VM | ||||||
|  |         # 3. Create a new VM from this template | ||||||
|  |         # 4. Check that the data is present in the new VM | ||||||
|  | 
 | ||||||
|  |         This is to test that data is persisted on root disk of VM or not | ||||||
|  |         when template is created immediately from it | ||||||
|  |         """ | ||||||
|  | 
 | ||||||
|  |         ssh = self.virtual_machine.get_ssh_client() | ||||||
|  | 
 | ||||||
|  |         sampleText = "This is sample data" | ||||||
|  | 
 | ||||||
|  |         cmds = [ | ||||||
|  |                 "cd /root/", | ||||||
|  |                 "touch testFile.txt", | ||||||
|  |                 "chmod 600 testFile.txt", | ||||||
|  |                 "echo %s >> testFile.txt" % sampleText | ||||||
|  |                 ] | ||||||
|  |         for c in cmds: | ||||||
|  |             ssh.execute(c) | ||||||
|  | 
 | ||||||
|  |         #Stop virtual machine | ||||||
|  |         self.virtual_machine.stop(self.api_client) | ||||||
|  | 
 | ||||||
|  |         list_volume = Volume.list( | ||||||
|  |                             self.api_client, | ||||||
|  |                             virtualmachineid=self.virtual_machine.id, | ||||||
|  |                             type='ROOT', | ||||||
|  |                             listall=True) | ||||||
|  | 
 | ||||||
|  |         if isinstance(list_volume, list): | ||||||
|  |             self.volume = list_volume[0] | ||||||
|  |         else: | ||||||
|  |             raise Exception( | ||||||
|  |                 "Exception: Unable to find root volume for VM: %s" % | ||||||
|  |                 self.virtual_machine.id) | ||||||
|  | 
 | ||||||
|  |         self.services["template"]["ostype"] = self.services["ostype"] | ||||||
|  |         #Create templates for Edit, Delete & update permissions testcases | ||||||
|  |         customTemplate = Template.create( | ||||||
|  |                 self.userapiclient, | ||||||
|  |                 self.services["template"], | ||||||
|  |                 self.volume.id, | ||||||
|  |                 account=self.account.name, | ||||||
|  |                 domainid=self.account.domainid | ||||||
|  |             ) | ||||||
|  |         self.cleanup.append(customTemplate) | ||||||
|  |         # Delete the VM - No longer needed | ||||||
|  |         self.virtual_machine.delete(self.apiclient) | ||||||
|  | 
 | ||||||
|  |         virtual_machine = VirtualMachine.create( | ||||||
|  |                                     self.apiclient, | ||||||
|  |                                     self.services["virtual_machine"], | ||||||
|  |                                     templateid=customTemplate.id, | ||||||
|  |                                     accountid=self.account.name, | ||||||
|  |                                     domainid=self.account.domainid, | ||||||
|  |                                     serviceofferingid=self.service_offering.id, | ||||||
|  |                                     mode=self.services["mode"] | ||||||
|  |                                     ) | ||||||
|  | 
 | ||||||
|  |         ssh = virtual_machine.get_ssh_client() | ||||||
|  | 
 | ||||||
|  |         response = ssh.execute("cat /root/testFile.txt") | ||||||
|  |         res = str(response[0]) | ||||||
|  | 
 | ||||||
|  |         self.assertEqual(res, sampleText, "The data %s does not match\ | ||||||
|  |                 with sample test %s" % | ||||||
|  |                 (res, sampleText)) | ||||||
|  |         return | ||||||
|  | |||||||
| @ -200,6 +200,9 @@ class TestResetSSHKeypair(cloudstackTestCase): | |||||||
|             for c in cmds: |             for c in cmds: | ||||||
|                 ssh.execute(c) |                 ssh.execute(c) | ||||||
| 
 | 
 | ||||||
|  |             # Adding delay of 120 sec to avoid data loss due to timing issue | ||||||
|  |             time.sleep(120) | ||||||
|  | 
 | ||||||
|             #Stop virtual machine |             #Stop virtual machine | ||||||
|             cls.virtual_machine.stop(cls.api_client) |             cls.virtual_machine.stop(cls.api_client) | ||||||
| 
 | 
 | ||||||
| @ -1031,6 +1034,9 @@ class TestResetSSHKeyUserRights(cloudstackTestCase): | |||||||
|         for c in cmds: |         for c in cmds: | ||||||
|             ssh.execute(c) |             ssh.execute(c) | ||||||
| 
 | 
 | ||||||
|  |         # Adding delay of 120 sec to avoid data loss due to timing issue | ||||||
|  |         time.sleep(120) | ||||||
|  | 
 | ||||||
|         try: |         try: | ||||||
|             #Stop virtual machine |             #Stop virtual machine | ||||||
|             cls.virtual_machine.stop(cls.api_client) |             cls.virtual_machine.stop(cls.api_client) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user