Exemple #1
0
    def test_continuous_event_with_result(self):
        gemini_stress_event = GeminiStressEvent(node="node",
                                                cmd="cat",
                                                publish_event=False)
        begin_event_timestamp = 1623596860.1202102
        gemini_stress_event.event_id = "14f35b64-2fcc-4b6e-a09d-4aeaf4faa543"
        begin_event = gemini_stress_event.begin_event()
        begin_event.event_timestamp = begin_event.begin_timestamp = begin_event_timestamp
        self.assertEqual(
            str(begin_event),
            '(GeminiStressEvent Severity.NORMAL) period_type=begin '
            'event_id=14f35b64-2fcc-4b6e-a09d-4aeaf4faa543: node=node gemini_cmd=cat'
        )
        self.assertEqual(begin_event.event_timestamp, begin_event_timestamp)
        self.assertEqual(begin_event.timestamp, begin_event_timestamp)
        self.assertEqual(begin_event, pickle.loads(pickle.dumps(begin_event)))

        gemini_stress_event.add_result(
            result=Result(stdout="  \n\nline1\n  line2  \nline3\n  ",
                          stderr="\terr\t",
                          exited=1))

        result = "Exit code: 1\nCommand output: ['  line2  ', 'line3']\n"
        gemini_stress_event.end_event()
        gemini_stress_event.event_timestamp = gemini_stress_event.end_timestamp = 1623599860.1202102
        self.assertEqual(gemini_stress_event.result, result)
        self.assertEqual(
            str(gemini_stress_event),
            '(GeminiStressEvent Severity.NORMAL) period_type=end '
            'event_id=14f35b64-2fcc-4b6e-a09d-4aeaf4faa543 duration=50m0s: node=node gemini_cmd=cat\n'
            'result=Exit code: 1\nCommand output: [\'  line2  \', \'line3\']\n\n'
            'errors=[\'Command error: \\terr\\t\\n\']')

        self.assertEqual(gemini_stress_event,
                         pickle.loads(pickle.dumps(gemini_stress_event)))
Exemple #2
0
    def test_continuous_event_without_result(self):
        gemini_stress_event = GeminiStressEvent(node="node",
                                                cmd="cat",
                                                publish_event=False)
        begin_event_timestamp = 1623596860.1202102
        gemini_stress_event.event_id = "14f35b64-2fcc-4b6e-a09d-4aeaf4faa543"
        begin_event = gemini_stress_event.begin_event()
        begin_event.event_timestamp = begin_event.begin_timestamp = begin_event_timestamp
        self.assertEqual(
            str(begin_event),
            '(GeminiStressEvent Severity.NORMAL) period_type=begin '
            'event_id=14f35b64-2fcc-4b6e-a09d-4aeaf4faa543: node=node gemini_cmd=cat'
        )
        self.assertEqual(begin_event.event_timestamp, begin_event_timestamp)
        self.assertEqual(begin_event.timestamp, begin_event_timestamp)
        self.assertEqual(begin_event, pickle.loads(pickle.dumps(begin_event)))

        gemini_stress_event.end_event()
        gemini_stress_event.event_timestamp = gemini_stress_event.end_timestamp = 1623696860.1202102
        self.assertEqual(gemini_stress_event.result, '')
        self.assertEqual(
            str(gemini_stress_event),
            '(GeminiStressEvent Severity.NORMAL) period_type=end '
            'event_id=14f35b64-2fcc-4b6e-a09d-4aeaf4faa543 duration=1d3h46m40s: node=node gemini_cmd=cat'
        )

        self.assertEqual(gemini_stress_event,
                         pickle.loads(pickle.dumps(gemini_stress_event)))
Exemple #3
0
    def test_continuous_event_with_error(self):
        gemini_stress_event = GeminiStressEvent(node="node",
                                                cmd="gemini_cmd",
                                                publish_event=False)
        begin_event_timestamp = 1623596860.1202102
        gemini_stress_event.event_id = "14f35b64-2fcc-4b6e-a09d-4aeaf4faa543"
        begin_event = gemini_stress_event.begin_event()
        begin_event.event_timestamp = begin_event.begin_timestamp = begin_event_timestamp
        self.assertEqual(
            str(begin_event),
            '(GeminiStressEvent Severity.NORMAL) period_type=begin '
            'event_id=14f35b64-2fcc-4b6e-a09d-4aeaf4faa543: node=node gemini_cmd=gemini_cmd'
        )
        self.assertEqual(begin_event.event_timestamp, begin_event_timestamp)
        self.assertEqual(begin_event.timestamp, begin_event_timestamp)
        self.assertEqual(begin_event,
                         pickle.loads(pickle.dumps(gemini_stress_event)))

        gemini_stress_event.add_error(errors=["error1", "error2"])
        gemini_stress_event.severity = Severity.ERROR

        gemini_stress_event.end_event()
        gemini_stress_event.event_timestamp = gemini_stress_event.end_timestamp = 1623597850.6610544
        self.assertEqual(
            str(gemini_stress_event),
            '(GeminiStressEvent Severity.ERROR) period_type=end '
            'event_id=14f35b64-2fcc-4b6e-a09d-4aeaf4faa543 duration=16m30s: node=node gemini_cmd=gemini_cmd'
            '\nerrors=[\'error1\', \'error2\']')
        self.assertEqual(gemini_stress_event,
                         pickle.loads(pickle.dumps(gemini_stress_event)))