def test_mgmt_batch_pools(self, resource_group, location, batch_account): # Test create PAAS pool paas_pool = "test_paas_pool" parameters = models.Pool( display_name="test_pool", vm_size='small', deployment_configuration=models.DeploymentConfiguration( cloud_service_configuration=models.CloudServiceConfiguration( os_family='5')), start_task=models.StartTask( command_line="cmd.exe /c \"echo hello world\"", resource_files=[ models.ResourceFile(http_url='https://blobsource.com', file_path='filename.txt') ], environment_settings=[ models.EnvironmentSetting(name='ENV_VAR', value='env_value') ], user_identity=models.UserIdentity( auto_user=models.AutoUserSpecification( elevation_level=models.ElevationLevel.admin))), user_accounts=[ models.UserAccount(name='UserName', password='******') ], scale_settings=models.ScaleSettings( fixed_scale=models.FixedScaleSettings( target_dedicated_nodes=0, target_low_priority_nodes=0))) response = self.mgmt_batch_client.pool.create(resource_group.name, batch_account.name, paas_pool, parameters) assert isinstance(response, models.Pool) # Test create IAAS pool iaas_pool = "test_iaas_pool" parameters = models.Pool( display_name="test_pool", vm_size='Standard_A1', deployment_configuration=models.DeploymentConfiguration( virtual_machine_configuration=models. VirtualMachineConfiguration( image_reference=models.ImageReference( publisher='MicrosoftWindowsServer', offer='WindowsServer', sku='2016-Datacenter-smalldisk'), node_agent_sku_id='batch.node.windows amd64', windows_configuration=models.WindowsConfiguration( enable_automatic_updates=True))), scale_settings=models.ScaleSettings( fixed_scale=models.FixedScaleSettings( target_dedicated_nodes=0, target_low_priority_nodes=0))) response = self.mgmt_batch_client.pool.create(resource_group.name, batch_account.name, iaas_pool, parameters) assert isinstance(response, models.Pool) # Test list pools pools = self.mgmt_batch_client.pool.list_by_batch_account( resource_group.name, batch_account.name) assert len(list(pools)) == 2 # Test Update pool parameters = models.Pool(scale_settings=models.ScaleSettings( auto_scale=models.AutoScaleSettings( # Change this to a value once accounts get default quotas formula='$TargetDedicatedNodes=0'))) if self.is_live: time.sleep(15) response = self.mgmt_batch_client.pool.update(resource_group.name, batch_account.name, iaas_pool, parameters) assert isinstance(response, models.Pool) # Test Get pool pool = self.mgmt_batch_client.pool.get(resource_group.name, batch_account.name, iaas_pool) assert isinstance(pool, models.Pool) assert pool.vm_size == 'STANDARD_A1' assert pool.display_name is not None # This assert should be reintroduced when targetDedidicated nodes can be 1+ # assert pool.allocation_state == models.AllocationState.resizing assert pool.deployment_configuration.virtual_machine_configuration.node_agent_sku_id == 'batch.node.windows amd64' # Test stop resizing # with pytest.raises(CloudError): # self.mgmt_batch_client.pool.stop_resize(resource_group.name, batch_account.name, iaas_pool) # if self.is_live: # time.sleep(300) # # Test disable auto-scale # response = self.mgmt_batch_client.pool.disable_auto_scale( # resource_group.name, batch_account.name, iaas_pool) # assert isinstance(response, models.Pool) # Test delete pool response = self.mgmt_batch_client.pool.begin_delete( resource_group.name, batch_account.name, iaas_pool) assert response.result() is None
def test_mgmt_batch_pools(self, resource_group, location, batch_account): # Test create PAAS pool paas_pool = "test_paas_pool" parameters = models.Pool( display_name="test_pool", vm_size='small', deployment_configuration=models.DeploymentConfiguration( cloud_service_configuration=models.CloudServiceConfiguration( os_family='5')), start_task=models.StartTask( command_line="cmd.exe /c \"echo hello world\"", resource_files=[ models.ResourceFile(http_url='https://blobsource.com', file_path='filename.txt') ], environment_settings=[ models.EnvironmentSetting('ENV_VAR', 'env_value') ], user_identity=models.UserIdentity( auto_user=models.AutoUserSpecification( elevation_level=models.ElevationLevel.admin))), user_accounts=[models.UserAccount('UserName', 'p@55wOrd')], scale_settings=models.ScaleSettings( fixed_scale=models.FixedScaleSettings( target_dedicated_nodes=0, target_low_priority_nodes=0))) response = self.mgmt_batch_client.pool.create(resource_group.name, batch_account.name, paas_pool, parameters) self.assertIsInstance(response.result(), models.Pool) # Test create IAAS pool iaas_pool = "test_iaas_pool" parameters = models.Pool( display_name="test_pool", vm_size='Standard_A1', deployment_configuration=models.DeploymentConfiguration( virtual_machine_configuration=models. VirtualMachineConfiguration( image_reference=models.ImageReference( publisher='MicrosoftWindowsServer', offer='WindowsServer', sku='2016-Datacenter-smalldisk'), node_agent_sku_id='batch.node.windows amd64', windows_configuration=models.WindowsConfiguration(True))), scale_settings=models.ScaleSettings( fixed_scale=models.FixedScaleSettings( target_dedicated_nodes=0, target_low_priority_nodes=0))) response = self.mgmt_batch_client.pool.create(resource_group.name, batch_account.name, iaas_pool, parameters) self.assertIsInstance(response.result(), models.Pool) # Test list pools pools = self.mgmt_batch_client.pool.list_by_batch_account( resource_group.name, batch_account.name) self.assertEqual(len(list(pools)), 2) # Test Update pool parameters = models.Pool(scale_settings=models.ScaleSettings( auto_scale=models.AutoScaleSettings( formula='$TargetDedicatedNodes=1'))) response = self.mgmt_batch_client.pool.update(resource_group.name, batch_account.name, iaas_pool, parameters) self.assertIsInstance(response, models.Pool) # Test Get pool pool = self.mgmt_batch_client.pool.get(resource_group.name, batch_account.name, iaas_pool) self.assertIsInstance(pool, models.Pool) self.assertEqual(pool.vm_size, 'STANDARD_A1'), self.assertIsNone(pool.display_name), self.assertEqual(pool.allocation_state, models.AllocationState.resizing) self.assertEqual( pool.deployment_configuration.virtual_machine_configuration. node_agent_sku_id, 'batch.node.windows amd64') # Test stop resizing with self.assertRaises(CloudError): self.mgmt_batch_client.pool.stop_resize(resource_group.name, batch_account.name, iaas_pool) if self.is_live: time.sleep(300) # Test disable auto-scale response = self.mgmt_batch_client.pool.disable_auto_scale( resource_group.name, batch_account.name, iaas_pool) self.assertIsInstance(response, models.Pool) # Test delete pool response = self.mgmt_batch_client.pool.delete(resource_group.name, batch_account.name, iaas_pool) self.assertIsNone(response.result())