Esempio n. 1
0
    def test_host_option_segment_down_is_skipped_succeeds(self):
        sys.argv = ["gpstop", "-a", "--host", "sdw1"]
        parser = self.subject.GpStop.createParser()
        options, args = parser.parse_args()

        self.primary0 = Segment.initFromString(
            "2|0|m|p|s|d|sdw1|sdw1|40000|/data/primary0")
        self.mirror0 = Segment.initFromString(
            "6|0|p|m|c|u|sdw2|sdw2|50000|/data/mirror0")
        self.mock_gparray.return_value = GpArray([
            self.master, self.primary0, self.primary1, self.primary2,
            self.primary3, self.mirror0, self.mirror1, self.mirror2,
            self.mirror3
        ])

        gpstop = self.subject.GpStop.createProgram(options, args)
        gpstop.run()
        log_messages = self.get_info_messages()

        self.assertEquals(2, self.mock_GpSegStopCmdInit.call_count)
        self.assertIn(
            "Targeting dbid %s for shutdown" % [
                self.primary1.getSegmentDbId(),
                self.mirror2.getSegmentDbId(),
                self.mirror3.getSegmentDbId()
            ], log_messages)
        self.assertIn("Successfully shutdown 3 of 8 segment instances ",
                      log_messages)
Esempio n. 2
0
    def createGpArrayWith4Primary4Mirrors(self):
        self.master = Segment.initFromString(
            "1|-1|p|p|s|u|mdw|mdw|5432|/data/master")

        self.primary0 = Segment.initFromString(
            "2|0|p|p|s|u|sdw1|sdw1|40000|/data/primary0")
        self.primary1 = Segment.initFromString(
            "3|1|p|p|s|u|sdw1|sdw1|40001|/data/primary1")
        self.primary2 = Segment.initFromString(
            "4|2|p|p|s|u|sdw2|sdw2|40002|/data/primary2")
        self.primary3 = Segment.initFromString(
            "5|3|p|p|s|u|sdw2|sdw2|40003|/data/primary3")

        self.mirror0 = Segment.initFromString(
            "6|0|m|m|s|u|sdw2|sdw2|50000|/data/mirror0")
        self.mirror1 = Segment.initFromString(
            "7|1|m|m|s|u|sdw2|sdw2|50001|/data/mirror1")
        self.mirror2 = Segment.initFromString(
            "8|2|m|m|s|u|sdw1|sdw1|50002|/data/mirror2")
        self.mirror3 = Segment.initFromString(
            "9|3|m|m|s|u|sdw1|sdw1|50003|/data/mirror3")
        return GpArray([
            self.master, self.primary0, self.primary1, self.primary2,
            self.primary3, self.mirror0, self.mirror1, self.mirror2,
            self.mirror3
        ])
Esempio n. 3
0
 def _create_gparray_with_2_primary_2_mirrors():
     master = Segment.initFromString(
         "1|-1|p|p|s|u|mdw|mdw|5432|/data/master")
     primary0 = Segment.initFromString(
         "2|0|p|p|s|u|sdw1|sdw1|40000|/data/primary0")
     primary1 = Segment.initFromString(
         "3|1|p|p|s|u|sdw2|sdw2|40001|/data/primary1")
     mirror0 = Segment.initFromString(
         "4|0|m|m|s|u|sdw2|sdw2|50000|/data/mirror0")
     mirror1 = Segment.initFromString(
         "5|1|m|m|s|u|sdw1|sdw1|50001|/data/mirror1")
     return GpArray([master, primary0, primary1, mirror0, mirror1])
Esempio n. 4
0
 def createGpArrayWith2Primary2Mirrors(self):
     master = Segment.initFromString(
         "1|-1|p|p|s|u|mdw|mdw|5432|/data/master")
     primary0 = Segment.initFromString(
         "2|0|p|p|s|u|sdw1|sdw1|40000|/data/primary0")
     primary1 = Segment.initFromString(
         "3|1|p|p|s|u|sdw2|sdw2|40001|/data/primary1")
     mirror0 = Segment.initFromString(
         "4|0|m|m|s|u|sdw2|sdw2|50000|/data/mirror0")
     mirror1 = Segment.initFromString(
         "5|1|m|m|s|u|sdw1|sdw1|50001|/data/mirror1")
     return GpArray([master, primary0, primary1, mirror0, mirror1])
Esempio n. 5
0
 def createGpArrayWith2Primary2Mirrors(self):
     self.master = Segment.initFromString(
         "1|-1|p|p|s|u|mdw|mdw|5432|/data/master")
     self.primary0 = Segment.initFromString(
         "2|0|p|p|s|u|aspen|sdw1|40000|/Users/pivotal/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1")
     self.primary1 = Segment.initFromString(
         "3|1|p|p|s|u|sdw2|sdw2|40001|/data/primary1")
     self.mirror0 = Segment.initFromString(
         "4|0|m|m|s|u|sdw2|sdw2|50000|/data/mirror0")
     self.mirror1 = Segment.initFromString(
         "5|1|m|m|s|u|sdw1|sdw1|50001|/data/mirror1")
     return GpArray([self.master, self.primary0, self.primary1, self.mirror0, self.mirror1])
Esempio n. 6
0
 def createGpArrayWith2Primary2Mirrors(self):
     self.master = Segment.initFromString(
         "1|-1|p|p|s|u|mdw|mdw|5432|/data/master")
     self.primary0 = Segment.initFromString(
         "2|0|p|p|s|u|aspen|sdw1|40000|/Users/pivotal/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1")
     self.primary1 = Segment.initFromString(
         "3|1|p|p|s|u|sdw2|sdw2|40001|/data/primary1")
     self.mirror0 = Segment.initFromString(
         "4|0|m|m|s|u|sdw2|sdw2|50000|/data/mirror0")
     self.mirror1 = Segment.initFromString(
         "5|1|m|m|s|u|sdw1|sdw1|50001|/data/mirror1")
     return GpArray([self.master, self.primary0, self.primary1, self.mirror0, self.mirror1])
 def _create_gparray_with_2_primary_2_mirrors():
     master = Segment.initFromString(
         "1|-1|p|p|s|u|mdw|mdw|5432|/data/master")
     primary0 = Segment.initFromString(
         "2|0|p|p|s|u|sdw1|sdw1|40000|/data/primary0")
     primary1 = Segment.initFromString(
         "3|1|p|p|s|u|sdw2|sdw2|40001|/data/primary1")
     mirror0 = Segment.initFromString(
         "4|0|m|m|s|u|sdw2|sdw2|50000|/data/mirror0")
     mirror1 = Segment.initFromString(
         "5|1|m|m|s|u|sdw1|sdw1|50001|/data/mirror1")
     return GpArray([master, primary0, primary1, mirror0, mirror1])
Esempio n. 8
0
    def test_host_option_if_master_running_on_the_host_fails(self):
        sys.argv = ["gpstop", "-a", "--host", "mdw"]
        parser = self.subject.GpStop.createParser()
        options, args = parser.parse_args()

        self.master = Segment.initFromString(
            "1|-1|p|p|s|u|mdw|mdw|5432|/data/master")
        self.primary0 = Segment.initFromString(
            "2|0|p|p|s|u|sdw1|sdw1|40000|/data/primary0")
        self.mirror0 = Segment.initFromString(
            "3|0|m|m|s|u|sdw1|sdw1|50000|/data/mirror0")
        self.mock_gparray.return_value = GpArray([self.master, self.primary0, self.mirror0])

        gpstop = self.subject.GpStop.createProgram(options, args)

        with self.assertRaisesRegexp(Exception,"Specified host '%s' has the master or standby master on it. This node can only be stopped as part of a full-cluster gpstop, without '--host'." %
                                     self.master.getSegmentHostName()):
            gpstop.run()
        self.assertEquals(0, self.mock_GpSegStopCmdInit.call_count)
Esempio n. 9
0
    def test_host_option_segment_on_same_host_with_mirror_fails(self):
        sys.argv = ["gpstop", "-a", "--host", "sdw1"]
        parser = self.subject.GpStop.createParser()
        options, args = parser.parse_args()

        self.master = Segment.initFromString(
            "1|-1|p|p|s|u|mdw|mdw|5432|/data/master")

        self.primary0 = Segment.initFromString(
            "2|0|p|p|s|u|sdw1|sdw1|40000|/data/primary0")
        self.mirror0 = Segment.initFromString(
            "3|0|m|m|s|u|sdw1|sdw1|50000|/data/mirror0")
        self.mock_gparray.return_value = GpArray([self.master, self.primary0, self.mirror0])

        gpstop = self.subject.GpStop.createProgram(options, args)

        with self.assertRaisesRegexp(Exception,"Segment host '%s' has both of corresponding primary '%s' and mirror '%s'. Aborting." % (self.primary0.getSegmentHostName(), self.primary0, self.mirror0)):
            gpstop.run()
        self.assertEquals(0, self.mock_GpSegStopCmdInit.call_count)
Esempio n. 10
0
    def test_host_option_segment_in_resynchronizing_mode_fails(self):
        sys.argv = ["gpstop", "-a", "--host", "sdw1"]
        parser = self.subject.GpStop.createParser()
        options, args = parser.parse_args()

        self.primary0 = Segment.initFromString(
            "2|0|p|p|r|u|sdw1|sdw1|40000|/data/primary0")
        self.mirror0 = Segment.initFromString(
            "6|0|m|m|r|u|sdw2|sdw2|50000|/data/mirror0")
        self.mock_gparray.return_value = GpArray([self.master, self.primary0,
                                                  self.primary1, self.primary2,
                                                  self.primary3, self.mirror0,
                                                  self.mirror1, self.mirror2,
                                                  self.mirror3])

        gpstop = self.subject.GpStop.createProgram(options, args)

        with self.assertRaisesRegexp(Exception,"Segment '%s' not synchronized. Aborting." % self.primary0):
            gpstop.run()
        self.assertEquals(0, self.mock_GpSegStopCmdInit.call_count)
Esempio n. 11
0
    def test_host_option_if_no_mirrors_fails(self):
        sys.argv = ["gpstop", "-a", "--host", "sdw2"]
        parser = self.subject.GpStop.createParser()
        options, args = parser.parse_args()

        self.master = Segment.initFromString(
            "1|-1|p|p|s|u|mdw|mdw|5432|/data/master")
        self.standby = Segment.initFromString(
            "2|-1|m|m|s|u|sdw1|sdw1|25432|/data/master")
        self.primary0 = Segment.initFromString(
            "3|0|p|p|s|u|sdw1|sdw1|40000|/data/primary0")
        self.primary1 = Segment.initFromString(
            "4|0|p|p|s|u|sdw2|sdw2|40001|/data/primary1")
        self.mock_gparray.return_value = GpArray([self.master, self.standby, self.primary0, self.primary1])

        gpstop = self.subject.GpStop.createProgram(options, args)

        with self.assertRaisesRegexp(Exception,"Cannot perform host-specific gpstop on a cluster without segment mirroring."):
            gpstop.run()
        self.assertEquals(0, self.mock_GpSegStopCmdInit.call_count)
Esempio n. 12
0
    def test_prepare_segment_start_returns_up_and_down_segments(self):
        # Boilerplate: create a gpstart object
        parser = self.subject.GpStart.createParser()
        options, args = parser.parse_args([])
        gpstart = self.subject.GpStart.createProgram(options, args)

        # Up segments
        master = Segment.initFromString(
            "1|-1|p|p|n|u|mdw|mdw|5432|/data/master")
        primary1 = Segment.initFromString(
            "3|1|p|p|n|u|sdw2|sdw2|40001|/data/primary1")
        mirror0 = Segment.initFromString(
            "4|0|m|m|n|u|sdw2|sdw2|50000|/data/mirror0")

        # Down segments
        primary0 = Segment.initFromString(
            "2|0|p|p|n|d|sdw1|sdw1|40000|/data/primary0")
        mirror1 = Segment.initFromString(
            "5|1|m|m|n|d|sdw1|sdw1|50001|/data/mirror1")
        standby = Segment.initFromString(
            "6|-1|m|m|n|d|sdw3|sdw3|5433|/data/standby")

        gpstart.gparray = GpArray(
            [master, primary0, primary1, mirror0, mirror1, standby])

        up, down = gpstart._prepare_segment_start()

        # The master and standby should not be accounted for in these lists.
        self.assertItemsEqual(up, [primary1, mirror0])
        self.assertItemsEqual(down, [primary0, mirror1])
Esempio n. 13
0
 def _createGpArrayWith2Primary2Mirrors(self):
     self.master = Segment.initFromString(
         "1|-1|p|p|s|u|mdw|mdw|5432|/data/master")
     self.primary0 = Segment.initFromString(
         "2|0|p|p|s|u|sdw1|sdw1|40000|/data/primary0")
     self.primary1 = Segment.initFromString(
         "3|1|p|p|s|u|sdw2|sdw2|40001|/data/primary1")
     self.mirror0 = Segment.initFromString(
         "4|0|m|m|s|u|sdw2|sdw2|50000|/data/mirror0")
     self.mirror1 = Segment.initFromString(
         "5|1|m|m|s|u|sdw1|sdw1|50001|/data/mirror1")
     self.standby = Segment.initFromString(
         "6|-1|m|m|s|u|sdw3|sdw3|5433|/data/standby")
     return GpArray([self.master, self.primary0, self.primary1, self.mirror0, self.mirror1])
Esempio n. 14
0
 def createGpArrayWith2Primary2Mirrors(self):
     coordinator = Segment.initFromString(
         "1|-1|p|p|s|u|cdw|cdw|5432|/data/coordinator")
     self.primary0 = Segment.initFromString(
         "2|0|p|p|s|u|aspen|sdw1|40000|/Users/pivotal/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1")
     primary1 = Segment.initFromString(
         "3|1|p|p|s|u|sdw2|sdw2|40001|/data/primary1")
     mirror0 = Segment.initFromString(
         "4|0|m|m|s|u|sdw2|sdw2|50000|/data/mirror0")
     mirror1 = Segment.initFromString(
         "5|1|m|m|s|u|sdw1|sdw1|50001|/data/mirror1")
     standby_coordinator = Segment.initFromString(
         "6|-1|m|m|s|u|cdw_standby|cdw_standby|25432|/data/standby_coordinator")
     return GpArray([coordinator, self.primary0, primary1, mirror0, mirror1, standby_coordinator])
Esempio n. 15
0
 def _createGpArrayWith2Primary2Mirrors(self):
     self.master = Segment.initFromString(
         "1|-1|p|p|s|u|mdw|mdw|5432|/data/master")
     self.primary0 = Segment.initFromString(
         "2|0|p|p|s|u|sdw1|sdw1|40000|/data/primary0")
     self.primary1 = Segment.initFromString(
         "3|1|p|p|s|u|sdw2|sdw2|40001|/data/primary1")
     self.mirror0 = Segment.initFromString(
         "4|0|m|m|s|u|sdw2|sdw2|50000|/data/mirror0")
     self.mirror1 = Segment.initFromString(
         "5|1|m|m|s|u|sdw1|sdw1|50001|/data/mirror1")
     self.standby = Segment.initFromString(
         "6|-1|m|m|s|u|sdw3|sdw3|5433|/data/standby")
     return GpArray([self.master, self.primary0, self.primary1, self.mirror0, self.mirror1])
Esempio n. 16
0
    def test_stop_standby_option(self, mock):
        self.standby = Segment.initFromString(
            "10|-1|m|m|s|u|smdw|smdw|5432|/data/standby_master")
        self.gparray = GpArray([
            self.master, self.primary0, self.primary1, self.primary2,
            self.primary3, self.mirror0, self.mirror1, self.mirror2,
            self.mirror3, self.standby
        ])
        self.mock_gparray.return_value = self.gparray

        sys.argv = ["gpstop", "-a", "-y"]
        parser = self.subject.GpStop.createParser()
        options, args = parser.parse_args()

        gpstop = self.subject.GpStop.createProgram(options, args)
        gpstop.run()
        assert not mock.called
        log_message = self.get_info_messages()
        self.assertTrue(
            "Stopping master standby host smdw mode=fast" not in log_message)
        self.assertTrue("No standby master host configured" not in log_message)
 def _triplet(failed, live, failover, failed_unreachable=False):
     failedSeg = Segment.initFromString(failed)
     failedSeg.unreachable = failed_unreachable
     return RecoveryTriplet(
         failedSeg, Segment.initFromString(live),
         Segment.initFromString(failover) if failover else None)
Esempio n. 18
0
 def _triplet(failed, live, failover):
     return RecoverTriplet(
         Segment.initFromString(failed), Segment.initFromString(live),
         Segment.initFromString(failover) if failover else None)