コード例 #1
0
    def test_command_for_two_clusters_and_node0_is_not_running(
            self, instances):
        self.mock_node0.start_node.return_value = 'mock-descriptor'
        self.mock_node3.start_node.return_value = 'mock-3-descriptor'

        real_command = subject.command()

        real_command.run_for('3')

        self.mock_node0.start_node.assert_called_with()
        self.mock_node1.start_node.assert_called_with('mock-descriptor')
        self.mock_node2.start_node.assert_called_with('mock-descriptor')
        self.mock_node3.start_node.assert_called_with('mock-descriptor')
        self.mock_node4.start_node.assert_not_called()

        self.mock_node0.reset_mock()
        self.mock_node3.reset_mock()
        self.mock_node0.node.descriptor = 'mock-descriptor'
        set_descriptor(self.mock_node1, 'mock-1-descriptor')
        set_descriptor(self.mock_node2, 'mock-2-descriptor')
        set_descriptor(self.mock_node3, 'mock-3-descriptor')

        real_command.run_for('3')

        self.mock_node0.start_node.assert_not_called()
        self.mock_node3.start_node.assert_not_called()
        self.mock_node4.start_node.assert_called_with('mock-3-descriptor')
        self.mock_node5.start_node.assert_called_with('mock-3-descriptor')
        self.mock_node6.start_node.assert_called_with('mock-3-descriptor')
        self.mock_node7.start_node.assert_not_called()
コード例 #2
0
    def test_command_with_bad_count(self, mocker, printing, instances):
        real_command = subject.command()

        real_command.run_for('bad')

        assert self.mock_print.mock_calls == [
            mocker.call('FAILED TO START cluster: bad is not an integer')
        ]
コード例 #3
0
    def test_command_for_three_nodes_and_node0_is_not_running(self, instances):
        self.mock_node0.start_node.return_value = 'descriptor'

        real_command = subject.command()

        real_command.run_for('3')

        self.mock_node0.start_node.assert_called_with()
        self.mock_node1.start_node.assert_called_with('descriptor')
        self.mock_node2.start_node.assert_called_with('descriptor')
        self.mock_node3.start_node.assert_called_with('descriptor')
        self.mock_node4.start_node.assert_not_called()
コード例 #4
0
    def test_command_for_three_nodes_and_node0_is_already_running(
            self, instances):
        self.mock_node0.node.descriptor = 'node-0-descriptor'

        real_command = subject.command()

        real_command.run_for('3')

        self.mock_node0.start_node.assert_not_called()
        self.mock_node1.start_node.assert_called_with('node-0-descriptor')
        self.mock_node2.start_node.assert_called_with('node-0-descriptor')
        self.mock_node3.start_node.assert_called_with('node-0-descriptor')
        self.mock_node4.start_node.assert_not_called()
コード例 #5
0
    ),
    'stop':
    SelectCommand('stop', lambda instance: instance.stop_node(),
                  "reverts and stops MASQNode on"),
    finish.name():
    finish.command(),  # always "all"
    'shell':
    SelectCommand('shell', lambda instance: instance.shell(),
                  "opens shell(s) on node instance in terminal window"),
    kill.name():
    kill.command(),
    nfo.name():
    nfo.command(),
    help.name():
    help.command(),
    daisy.name():
    daisy.command(),
    cluster.name():
    cluster.command(),
    'set':
    SetCommand(),
    'binaries':
    binaries_command.BinariesCommand(),

    # TODO status command (finds out which instances are running (checks all platforms), for running instances, determines if node is running on them, if they are subverted, etc)
    # it should not load this state into INSTANCES automatically (multiple pairs could be using different cloud instances, so this should enable coordination)
    # status could prompt for which ones we want to claim for this run of TNT, and load only those into INSTANCES.

    # TODO help command with more detailed command info
}
コード例 #6
0
    def test_command(self):
        real_command = subject.command()

        assert real_command.name == 'cluster'
        assert real_command.info == 'Starts the specified number of nodes all with the same neighbor'