Пример #1
0
    def test_write_file(self, mock_inst, mock_disconn, mock_cmds, mock_date):
        """Function:  test_write_file

        Description:  Test option to write to file.

        Arguments:

        """

        mock_cmds.return_value = self.results
        mock_inst.return_value = self.server
        mock_disconn.return_value = True
        mock_date.return_value = self.setdate

        mongo_perf.run_program(self.args_array3,
                               self.func_dict,
                               req_arg=self.req_arg_list,
                               opt_arg=self.opt_arg_list)

        self.assertTrue(filecmp.cmp(self.outfile, self.ofile))
Пример #2
0
    def test_flatten_json(self, mock_inst, mock_disconn, mock_cmds, mock_date):
        """Function:  test_flatten_json

        Description:  Test option to flatten JSON data structure.

        Arguments:

        """

        mock_cmds.return_value = self.results
        mock_inst.return_value = self.server
        mock_disconn.return_value = True
        mock_date.return_value = self.setdate

        mongo_perf.run_program(self.args_array5,
                               self.func_dict,
                               req_arg=self.req_arg_list,
                               opt_arg=self.opt_arg_list)

        self.assertTrue(filecmp.cmp(self.outfile3, self.ofile))
Пример #3
0
    def test_run_program(self, mock_inst, mock_disconn, mock_cfg):
        """Function:  test_run_program

        Description:  Test run_program function.

        Arguments:

        """

        mock_inst.return_value = self.server
        mock_disconn.return_value = True
        mock_cfg.return_value = self.cfg

        self.assertFalse(
            mongo_perf.run_program(self.args_array3, self.func_dict))
Пример #4
0
    def test_mongo(self, mock_inst, mock_cfg, mock_disconn):
        """Function:  test_mongo

        Description:  Test with mongo option.

        Arguments:

        """

        mock_inst.return_value = self.server
        mock_cfg.side_effect = [self.cfg, True]
        mock_disconn.return_value = True

        self.assertFalse(
            mongo_perf.run_program(self.args_array, self.func_dict))
Пример #5
0
    def test_replica_set(self, mock_inst, mock_cfg, mock_disconn):
        """Function:  test_replica_set

        Description:  Test connecting to Mongo replica set.

        Arguments:

        """

        self.cfg.repset = "replicasetname"
        self.cfg.repset_hosts = self.repset_list

        mock_inst.return_value = self.server
        mock_cfg.side_effect = [self.cfg, True]
        mock_disconn.return_value = True

        self.assertFalse(
            mongo_perf.run_program(self.args_array, self.func_dict))
Пример #6
0
    def test_no_auth_mech(self, mock_inst, mock_cfg, mock_disconn):
        """Function:  test_no_auth_mech

        Description:  Test with no authorization mechanism setting.

        Arguments:

        """

        self.cfg.repset = "replicasetname"
        self.cfg.repset_hosts = self.repset_list

        mock_inst.return_value = self.server
        mock_cfg.side_effect = [self.cfg, True]
        mock_disconn.return_value = True

        self.assertFalse(
            mongo_perf.run_program(self.args_array, self.func_dict))
Пример #7
0
    def test_conn_fail_suppress(self, mock_inst, mock_cfg, mock_disconn):
        """Function:  test_conn_fail_suppress

        Description:  Test with failed connection with suppression.

        Arguments:

        """

        self.server.status = False
        self.server.err_msg = "Error Connection Message"

        mock_inst.return_value = self.server
        mock_cfg.side_effect = [self.cfg, True]
        mock_disconn.return_value = True

        self.assertFalse(
            mongo_perf.run_program(self.args_array4, self.func_dict))
Пример #8
0
    def test_no_rep_arg(self, mock_inst, mock_cfg, mock_disconn):
        """Function:  test_no_rep_arg

        Description:  Test with not passing rep_arg argument.

        Arguments:

        """

        self.cfg2.repset = "replicasetname"
        self.cfg2.repset_hosts = self.repset_list

        mock_inst.return_value = self.server
        mock_cfg.side_effect = [self.cfg2, self.cfg2]
        mock_disconn.return_value = True

        self.assertFalse(
            mongo_perf.run_program(self.args_array, self.func_dict))
Пример #9
0
    def test_default_args_array(self, mock_inst, mock_disconn, mock_popen):
        """Function:  test_default_args_array

        Description:  Test with default options.

        Arguments:

        """

        mock_inst.return_value = self.server
        mock_disconn.return_value = True
        mock_popen.return_value = self.subproc

        self.assertFalse(
            mongo_perf.run_program(self.args_array,
                                   self.func_dict,
                                   req_arg=self.req_arg_list,
                                   opt_arg=self.opt_arg_list))
Пример #10
0
    def test_json(self, mock_inst, mock_disconn, mock_cmds):
        """Function:  test_json

        Description:  Test with JSON option.

        Arguments:

        """

        mock_cmds.return_value = self.results
        mock_inst.return_value = self.server
        mock_disconn.return_value = True

        self.assertFalse(
            mongo_perf.run_program(self.args_array2,
                                   self.func_dict,
                                   req_arg=self.req_arg_list,
                                   opt_arg=self.opt_arg_list))
Пример #11
0
    def test_replica_set(self, mock_inst, mock_disconn, mock_popen):
        """Function:  test_replica_set

        Description:  Test connecting to Mongo replica set.

        Arguments:

        """

        mock_popen.return_value = self.subproc
        mock_inst.return_value = self.server
        mock_disconn.return_value = True

        self.assertFalse(
            mongo_perf.run_program(self.args_array7,
                                   self.func_dict,
                                   req_arg=self.req_arg_list,
                                   opt_arg=self.opt_arg_list))
Пример #12
0
    def test_no_suppress(self, mock_inst, mock_disconn, mock_cmds):
        """Function:  test_no_suppress

        Description:  Test with no suppression.

        Arguments:

        """

        mock_cmds.return_value = self.results
        mock_inst.return_value = self.server
        mock_disconn.return_value = True

        with gen_libs.no_std_out():
            self.assertFalse(
                mongo_perf.run_program(self.args_array8,
                                       self.func_dict,
                                       req_arg=self.req_arg_list,
                                       opt_arg=self.opt_arg_list))
Пример #13
0
    def test_mongo(self, mock_inst, mock_disconn, mock_popen, mock_cmd,
                   mock_mongo):
        """Function:  test_mongo

        Description:  Test with mongo option.

        Arguments:

        """

        mock_mongo.return_value = (True, None)
        mock_cmd.return_value = self.results
        mock_popen.return_value = self.subproc
        mock_inst.return_value = self.server
        mock_disconn.return_value = True

        self.assertFalse(
            mongo_perf.run_program(self.args_array6,
                                   self.func_dict,
                                   req_arg=self.req_arg_list,
                                   opt_arg=self.opt_arg_list))
Пример #14
0
    def test_conn_fail_suppress(self, mock_inst, mock_disconn, mock_cmds):
        """Function:  test_conn_fail_suppress

        Description:  Test with failed conn with suppression.

        Arguments:

        """

        self.server.status = False
        self.server.err_msg = "Error connection message"

        mock_cmds.return_value = self.results
        mock_inst.return_value = self.server
        mock_disconn.return_value = True

        self.assertFalse(
            mongo_perf.run_program(self.args_array2a,
                                   self.func_dict,
                                   req_arg=self.req_arg_list,
                                   opt_arg=self.opt_arg_list))
Пример #15
0
    def test_connection_fail(self, mock_inst, mock_disconn, mock_cmds):
        """Function:  test_connection_fail

        Description:  Test with failed connection to mongo.

        Arguments:

        """

        self.server.status = False
        self.server.err_msg = "Error connection message"

        mock_cmds.return_value = self.results
        mock_inst.return_value = self.server
        mock_disconn.return_value = True

        with gen_libs.no_std_out():
            self.assertFalse(
                mongo_perf.run_program(self.args_array2,
                                       self.func_dict,
                                       req_arg=self.req_arg_list,
                                       opt_arg=self.opt_arg_list))
Пример #16
0
    def test_insert_fail(self, mock_inst, mock_disconn, mock_popen, mock_cmd,
                         mock_mongo):
        """Function:  test_insert_fail

        Description:  Test with failed insert into Mongo.

        Arguments:

        """

        mock_mongo.return_value = (False, "Connection error")
        mock_cmd.return_value = self.results
        mock_popen.return_value = self.subproc
        mock_inst.return_value = self.server
        mock_disconn.return_value = True

        with gen_libs.no_std_out():
            self.assertFalse(
                mongo_perf.run_program(self.args_array6,
                                       self.func_dict,
                                       req_arg=self.req_arg_list,
                                       opt_arg=self.opt_arg_list))