Пример #1
0
    def test_attach_igw_invalid_parameters(self):
        def do_check(error_code):
            self.assert_execution_error(
                error_code, 'AttachInternetGateway',
                {'VpcId': fakes.ID_EC2_VPC_2,
                 'InternetGatewayId': fakes.ID_EC2_IGW_2})

            self.assertEqual(0, self.neutron.add_gateway_router.call_count)
            self.assertEqual(0, self.db_api.update_item.call_count)

            self.neutron.reset_mock()
            self.db_api.reset_mock()

        self.set_mock_db_items(fakes.DB_VPC_2)
        do_check('InvalidInternetGatewayID.NotFound')

        self.set_mock_db_items(fakes.DB_IGW_2)
        do_check('InvalidVpcID.NotFound')

        self.set_mock_db_items(self.DB_IGW_2_ATTACHED, fakes.DB_VPC_2)
        do_check('Resource.AlreadyAssociated')

        self.set_mock_db_items(
            fakes.DB_IGW_2, fakes.DB_VPC_2,
            fakes.gen_db_igw(fakes.ID_EC2_IGW_1, fakes.ID_EC2_VPC_2))
        do_check('InvalidParameterValue')
Пример #2
0
    def test_attach_igw_invalid_parameters(self):
        def do_check(error_code):
            self.assert_execution_error(
                error_code, 'AttachInternetGateway', {
                    'VpcId': fakes.ID_EC2_VPC_2,
                    'InternetGatewayId': fakes.ID_EC2_IGW_2
                })

            self.assertEqual(0, self.neutron.add_gateway_router.call_count)
            self.assertEqual(0, self.db_api.update_item.call_count)

            self.neutron.reset_mock()
            self.db_api.reset_mock()

        self.set_mock_db_items(fakes.DB_VPC_2)
        do_check('InvalidInternetGatewayID.NotFound')

        self.set_mock_db_items(fakes.DB_IGW_2)
        do_check('InvalidVpcID.NotFound')

        self.set_mock_db_items(self.DB_IGW_2_ATTACHED, fakes.DB_VPC_2)
        do_check('Resource.AlreadyAssociated')

        self.set_mock_db_items(
            fakes.DB_IGW_2, fakes.DB_VPC_2,
            fakes.gen_db_igw(fakes.ID_EC2_IGW_1, fakes.ID_EC2_VPC_2))
        do_check('InvalidParameterValue')
    def test_create_or_replace_route_rollback(self, routes_updater):
        self.set_mock_db_items(
            fakes.DB_ROUTE_TABLE_1, fakes.DB_ROUTE_TABLE_2, fakes.DB_VPC_1,
            fakes.DB_IGW_1,
            fakes.gen_db_igw(fakes.ID_EC2_IGW_2, fakes.ID_EC2_VPC_1))
        routes_updater.side_effect = Exception()

        with tools.ScreeningLogger(log_name='ec2api.api'):
            self.assert_execution_error(
                self.ANY_EXECUTE_ERROR, 'CreateRoute', {
                    'RouteTableId': fakes.ID_EC2_ROUTE_TABLE_1,
                    'DestinationCidrBlock': '0.0.0.0/0',
                    'GatewayId': fakes.ID_EC2_IGW_1
                })

            self.db_api.update_item.assert_any_call(mock.ANY,
                                                    fakes.DB_ROUTE_TABLE_1)

        with tools.ScreeningLogger(log_name='ec2api.api'):
            self.assert_execution_error(
                self.ANY_EXECUTE_ERROR, 'ReplaceRoute', {
                    'RouteTableId': fakes.ID_EC2_ROUTE_TABLE_2,
                    'DestinationCidrBlock': '0.0.0.0/0',
                    'GatewayId': fakes.ID_EC2_IGW_2
                })

            self.db_api.update_item.assert_any_call(mock.ANY,
                                                    fakes.DB_ROUTE_TABLE_2)
Пример #4
0
 def setUp(self):
     super(IgwTestCase, self).setUp()
     self.DB_IGW_1_DETACHED = fakes.gen_db_igw(fakes.ID_EC2_IGW_1)
     self.DB_IGW_2_ATTACHED = fakes.gen_db_igw(fakes.ID_EC2_IGW_2,
                                               fakes.ID_EC2_VPC_2)
Пример #5
0
 def setUp(self):
     super(IgwTestCase, self).setUp()
     self.DB_IGW_1_DETACHED = fakes.gen_db_igw(fakes.ID_EC2_IGW_1)
     self.DB_IGW_2_ATTACHED = fakes.gen_db_igw(fakes.ID_EC2_IGW_2,
                                               fakes.ID_EC2_VPC_2)