Ejemplo n.º 1
0
    def testWithOpts(self):
        """
        test calling createWorker() with --relocatable and --allow-shutdown
        options specified.
        """
        options = self.options.copy()
        options["relocatable"] = True
        options["allow-shutdown"] = "signal"

        # patch _make*() functions to do nothing
        self.setUpMakeFunctions()

        # call createWorker() and check that we get success exit code
        self.assertEquals(create_worker.createWorker(options), 0,
                          "unexpected exit code")

        # check _make*() functions were called with correct arguments
        options["allow-shutdown"] = "'signal'"
        expected_tac_contents = \
            "".join(create_worker.workerTACTemplate) % options
        self.assertMakeFunctionsCalls(self.options["basedir"],
                                      expected_tac_contents,
                                      options["quiet"])

        # check that correct info message was printed
        self.assertStdoutEqual("worker configured in bdir\n")
Ejemplo n.º 2
0
    def testWithOpts(self):
        """
        test calling createWorker() with --relocatable and --allow-shutdown
        options specified.
        """
        options = self.options.copy()
        options["relocatable"] = True
        options["allow-shutdown"] = "signal"

        # patch _make*() functions to do nothing
        self.setUpMakeFunctions()

        # call createWorker() and check that we get success exit code
        self.assertEquals(create_worker.createWorker(options), 0,
                          "unexpected exit code")

        # check _make*() functions were called with correct arguments
        options["allow-shutdown"] = "'signal'"
        expected_tac_contents = \
            "".join(create_worker.workerTACTemplate) % options
        self.assertMakeFunctionsCalls(self.options["basedir"],
                                      expected_tac_contents, options["quiet"])

        # check that correct info message was printed to the log
        self.assertLogged("worker configured in bdir")
Ejemplo n.º 3
0
    def testCreateError(self):
        """
        test that errors while creating worker directory are handled
        correctly by createWorker()
        """
        # patch _make*() functions to raise an exception
        self.setUpMakeFunctions(create_worker.CreateWorkerError("err-msg"))

        # call createWorker() and check that we get error exit code
        self.assertEquals(create_worker.createWorker(self.options), 1, "unexpected exit code")

        # check that correct error message was printed on stdout
        self.assertStdoutEqual("err-msg\n" "failed to configure worker in bdir\n")
Ejemplo n.º 4
0
    def testCreateError(self):
        """
        test that errors while creating worker directory are handled
        correctly by createWorker()
        """
        # patch _make*() functions to raise an exception
        self.setUpMakeFunctions(create_worker.CreateWorkerError("err-msg"))

        # call createWorker() and check that we get error exit code
        self.assertEquals(create_worker.createWorker(self.options), 1,
                          "unexpected exit code")

        # check that correct error message was printed the the log
        self.assertLogged("err-msg", "failed to configure worker in bdir")
Ejemplo n.º 5
0
    def testMinArgs(self):
        """
        test calling createWorker() with only required arguments
        """
        # patch _make*() functions to do nothing
        self.setUpMakeFunctions()

        # call createWorker() and check that we get success exit code
        self.assertEquals(create_worker.createWorker(self.options), 0, "unexpected exit code")

        # check _make*() functions were called with correct arguments
        expected_tac_contents = "".join(create_worker.workerTACTemplate) % self.options
        self.assertMakeFunctionsCalls(self.options["basedir"], expected_tac_contents, self.options["quiet"])

        # check that correct info message was printed
        self.assertStdoutEqual("worker configured in bdir\n")
Ejemplo n.º 6
0
    def testQuiet(self):
        """
        test calling createWorker() with --quiet flag
        """
        options = self.options.copy()
        options["quiet"] = True

        # patch _make*() functions to do nothing
        self.setUpMakeFunctions()

        # call createWorker() and check that we get success exit code
        self.assertEquals(create_worker.createWorker(options), 0, "unexpected exit code")

        # check _make*() functions were called with correct arguments
        expected_tac_contents = "".join(create_worker.workerTACTemplate) % options
        self.assertMakeFunctionsCalls(options["basedir"], expected_tac_contents, options["quiet"])

        # there should be no output on stdout
        self.assertWasQuiet()
Ejemplo n.º 7
0
    def testMinArgs(self):
        """
        test calling createWorker() with only required arguments
        """
        # patch _make*() functions to do nothing
        self.setUpMakeFunctions()

        # call createWorker() and check that we get success exit code
        self.assertEquals(create_worker.createWorker(self.options), 0,
                          "unexpected exit code")

        # check _make*() functions were called with correct arguments
        expected_tac_contents = \
            "".join(create_worker.workerTACTemplate) % self.options
        self.assertMakeFunctionsCalls(self.options["basedir"],
                                      expected_tac_contents,
                                      self.options["quiet"])

        # check that correct info message was printed to the log
        self.assertLogged("worker configured in bdir")
Ejemplo n.º 8
0
    def testNoLogRotate(self):
        """
        test that when --no-logrotate options is used, correct tac file
        is generated.
        """
        options = self.options.copy()
        options["no-logrotate"] = True

        # patch _make*() functions to do nothing
        self.setUpMakeFunctions()

        # call createWorker() and check that we get success exit code
        self.assertEquals(create_worker.createWorker(options), 0, "unexpected exit code")

        # check _make*() functions were called with correct arguments
        expected_tac_contents = (create_worker.workerTACTemplate[0] + create_worker.workerTACTemplate[2]) % options
        self.assertMakeFunctionsCalls(self.options["basedir"], expected_tac_contents, self.options["quiet"])

        # check that correct info message was printed
        self.assertStdoutEqual("worker configured in bdir\n")
Ejemplo n.º 9
0
    def testQuiet(self):
        """
        test calling createWorker() with --quiet flag
        """
        options = self.options.copy()
        options["quiet"] = True

        # patch _make*() functions to do nothing
        self.setUpMakeFunctions()

        # call createWorker() and check that we get success exit code
        self.assertEquals(create_worker.createWorker(options), 0,
                          "unexpected exit code")

        # check _make*() functions were called with correct arguments
        expected_tac_contents = \
            "".join(create_worker.workerTACTemplate) % options
        self.assertMakeFunctionsCalls(options["basedir"],
                                      expected_tac_contents, options["quiet"])

        # there should be no output on stdout
        self.assertWasQuiet()
    def testDeleteLeftoverDirs(self):
        """
        test calling createWorker() with --delete-leftover-dirs flag
        """
        options = self.options.copy()
        options["delete-leftover-dirs"] = True

        # patch _make*() functions to do nothing
        self.setUpMakeFunctions()

        # call createWorker() and check that we get success exit code
        self.assertEqual(create_worker.createWorker(options), 0,
                         "unexpected exit code")

        # check _make*() functions were called with correct arguments
        expected_tac_contents = ("".join(create_worker.workerTACTemplate)) % options
        self.assertMakeFunctionsCalls(self.options["basedir"],
                                      expected_tac_contents,
                                      self.options["quiet"])

        # check that correct info message was printed
        self.assertStdoutEqual("worker configured in bdir\n")
    def testUseTLS(self):
        """
        test that when --use-tls options is used, correct connection_string
        is generated
        """
        options = self.options.copy()
        options["use-tls"] = True

        # patch _make*() functions to do nothing
        self.setUpMakeFunctions()

        # call createWorker() and check that we get success exit code
        self.assertEqual(create_worker.createWorker(options), 0,
                         "unexpected exit code")

        # check _make*() functions were called with correct arguments
        expected_tac_contents = ("".join(create_worker.workerTACTemplate)) % options
        self.assertMakeFunctionsCalls(self.options["basedir"],
                                      expected_tac_contents,
                                      self.options["quiet"])

        # check that correct info message was printed
        self.assertStdoutEqual("worker configured in bdir\n")
Ejemplo n.º 12
0
    def testNoLogRotate(self):
        """
        test that when --no-logrotate options is used, correct tac file
        is generated.
        """
        options = self.options.copy()
        options["no-logrotate"] = True

        # patch _make*() functions to do nothing
        self.setUpMakeFunctions()

        # call createWorker() and check that we get success exit code
        self.assertEquals(create_worker.createWorker(options), 0,
                          "unexpected exit code")

        # check _make*() functions were called with correct arguments
        expected_tac_contents = (create_worker.workerTACTemplate[0] +
                                 create_worker.workerTACTemplate[2]) % options
        self.assertMakeFunctionsCalls(self.options["basedir"],
                                      expected_tac_contents,
                                      self.options["quiet"])

        # check that correct info message was printed to the log
        self.assertLogged("worker configured in bdir")