示例#1
0
文件: application.py 项目: wdsx/igor
def deploy_function():
    try:
        for job in JobBuilder.build_jobs(request.get_json()):
            igor.deploy(job)
    except:
        exception = sys.exc_info()[0]
        log_writer.exception("Deployment Error: %s", exception)
        abort(400)
    return "Done"
示例#2
0
文件: test_igor.py 项目: wdsx/igor
    def test_we_terminate_the_new_instances_if_the_instance_is_not_running(self, mock_ec2):
        project = {'name': 'MyProject', 'version': 'v34'}
        new_instances = ['i-232425', 'i-3434231']
        mock_ec2.is_running.return_value = False
        mock_ec2.create_and_start_instances.return_value = new_instances
        job = Job(project)

        igor.deploy(job)
        mock_ec2.terminate.assert_called_with(new_instances)
        self.assertEquals(JobStatus.failed, job.get_status())
示例#3
0
文件: test_igor.py 项目: wdsx/igor
    def test_we_deploy_an_instance_with_a_load_balancer_by_default(self, mock_loadbalancer, mock_ec2):
        project = {'name': 'MyProject', 'version': 'v34'}
        job = Job(project)
        new_instances = ['i-232425', 'i-3434231']
        mock_ec2.create_and_start_instances.return_value = new_instances
        returned_loadbalancer = LoadBalancerStub()
        mock_loadbalancer.get_loadbalancer.return_value = returned_loadbalancer
        igor.deploy(job)

        mock_ec2.create_and_start_instances.assert_called_with(project)
        mock_loadbalancer.get_loadbalancer.assert_called_with(project)
        mock_ec2.is_running.assert_called_with(new_instances, project)
        mock_loadbalancer.attach.assert_called_with(returned_loadbalancer, new_instances)
        mock_loadbalancer.dettach.assert_called_with(returned_loadbalancer, ['i-8w78921', 'i-8w78921'])
        mock_ec2.terminate.assert_called_with(['i-8w78921', 'i-8w78921'])
        self.assertEquals(JobStatus.done, job.get_status())
示例#4
0
文件: test_igor.py 项目: wdsx/igor
    def test_we_deploy_in_the_proper_order(self, mock_loadbalancer, mock_ec2):
        project = {'name': 'MyProject', 'version': 'v34', 'environment_tier': EnvironmentTier.WEB_SERVER}
        job = Job(project)
        new_instances = ['i-232425', 'i-3434231']
        mock_ec2.create_and_start_instances.return_value = new_instances
        returned_loadbalancer = LoadBalancerStub()
        mock_loadbalancer.get_loadbalancer.return_value = returned_loadbalancer
        igor.deploy(job)

        mock_ec2.create_and_start_instances.assert_called_with(project)
        mock_loadbalancer.get_loadbalancer.assert_called_with(project)
        mock_ec2.is_running.assert_called_with(new_instances, project)
        mock_loadbalancer.attach.assert_called_with(returned_loadbalancer, new_instances)
        mock_loadbalancer.dettach.assert_called_with(returned_loadbalancer, ['i-8w78921', 'i-8w78921'])
        mock_ec2.terminate.assert_called_with(['i-8w78921', 'i-8w78921'])
        self.assertEquals(JobStatus.done, job.get_status())
示例#5
0
文件: test_igor.py 项目: wdsx/igor
    def test_load_balancer_is_not_used_for_worker_projects(self, mock_loadbalancer, mock_ec2):
        project_attributes = {'name': 'MyProject', 'version': 'v34', 'environment_tier': EnvironmentTier.WORKER.value}
        job = Job(project_attributes)
        new_instances = ['i-232425', 'i-3434231']
        old_instance_ids = ['i-232425', 'i-3434231', 'i-342112', 'i-7322912']
        ids_to_terminate = ['i-342112', 'i-7322912']
        old_instances = [InstanceStub(old_instance_ids[2]), InstanceStub(old_instance_ids[3])]
        mock_ec2.is_running.return_value = True
        mock_ec2.create_and_start_instances.return_value = new_instances
        mock_ec2.get_instances.return_value = old_instances

        igor.deploy(job)

        mock_ec2.create_and_start_instances.assert_called_with(project_attributes)
        mock_loadbalancer.get_loadbalancer.assert_not_called()
        mock_ec2.terminate.assert_called_with(ids_to_terminate)
        self.assertEquals(JobStatus.done, job.get_status())