class TestInstanceWaiter(TestCase): def setUp(self): self.vpc_peering_connection_waiter = VpcPeeringConnectionWaiter( 1, 0.02) @patch("time.sleep", helper.change_to_active) def test_waiter(self): helper.change_to_pending_acceptance(Mock()) peering_conn = self.vpc_peering_connection_waiter.wait( vpc_peering_connection, VpcPeeringConnectionWaiter.ACTIVE) self.assertEqual(peering_conn, vpc_peering_connection) self.assertEqual(peering_conn.reload.call_count, 1) def test_waiter_timeout(self): helper.change_to_pending_acceptance(Mock()) self.assertRaises( Exception, self.vpc_peering_connection_waiter.wait, vpc_peering_connection, VpcPeeringConnectionWaiter.ACTIVE, ) @patch("time.sleep", helper.change_to_failed) def test_waiter_throw_on_error_state(self): helper.change_to_pending_acceptance(Mock()) self.assertRaises( Exception, self.vpc_peering_connection_waiter.wait, vpc_peering_connection, VpcPeeringConnectionWaiter.ACTIVE, )
class TestInstanceWaiter(TestCase): def setUp(self): self.vpc_peering_connection_waiter = VpcPeeringConnectionWaiter(1, 0.02) # self.vpc_peering_connection = Mock() @patch('time.sleep', helper.change_to_active) def test_waiter(self): helper.change_to_pending_acceptance(Mock()) peering_conn = self.vpc_peering_connection_waiter.wait(vpc_peering_connection, VpcPeeringConnectionWaiter.ACTIVE) self.assertEqual(peering_conn, vpc_peering_connection) self.assertEqual(peering_conn.reload.call_count, 1) def test_waiter_timeout(self): helper.change_to_pending_acceptance(Mock()) self.assertRaises(Exception, self.vpc_peering_connection_waiter.wait, vpc_peering_connection, VpcPeeringConnectionWaiter.ACTIVE) @patch('time.sleep', helper.change_to_failed) def test_waiter_throw_on_error_state(self): helper.change_to_pending_acceptance(Mock()) self.assertRaises(Exception, self.vpc_peering_connection_waiter.wait, vpc_peering_connection, VpcPeeringConnectionWaiter.ACTIVE)
def __init__(self): self.image_waiter = AMIWaiter() self.command_result_parser = CommandResultsParser() self.cancellation_service = CommandCancellationService() self.client_err_wrapper = ClientErrorWrapper() self.tag_service = TagService( client_err_wrapper=self.client_err_wrapper) self.ec2_instance_waiter = InstanceWaiter( cancellation_service=self.cancellation_service) self.instance_service = InstanceService(self.tag_service, self.ec2_instance_waiter) self.ec2_storage_service = EC2StorageService() self.model_parser = AWSModelsParser() self.cloudshell_session_helper = CloudshellDriverHelper() self.aws_session_manager = AWSSessionProvider() self.password_waiter = PasswordWaiter(self.cancellation_service) self.vm_custom_params_extractor = VmCustomParamsExtractor() self.ami_credentials_service = InstanceCredentialsService( self.password_waiter) self.security_group_service = SecurityGroupService(self.tag_service) self.subnet_waiter = SubnetWaiter() self.subnet_service = SubnetService(self.tag_service, self.subnet_waiter) self.s3_service = S3BucketService() self.vpc_peering_waiter = VpcPeeringConnectionWaiter() self.key_pair_service = KeyPairService(self.s3_service) self.vpc_waiter = VPCWaiter() self.route_tables_service = RouteTablesService(self.tag_service) self.network_interface_service = NetworkInterfaceService( subnet_service=self.subnet_service, security_group_service=self.security_group_service, ) self.elastic_ip_service = ElasticIpService() self.vm_details_provider = VmDetailsProvider() self.session_number_service = SessionNumberService() self.traffic_mirror_service = TrafficMirrorService() self.request_parser = DriverRequestParser() self.vpc_service = VPCService( tag_service=self.tag_service, subnet_service=self.subnet_service, instance_service=self.instance_service, vpc_waiter=self.vpc_waiter, vpc_peering_waiter=self.vpc_peering_waiter, sg_service=self.security_group_service, route_table_service=self.route_tables_service, traffic_mirror_service=self.traffic_mirror_service, ) self.prepare_connectivity_operation = PrepareSandboxInfraOperation( vpc_service=self.vpc_service, security_group_service=self.security_group_service, key_pair_service=self.key_pair_service, tag_service=self.tag_service, route_table_service=self.route_tables_service, cancellation_service=self.cancellation_service, subnet_service=self.subnet_service, subnet_waiter=self.subnet_waiter, ) self.deploy_ami_operation = DeployAMIOperation( instance_service=self.instance_service, ami_credential_service=self.ami_credentials_service, security_group_service=self.security_group_service, tag_service=self.tag_service, vpc_service=self.vpc_service, key_pair_service=self.key_pair_service, subnet_service=self.subnet_service, elastic_ip_service=self.elastic_ip_service, network_interface_service=self.network_interface_service, cancellation_service=self.cancellation_service, device_index_strategy=AllocateMissingValuesDeviceIndexStrategy(), vm_details_provider=self.vm_details_provider, ) self.refresh_ip_operation = RefreshIpOperation( instance_service=self.instance_service) self.power_management_operation = PowerOperation( instance_service=self.instance_service, instance_waiter=self.ec2_instance_waiter, ) self.delete_ami_operation = DeleteAMIOperation( instance_service=self.instance_service, ec2_storage_service=self.ec2_storage_service, security_group_service=self.security_group_service, tag_service=self.tag_service, elastic_ip_service=self.elastic_ip_service, ) self.clean_up_operation = CleanupSandboxInfraOperation( vpc_service=self.vpc_service, key_pair_service=self.key_pair_service, route_table_service=self.route_tables_service, traffic_mirror_service=self.traffic_mirror_service, ) self.deployed_app_ports_operation = DeployedAppPortsOperation( self.vm_custom_params_extractor, security_group_service=self.security_group_service, instance_service=self.instance_service, ) self.access_key_operation = GetAccessKeyOperation( key_pair_service=self.key_pair_service) self.set_app_security_groups_operation = SetAppSecurityGroupsOperation( instance_service=self.instance_service, tag_service=self.tag_service, security_group_service=self.security_group_service, ) self.vm_details_operation = VmDetailsOperation( instance_service=self.instance_service, vm_details_provider=self.vm_details_provider, ) self.autoload_operation = AutoloadOperation() self.snapshot_operation = SnapshotOperation(self.instance_service, self.image_waiter) self.traffic_mirroring_operation = TrafficMirrorOperation( tag_service=self.tag_service, session_number_service=self.session_number_service, traffic_mirror_service=self.traffic_mirror_service, cancellation_service=self.cancellation_service, )
def setUp(self): self.vpc_peering_connection_waiter = VpcPeeringConnectionWaiter( 1, 0.02)
def setUp(self): self.vpc_peering_connection_waiter = VpcPeeringConnectionWaiter(1, 0.02)