コード例 #1
0
    def test_cli(self, mock_update, mock_add_worker):
        # Given
        cm = ClusterManager()

        # When
        cm.cli(['-a', 'host', '--home', 'home', '--nfs'])

        # Then
        mock_add_worker.assert_called_with('host', 'home', True)
コード例 #2
0
    def test_create_scheduler(self, mock_bootstrap):
        # Given
        cm = ClusterManager()
        cm.add_worker('host', home='/home/foo', nfs=False)

        # When
        s = cm.create_scheduler()

        # Then
        confs = s.worker_config
        hosts = sorted([x['host'] for x in confs])
        self.assertEqual(hosts, ['host', 'localhost'])
コード例 #3
0
    def test_add_worker(self, mock_bootstrap):
        # Given
        cm = ClusterManager()

        # When
        cm.add_worker('host', home='/home/foo', nfs=False)

        # Then
        mock_bootstrap.assert_called_with('host', '/home/foo')
        config = self._get_config()
        workers = config.get('workers')
        self.assertEqual(len(workers), 2)
        hosts = sorted(x['host'] for x in workers)
        self.assertEqual(hosts, ['host', 'localhost'])
コード例 #4
0
    def test_do_not_delete_outputs_from_hosts_when_nfs_true(
            self, mock_delete_outputs, mock_bootstrap):
        # Given
        cm = ClusterManager()
        cm.add_worker('host', home='/home/foo', nfs=True)
        cm.add_worker('host1', home='/home/foo1', nfs=True)

        # When
        cm.delete('outputs', ['host', 'host1'])

        # Then
        mock_delete_outputs.assert_not_called()
コード例 #5
0
    def test_delete_outputs_from_all_hosts(self, mock_delete_outputs,
                                           mock_bootstrap):
        # Given
        cm = ClusterManager()
        cm.add_worker('host', home='/home/foo', nfs=False)
        cm.add_worker('host1', home='/home/foo1', nfs=False)

        # When
        cm.delete('outputs', ['all'])

        # Then
        mock_delete_outputs.assert_any_call('host1', '/home/foo1', 'outputs')
        mock_delete_outputs.assert_any_call('host', '/home/foo', 'outputs')
コード例 #6
0
    def test_new_config_created_on_creation(self):
        # Given/When
        ClusterManager()

        # Then
        config = self._get_config()

        self.assertEqual(config.get('root'), 'automan')
        self.assertEqual(config.get('project_name'),
                         os.path.basename(self.root))
        self.assertEqual(os.path.realpath(config.get('sources')[0]),
                         os.path.realpath(self.root))
        workers = config.get('workers')
        self.assertEqual(len(workers), 1)
        self.assertEqual(workers[0]['host'], 'localhost')
コード例 #7
0
    def test_update(self, mock_rebuild, mock_update_sources, mock_bootstrap):
        # Given
        cm = ClusterManager()
        cm.add_worker('host', home='/home/foo', nfs=False)

        # When
        cm.update()

        # Then
        mock_update_sources.assert_called_with('host', '/home/foo')
        mock_rebuild.assert_called_with('host', '/home/foo')