Example #1
0
 def test_command_line_update_long(self):
     with mock.patch(
             'sys.argv',
             [
                 'cluster',
                 '-y',
                 'deploy',
                 '--master',
                 'master-node',
                 '--slave',
                 'slave-node',
                 '-d',
                 '-t',
                 '10',
                 'reponame',
                 'branch',
                 '--update'
             ]
     ):
         with mock.patch('cluster.cluster.Cluster.deploy') as mo:
             main()
             mo.assert_called_once_with(
                 'reponame',
                 'branch',
                 master='master-node',
                 slave='slave-node',
                 no_wait=True,
                 timeout=10,
                 ask_user=False,
                 update=True
             )
Example #2
0
    def test_command_line(self):
        node = 'node1'
        command_line_args = self.fixture_command_line(node)

        with mock.patch(*command_line_args):
            with mock.patch('cluster.cluster.Cluster.inspect_node') as mo:
                main()
                mo.assert_called_once_with(node)
Example #3
0
 def test_check_command_lines(self):
     self.fill_data()
     with OutputCapture() as output:
         with mock.patch('sys.argv', [
                 'cluster',
                 'checks',
         ]):
             main()
             output.compare("\n".join([
                 "Node node-2:",
                 " - Service Service 3:",
                 "    - Check (critical): Check Service 3",
             ]))
Example #4
0
    def test_command_line_no_update(self):
        with mock.patch('sys.argv', [
                'cluster',
                '-y',
                'migrate',
                'reponame',
                'source-branch',
                'target-branch',
                '--target-repo',
                'reponame2',
                '--no-wait',
                '-t',
                '5',
                '-n',
        ]):
            with mock.patch('cluster.cluster.Cluster.migrate') as mo:
                main()
                mo.assert_called_once_with('reponame',
                                           'source-branch',
                                           'target-branch',
                                           target_repo='reponame2',
                                           no_wait=True,
                                           timeout=5,
                                           ask_user=False,
                                           no_update=True)

        with mock.patch('sys.argv', [
                'cluster',
                '-y',
                'migrate',
                'reponame',
                'source-branch',
                'target-branch',
                '--target-repo',
                'reponame2',
                '--no-wait',
                '-t',
                '5',
                '--no-update',
        ]):
            with mock.patch('cluster.cluster.Cluster.migrate') as mo:
                main()
                mo.assert_called_once_with('reponame',
                                           'source-branch',
                                           'target-branch',
                                           target_repo='reponame2',
                                           no_wait=True,
                                           timeout=5,
                                           ask_user=False,
                                           no_update=True)
Example #5
0
    def test_command_output_empty_node(self):
        node = 'node5'
        command_line_args = self.fixture_command_line(node)

        self.mocked_consul.configure_mock(
            **{
                'kv.find': lambda state: self._app_kv,
            })

        with OutputCapture() as output:
            with mock.patch(*command_line_args):
                main()
                output.compare("\n".join([
                    "Master apps of node {node}:".format(node=node),
                ]))
Example #6
0
 def test_command_line(self):
     with mock.patch(
             'sys.argv',
             ['cluster', 'deploy', 'reponame', 'branch', ]
     ):
         with mock.patch('cluster.cluster.Cluster.deploy') as mo:
             main()
             mo.assert_called_once_with(
                 'reponame',
                 'branch',
                 master=None,
                 slave=None,
                 no_wait=False,
                 timeout=cluster.DEFAULT_TIMEOUT,
                 ask_user=True,
                 update=False
             )
 def test_command_line(self):
     with mock.patch('sys.argv', [
             'cluster',
             '-y',
             'move-masters-from',
             'node-1',
             '--master',
             'node-2',
             '--no-wait',
             '-t',
             '5',
     ]):
         with mock.patch('cluster.cluster.Cluster.move_masters_from') as mo:
             main()
             mo.assert_called_once_with('node-1',
                                        master='node-2',
                                        no_wait=True,
                                        timeout=5,
                                        ask_user=False)