コード例 #1
0
    def test_continuous_event_without_errors(self):
        begin_event_timestamp = 1623596860.1202102
        cs_event = CassandraStressEvent(node="node",
                                        stress_cmd="stress_cmd",
                                        log_file_name="log_file_name",
                                        publish_event=False)
        cs_event.event_id = "14f35b64-2fcc-4b6e-a09d-4aeaf4faa543"
        begin_event = cs_event.begin_event()
        begin_event.event_timestamp = begin_event.begin_timestamp = begin_event_timestamp
        self.assertEqual(
            str(begin_event),
            "(CassandraStressEvent Severity.NORMAL) period_type=begin "
            "event_id=14f35b64-2fcc-4b6e-a09d-4aeaf4faa543: node=node\nstress_cmd=stress_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(begin_event)))

        end_event_timestamp = 1623596870.1202102
        cs_event.end_event()
        cs_event.event_timestamp = cs_event.end_timestamp = end_event_timestamp
        self.assertEqual(
            str(cs_event),
            "(CassandraStressEvent Severity.NORMAL) period_type=end "
            "event_id=14f35b64-2fcc-4b6e-a09d-4aeaf4faa543 duration=10s: node=node\n"
            "stress_cmd=stress_cmd")
        self.assertEqual(cs_event.event_timestamp, end_event_timestamp)
        self.assertEqual(cs_event.timestamp, end_event_timestamp)
        self.assertEqual(cs_event, pickle.loads(pickle.dumps(cs_event)))
コード例 #2
0
    def test_continuous_event_with_errors(self):
        begin_event_timestamp = 1623596860.1202102
        cs_event = CassandraStressEvent(node="node",
                                        stress_cmd="stress_cmd",
                                        log_file_name="log_file_name",
                                        publish_event=False)
        cs_event.event_id = "14f35b64-2fcc-4b6e-a09d-4aeaf4faa543"
        begin_event = cs_event.begin_event()
        begin_event.event_timestamp = begin_event.begin_timestamp = begin_event_timestamp
        self.assertEqual(
            str(begin_event),
            "(CassandraStressEvent Severity.NORMAL) period_type=begin "
            "event_id=14f35b64-2fcc-4b6e-a09d-4aeaf4faa543: node=node\nstress_cmd=stress_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(begin_event)))

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

        cs_event.end_event()
        end_event_timestamp = 1623596860.1202102
        cs_event.event_timestamp = cs_event.end_timestamp = end_event_timestamp
        self.assertEqual(
            str(cs_event),
            "(CassandraStressEvent Severity.ERROR) period_type=end "
            "event_id=14f35b64-2fcc-4b6e-a09d-4aeaf4faa543 duration=0s: node=node\nstress_cmd=stress_cmd"
            "\nerrors:\n\nerror1\nerror2")
        self.assertEqual(cs_event.event_timestamp, end_event_timestamp)
        self.assertEqual(cs_event.timestamp, end_event_timestamp)

        cs_event.add_error(["One more error"])
        cs_event.severity = Severity.CRITICAL
        cs_event.event_error()
        error_event_timestamp = 1623596860.1202102
        cs_event.event_timestamp = error_event_timestamp
        self.assertEqual(
            str(cs_event),
            "(CassandraStressEvent Severity.CRITICAL) period_type=one-time "
            "event_id=14f35b64-2fcc-4b6e-a09d-4aeaf4faa543 duration=0s: node=node\n"
            "stress_cmd=stress_cmd\nerrors:\n\nerror1\nerror2\nOne more error")
        self.assertEqual(cs_event.log_file_name, "log_file_name")
        self.assertEqual(cs_event.event_timestamp, error_event_timestamp)
        self.assertEqual(cs_event.timestamp, error_event_timestamp)
        self.assertEqual(cs_event, pickle.loads(pickle.dumps(cs_event)))