Пример #1
0
    def test_i_option_multi_db(self):
        """Function:  test_i_option_multi_db

        Description:  Test database with multiple database names.

        Arguments:

        """
        # Capture 2 databases/indices name in Elasticsearch.
        dbs = [
            str(y[2]) for y in
            [x.split() for x in self.els.els.cat.indices().splitlines()]
        ][0:2]

        self.args_array = {"-i": dbs}

        elastic_db_dump.initate_dump(self.els, args_array=self.args_array)

        dir_path = os.path.join(self.cfg.phy_repo_dir, self.cfg.repo_name,
                                "indices")

        # Count number of databases/indices dumped to repository.
        cnt = len([
            name for name in os.listdir(dir_path)
            if os.path.isdir(os.path.join(dir_path, name))
        ])

        self.assertEqual(cnt, 2)
Пример #2
0
    def test_initate_dump(self):
        """Function:  test_initate_dump

        Description:  Test datbase dump is created.

        Arguments:

        """

        elastic_db_dump.initate_dump(self.els, args_array=self.args_array)

        self.assertTrue(self.els.dump_list)
Пример #3
0
    def test_no_i_option(self):
        """Function:  test_no_i_option

        Description:  Test database dump with no -i option.

        Arguments:

        """

        elastic_db_dump.initate_dump(self.els, args_array=self.args_array)

        self.assertTrue(self.els.dump_list)
Пример #4
0
    def test_i_option_missing_db(self):
        """Function:  test_i_option_missing_db

        Description:  Test database with incorrect database name.

        Arguments:

        """

        self.args_array = {"-i": ["Incorrect_Database_Name"]}

        elastic_db_dump.initate_dump(self.els, args_array=self.args_array)

        # If index dump directory exists, then test is a failure.
        self.assertFalse(
            os.path.isdir(os.path.join(self.cfg.repo_dir, "indices")))
Пример #5
0
    def test_dump_status_success(self):
        """Function:  test_dump_status_success

        Description:  Test dump status set to success.

        Arguments:

        """

        self.assertFalse(
            elastic_db_dump.initate_dump(self.els, args_array=self.args_array))
Пример #6
0
    def test_err_flag_false(self):
        """Function:  test_err_flag_false

        Description:  Test error flag set to False.

        Arguments:

        """

        self.assertFalse(
            elastic_db_dump.initate_dump(self.els, args_array=self.args_array))
Пример #7
0
    def test_no_i_option(self):
        """Function:  test_no_i_option

        Description:  Test with no -i option in args_array.

        Arguments:

        """

        with gen_libs.no_std_out():
            self.assertFalse(
                elastic_db_dump.initate_dump(self.els,
                                             args_array=self.args_array))
Пример #8
0
    def test_dump_status_failed(self):
        """Function:  test_dump_status_failed

        Description:  Test dump status set to failed.

        Arguments:

        """

        self.els.dump_status = "FAILED"

        with gen_libs.no_std_out():
            self.assertFalse(
                elastic_db_dump.initate_dump(self.els,
                                             args_array=self.args_array))
Пример #9
0
    def test_dump_status_incomp(self):
        """Function:  test_dump_status_incomp

        Description:  Test dump status set to incompatible.

        Arguments:

        """

        self.els.dump_status = "INCOMPATIBLE"

        with gen_libs.no_std_out():
            self.assertFalse(
                elastic_db_dump.initate_dump(self.els,
                                             args_array=self.args_array))
Пример #10
0
    def test_dump_status_unknown(self):
        """Function:  test_dump_status_unknown

        Description:  Test dump status set to unknown.

        Arguments:

        """

        self.els.dump_status = "unknown"

        with gen_libs.no_std_out():
            self.assertFalse(
                elastic_db_dump.initate_dump(self.els,
                                             args_array=self.args_array))
Пример #11
0
    def test_err_flag_true(self):
        """Function:  test_err_flag_true

        Description:  Test error flag set to True.

        Arguments:

        """

        self.els.repo_name = None

        with gen_libs.no_std_out():
            self.assertFalse(
                elastic_db_dump.initate_dump(self.els,
                                             args_array=self.args_array))
Пример #12
0
    def test_with_option(self):
        """Function:  test_with_option

        Description:  Test with -i option in args_array.

        Arguments:

        """

        self.args_array = {"-i": ["Index1", "Index2"]}

        with gen_libs.no_std_out():
            self.assertFalse(
                elastic_db_dump.initate_dump(self.els,
                                             args_array=self.args_array))
Пример #13
0
    def test_dump_status_partial(self, mock_print):
        """Function:  test_dump_status_partial

        Description:  Test dump status set to partial.

        Arguments:

        """

        mock_print.return_value = True

        self.els.dump_status = "PARTIAL"

        with gen_libs.no_std_out():
            self.assertFalse(
                elastic_db_dump.initate_dump(self.els,
                                             args_array=self.args_array))