Beispiel #1
0
 def test_existing_command(self):
     test_string = 'checkbox'
     job = Job('echo -n "%s"' % test_string, '', 10)
     status, data, duration = job.execute()
     #data is expected to be bytes
     self.assertTrue(isinstance(data, bytes))
     self.assertEqual(data, test_string.encode())
Beispiel #2
0
    def message_exec(self, message):
        if "name" in message:
            logging.info(_("Executing %(test_name)s" % {
                "test_name": message["name"]}))

        if "user" not in message:

            def stop():
                os.kill(0, signal.SIGTERM)

            job = Job(message["command"], message.get("environ"),
                message.get("timeout"))

            # Kill the job if the stop event is fired during execution
            event_id = self._manager.reactor.call_on("stop", stop)
            status, data, duration = job.execute()
            self._manager.reactor.cancel_call(event_id)

            try:
                data = data.decode("utf-8")
            except UnicodeDecodeError:
                status, data, duration = (FAIL, "Decode error", 0,)

            self._manager.reactor.fire(
                "message-result", status, data, duration)
Beispiel #3
0
 def test_existing_command(self):
     test_string = 'checkbox'
     job = Job('echo -n "%s"' % test_string, '', 10)
     status, data, duration = job.execute()
     #data is expected to be bytes
     self.assertTrue(isinstance(data, bytes))
     self.assertEqual(data, test_string.encode())
Beispiel #4
0
    def message_exec(self, message):
        if "name" in message:
            logging.info(
                _("Executing %(test_name)s" % {"test_name": message["name"]}))

        if "user" not in message:

            def stop():
                os.kill(0, signal.SIGTERM)

            job = Job(message["command"], message.get("environ"),
                      message.get("timeout"))

            # Kill the job if the stop event is fired during execution
            event_id = self._manager.reactor.call_on("stop", stop)
            status, data, duration = job.execute()
            self._manager.reactor.cancel_call(event_id)

            try:
                data = data.decode("utf-8")
            except UnicodeDecodeError:
                status, data, duration = (
                    FAIL,
                    "Decode error",
                    0,
                )

            self._manager.reactor.fire("message-result", status, data,
                                       duration)
    def message_exec(self, message):
        if "user" not in message:
            def stop():
                os.kill(0, signal.SIGTERM)

            job = Job(message["command"], message.get("environ"),
                message.get("timeout"))

            # Kill the job if the stop event is fired during execution
            event_id = self._manager.reactor.call_on("stop", stop)
            result = job.execute()
            self._manager.reactor.cancel_call(event_id)

            self._manager.reactor.fire("message-result", *result)
Beispiel #6
0
 def test_command_not_found(self):
     job = Job('xwonkt', '', 10)
     status, data, duration = job.execute()
     #data is expected to be bytes
     self.assertTrue(isinstance(data, bytes))
Beispiel #7
0
 def test_command_not_found(self):
     job = Job('xwonkt', '', 10)
     status, data, duration = job.execute()
     #data is expected to be bytes
     self.assertTrue(isinstance(data, bytes))