Exemplo n.º 1
0
    def test_startSegments(self):
        sys.argv = self.args_list
        self.subject.GpSegStart.__checkLocaleAndConnect = Mock()
        parser = self.subject.GpSegStart.createParser()
        options, args = parser.parse_args()

        gpsegstart = self.subject.GpSegStart.createProgram(options, args)
        exitCode = gpsegstart.run()

        self.assertEqual(exitCode, 0)
        for result in gpsegstart.overall_status.results:
            self.assertTrue(result.reasoncode == gp.SEGSTART_SUCCESS)
Exemplo n.º 2
0
    def test_startSegments(self):
        sys.argv = self.args_list

        parser = self.subject.GpSegStart.createParser()
        options, args = parser.parse_args()

        gpsegstart = self.subject.GpSegStart.createProgram(options, args)
        exitCode = gpsegstart.run()

        self.assertEqual(exitCode, 0)
        for result in gpsegstart.overall_status.results:
            self.assertTrue(result.reasoncode == gp.SEGSTART_SUCCESS)
Exemplo n.º 3
0
    def test_startSegments_when_checksums_mismatch(self, mock1, mock2):
        self.args_list.append("--master-checksum-version")
        self.args_list.append("0")
        sys.argv = self.args_list

        parser = self.subject.GpSegStart.createParser()
        options, args = parser.parse_args()

        gpsegstart = self.subject.GpSegStart.createProgram(options, args)
        exitCode = gpsegstart.run()

        self.assertEqual(exitCode, 1)
        for result in gpsegstart.overall_status.results:
            self.assertTrue(result.reasoncode == gp.SEGSTART_ERROR_CHECKSUM_MISMATCH)
Exemplo n.º 4
0
    def test_startSegments_when_pg_controldata_failed(self, mock1):
        self.args_list.append("--master-checksum-version")
        self.args_list.append("1")
        sys.argv = self.args_list

        parser = self.subject.GpSegStart.createParser()
        options, args = parser.parse_args()

        gpsegstart = self.subject.GpSegStart.createProgram(options, args)
        exitCode = gpsegstart.run()

        self.assertEqual(exitCode, 1)
        for result in gpsegstart.overall_status.results:
            self.assertTrue(result.reasoncode == gp.SEGSTART_ERROR_PG_CONTROLDATA_FAILED)
Exemplo n.º 5
0
    def test_startSegments_when_pg_controldata_failed(self, mock1):
        self.args_list.append("--master-checksum-version")
        self.args_list.append("1")
        sys.argv = self.args_list

        parser = self.subject.GpSegStart.createParser()
        options, args = parser.parse_args()

        gpsegstart = self.subject.GpSegStart.createProgram(options, args)
        exitCode = gpsegstart.run()

        self.assertEqual(exitCode, 1)
        for result in gpsegstart.overall_status.results:
            self.assertTrue(result.reasoncode == gp.SEGSTART_ERROR_PG_CONTROLDATA_FAILED)
Exemplo n.º 6
0
    def test_startSegments_when_checksums_mismatch(self, mock1, mock2):
        self.args_list.append("--master-checksum-version")
        self.args_list.append("0")
        sys.argv = self.args_list

        parser = self.subject.GpSegStart.createParser()
        options, args = parser.parse_args()

        gpsegstart = self.subject.GpSegStart.createProgram(options, args)
        exitCode = gpsegstart.run()

        self.assertEqual(exitCode, 1)
        for result in gpsegstart.overall_status.results:
            self.assertTrue(result.reasoncode == gp.SEGSTART_ERROR_CHECKSUM_MISMATCH)
Exemplo n.º 7
0
    def test_startSegments_when_checksums_match(self, mock1, mock2):
        self.args_list.append("--coordinator-checksum-version")
        self.args_list.append("1")
        sys.argv = self.args_list

        parser = self.subject.GpSegStart.createParser()
        options, args = parser.parse_args()

        gpsegstart = self.subject.GpSegStart.createProgram(options, args)
        exitCode = gpsegstart.run()

        self.assertEqual(exitCode, 0)
        for result in gpsegstart.overall_status.results:
            self.assertTrue(result.reasoncode == gp.SEGSTART_SUCCESS)
Exemplo n.º 8
0
    def test_startSegments_when_pg_ctl_failed(self, mock1, mock2, mock_get_results):
        self.args_list.append("--master-checksum-version")
        self.args_list.append("1")
        sys.argv = self.args_list

        mock_get_results.segment = Mock()
        mock_get_results.segment.getSegmentDataDirectory.return_value = self.failing_data_dir

        parser = self.subject.GpSegStart.createParser()
        options, args = parser.parse_args()

        gpsegstart = self.subject.GpSegStart.createProgram(options, args)
        with patch('gpsegstart.base.WorkerPool.return_value.getCompletedItems', return_value=[mock_get_results]):
            exitCode = gpsegstart.run()

        self.assertEqual(exitCode, 1)
        for result in gpsegstart.overall_status.results:
            if result.datadir == self.failing_data_dir:
                self.assertTrue(result.reasoncode == gp.SEGSTART_ERROR_PG_CTL_FAILED)
            else:
                self.assertTrue(result.reasoncode == gp.SEGSTART_SUCCESS)
Exemplo n.º 9
0
    def test_startSegments_when_pg_ctl_failed(self, mock1, mock2, mock_get_results):
        self.args_list.append("--master-checksum-version")
        self.args_list.append("1")
        sys.argv = self.args_list

        mock_get_results.segment = Mock()
        mock_get_results.segment.getSegmentDataDirectory.return_value = self.failing_data_dir

        parser = self.subject.GpSegStart.createParser()
        options, args = parser.parse_args()

        gpsegstart = self.subject.GpSegStart.createProgram(options, args)
        with patch('gpsegstart.base.WorkerPool.return_value.getCompletedItems', return_value=[mock_get_results]):
            exitCode = gpsegstart.run()

        self.assertEqual(exitCode, 1)
        for result in gpsegstart.overall_status.results:
            if result.datadir == self.failing_data_dir:
                self.assertTrue(result.reasoncode == gp.SEGSTART_ERROR_PG_CTL_FAILED)
            else:
                self.assertTrue(result.reasoncode == gp.SEGSTART_SUCCESS)