Пример #1
0
    def test__execute_succeeds_when_local_and_remote_match(self):
        self.check_dir_mock.return_value.run.return_value = False
        self.check_remote_dir_mock.return_value.run.return_value = False
        self.make_dir_mock.return_value.run.return_value = None
        self.mock_listdir.return_value = ['synced.gppkg']
        self.mock_command.return_value.get_results.return_value.stdout = pickle.dumps(['synced.gppkg'])

        subject = SyncPackages('localhost')
        subject.execute()
        self.assertEqual(self.make_dir_mock.call_count, 1)
        self.assertEqual(self.make_remote_dir_mock.call_count, 1)

        log_messages = [args[1][0] for args in self.mock_logger.method_calls]
        self.assertIn('The packages on localhost are consistent.', log_messages)
Пример #2
0
    def test__execute_install_on_segments_when_package_are_missing(self):
        self.check_dir_mock.return_value.run.return_value = False
        self.check_remote_dir_mock.return_value.run.return_value = False
        self.make_dir_mock.return_value.run.return_value = None
        self.mock_listdir.return_value = ['foo.gppkg', 'bar.gppkg', 'zing.gppkg']
        self.mock_command.return_value.get_results.return_value.stdout = pickle.dumps(['foo.gppkg'])

        hostname = 'localhost'
        subject = SyncPackages(hostname)
        subject.execute()
        self.assertEqual(self.mock_scp.call_count, 2)
        self.assertEqual(self.make_dir_mock.call_count, 1)
        self.assertEqual(self.make_remote_dir_mock.call_count, 1)

        log_messages = [args[1][0] for args in self.mock_logger.method_calls]
        self.assertNotIn('The packages on %s are consistent.' % hostname, log_messages)
Пример #3
0
    def test__execute_succeeds_when_local_and_remote_match(self):
        self.check_dir_mock.return_value.run.return_value = False
        self.check_remote_dir_mock.return_value.run.return_value = False
        self.make_dir_mock.return_value.run.return_value = None
        self.mock_listdir.return_value = ['synced.gppkg']
        self.mock_command.return_value.get_results.return_value.stdout = pickle.dumps(
            ['synced.gppkg'])

        subject = SyncPackages('localhost')
        subject.execute()
        self.assertEqual(self.make_dir_mock.call_count, 1)
        self.assertEqual(self.make_remote_dir_mock.call_count, 1)

        log_messages = [args[1][0] for args in self.mock_logger.method_calls]
        self.assertIn('The packages on localhost are consistent.',
                      log_messages)
Пример #4
0
    def test__execute_uninstall_on_segments_when_package_is_missing_on_master(
            self):
        self.check_dir_mock.return_value.run.return_value = False
        self.check_remote_dir_mock.return_value.run.return_value = False
        self.make_dir_mock.return_value.run.return_value = None
        self.mock_listdir.return_value = ['ba.gppkg']
        self.mock_command.return_value.get_results.return_value.stdout = pickle.dumps(
            ['ba.gppkg', 'zing.gppkg', 'ga.gppkg'])
        hostname = 'localhost'
        subject = SyncPackages(hostname)
        subject.execute()
        self.assertEqual(self.make_dir_mock.call_count, 1)
        self.assertEqual(self.make_remote_dir_mock.call_count, 1)

        log_messages = [args[1][0] for args in self.mock_logger.method_calls]
        self.assertIn(
            'The following packages will be uninstalled on localhost: zing.gppkg, ga.gppkg',
            log_messages)
        self.assertNotIn('The packages on %s are consistent.' % hostname,
                         log_messages)
Пример #5
0
 def syncPackages(self, new_hosts):
     # The design decision here is to squash any exceptions resulting from the
     # synchronization of packages. We should *not* disturb the user's attempts to recover.
     try:
         self.logger.info('Syncing Greenplum Database extensions')
         operations = [SyncPackages(host) for host in new_hosts]
         ParallelOperation(operations, self.__options.parallelDegree).run()
         # introspect outcomes
         for operation in operations:
             operation.get_ret()
     except:
         self.logger.exception('Syncing of Greenplum Database extensions has failed.')
         self.logger.warning('Please run gppkg --clean after successful segment recovery.')