def test_stops_rds_instance(self, load_context, find_ec2_instances,
                             find_rds_instances, _stop):
     load_context.return_value = self.contexts[
         'project-with-rds-only--test']
     find_ec2_instances.return_value = []
     find_rds_instances.return_value = [self._rds_instance('available')]
     lifecycle.stop('project-with-rds-only--test')
Beispiel #2
0
def stop(stackname, *services):
    """Stops the nodes of 'stackname' without losing their state.

    Idempotent. Default to stopping only EC2 but additional services like 'rds' can be passed in"""
    if not services:
        services = ['ec2']

    lifecycle.stop(stackname, services)
    def test_restart_all_stopped(self):
        "multiple nodes can be restarted from a stopped state"
        lifecycle.stop(self.stackname)
        history = lifecycle.restart(self.stackname)

        # two nodes rebooting in serial, node 1 first, both stopped
        expected_history = [
            # node1, stopped -> running
            [(1, 'stopped'), (2, 'stopped')],
            [(1, 'running'), (2, 'stopped')],

            # node2, stopped -> running
            [(1, 'running'), (2, 'running')],
        ]
        self.assertEqual(expected_history, self._remove_transient_states(history))
Beispiel #4
0
    def test_create(self):
        with settings(abort_on_prompts=True):
            project = 'dummy1'
            stackname = '%s--%s' % (project, self.environment)

            cfn.ensure_destroyed(stackname)
            self.stacknames.append(stackname) # ensures stack is destroyed

            cfngen.generate_stack(project, stackname=stackname)
            bootstrap.create_stack(stackname)

            buildvars.switch_revision(stackname, 'master')
            buildvars.force(stackname, 'answer', 'forty-two')

            lifecycle.stop(stackname)
            lifecycle.start(stackname)
    def test_restart_all_stopped(self):
        "multiple nodes can be restarted from a stopped state"
        lifecycle.stop(self.stackname)
        history = lifecycle.restart(self.stackname)

        # two nodes rebooting in serial, node 1 first, both stopped
        expected_history = [
            # node1, stopped -> running
            [(1, 'stopped'), (2, 'stopped')],
            [(1, 'running'), (2, 'stopped')],

            # node2, stopped -> running
            [(1, 'running'), (2, 'running')],
        ]
        self.assertEqual(expected_history,
                         self._remove_transient_states(history))
Beispiel #6
0
    def test_create(self):
        with settings(abort_on_prompts=True):
            project = 'dummy1'
            stackname = '%s--%s' % (project, self.environment)

            cfn.ensure_destroyed(stackname)
            self.stacknames.append(stackname)

            cfngen.generate_stack(project, stackname=stackname)
            bootstrap.create_stack(stackname)

            buildvars.switch_revision(stackname, 'master')
            buildvars.force(stackname, 'answer', 'forty-two')

            lifecycle.stop(stackname)
            lifecycle.start(stackname)

            cfn.cmd(stackname,
                    "ls -l /",
                    username=BOOTSTRAP_USER,
                    concurrency='parallel')

            cfn.download_file(stackname,
                              "/bin/ls",
                              "ls",
                              use_bootstrap_user="******")
            self.assertTrue(os.path.isfile("./ls"))

            cfn.download_file(stackname,
                              "/bin/less",
                              "venv/bin/",
                              use_bootstrap_user="******")
            self.assertTrue(os.path.isfile("./venv/bin/less"))

            cfn.download_file(stackname,
                              "/bin/pwd",
                              "subfolder/pwd",
                              use_bootstrap_user="******")
            self.assertTrue(os.path.isfile("./subfolder/pwd"))
 def test_stops_rds_instance(self, load_context, find_ec2_instances, find_rds_instances, _stop):
     load_context.return_value = self.contexts['project-with-rds-only--test']
     find_ec2_instances.return_value = []
     find_rds_instances.return_value = [self._rds_instance('available')]
     lifecycle.stop('project-with-rds-only--test')
 def test_stops_ec2_instance(self, load_context, find_ec2_instances, find_rds_instances, _stop):
     load_context.return_value = self.contexts['dummy1--test']
     find_ec2_instances.return_value = [self._ec2_instance('running')]
     find_rds_instances.return_value = []
     lifecycle.stop('dummy1--test')
 def test_stops_ec2_instance(self, load_context, find_ec2_instances,
                             find_rds_instances, _stop):
     load_context.return_value = self.contexts['dummy1--test']
     find_ec2_instances.return_value = [self._ec2_instance('running')]
     find_rds_instances.return_value = []
     lifecycle.stop('dummy1--test')
Beispiel #10
0
def stop(stackname):
    "Stops the nodes of 'stackname' without losing their state. Idempotent"
    lifecycle.stop(stackname)