Beispiel #1
0
    def validate_deleted_rows(self, session, during_nemesis=False):
        """
        Part of data in the user profile table will be deleted using LWT.
        This data will be saved in the materialized view with "_deletions" substring in the name
        After prepare write rows count in this materialized view will be saved self.rows_before_deletion variable as
        expected result.
        During stress (after prepare) LWT delete statements will be run for a few hours.
        When stress will be finished this function verifies that rows count in "_deletions" MV will be less then it
        was saved in self.rows_before_deletion
        """
        if not self.rows_before_deletion:
            LOGGER.debug(
                'Verify deleted rows can\'t be performed as expected rows count had not been saved'
            )
            return

        pk_name = self.base_table_partition_keys[0]
        if not during_nemesis:
            LOGGER.debug('Verify deleted rows')

        actual_result = self.longevity_self_object.fetch_all_rows(
            session=session,
            default_fetch_size=self.DEFAULT_FETCH_SIZE,
            statement=
            f"SELECT {pk_name} FROM {self.view_name_for_deletion_data}",
            verbose=not during_nemesis)
        if not actual_result:
            DataValidatorEvent.DeletedRowsValidator(
                severity=Severity.ERROR,
                error=
                f"Can't validate deleted rows. Fetch all rows from {self.view_name_for_deletion_data} failed. "
                f"See error above in the sct.log").publish()
            return

        if len(actual_result) < self.rows_before_deletion:
            if not during_nemesis:
                # raise info event in the end of test only
                DataValidatorEvent.DeletedRowsValidator(
                    severity=Severity.NORMAL,
                    message="Validation deleted rows finished successfully"
                ).publish()
            else:
                LOGGER.debug('Validation deleted rows finished successfully')
        else:
            LOGGER.warning(
                'Deleted row were not found. May be issue #6181. '
                'Actual dataset length: {}, Expected dataset length: {}'.
                format(len(actual_result), self.rows_before_deletion))
    def test_data_validator_event_msgfmt(self):
        critical_event = DataValidatorEvent.DataValidator(
            severity=Severity.ERROR, error="e1")
        self.assertEqual(
            str(critical_event),
            "(DataValidatorEvent Severity.ERROR): type=DataValidator error=e1")
        self.assertEqual(critical_event,
                         pickle.loads(pickle.dumps(critical_event)))

        error_event = DataValidatorEvent.ImmutableRowsValidator(
            severity=Severity.ERROR, error="e2")
        self.assertEqual(
            str(error_event),
            "(DataValidatorEvent Severity.ERROR): type=ImmutableRowsValidator error=e2"
        )
        self.assertEqual(error_event, pickle.loads(pickle.dumps(error_event)))

        warning_event = DataValidatorEvent.UpdatedRowsValidator(
            severity=Severity.WARNING, message="m3")
        self.assertEqual(
            str(warning_event),
            "(DataValidatorEvent Severity.WARNING): type=UpdatedRowsValidator message=m3"
        )
        self.assertEqual(warning_event,
                         pickle.loads(pickle.dumps(warning_event)))

        info_event = DataValidatorEvent.DeletedRowsValidator(
            severity=Severity.NORMAL, message="m4")
        self.assertEqual(
            str(info_event),
            "(DataValidatorEvent Severity.NORMAL): type=DeletedRowsValidator message=m4"
        )
        self.assertEqual(info_event, pickle.loads(pickle.dumps(info_event)))
Beispiel #3
0
    def test_data_validator_event_msgfmt(self):
        critical_event = DataValidatorEvent.DataValidator(
            severity=Severity.ERROR, error="e1")
        critical_event.event_id = "3916da00-643c-4886-bdd0-963d3ebac536"
        self.assertEqual(
            str(critical_event),
            "(DataValidatorEvent Severity.ERROR) period_type=one-time "
            "event_id=3916da00-643c-4886-bdd0-963d3ebac536: type=DataValidator error=e1"
        )
        self.assertEqual(critical_event,
                         pickle.loads(pickle.dumps(critical_event)))

        error_event = DataValidatorEvent.ImmutableRowsValidator(
            severity=Severity.ERROR, error="e2")
        error_event.event_id = "3916da00-643c-4886-bdd0-963d3ebac536"
        self.assertEqual(
            str(error_event),
            "(DataValidatorEvent Severity.ERROR) period_type=one-time "
            "event_id=3916da00-643c-4886-bdd0-963d3ebac536: type=ImmutableRowsValidator error=e2"
        )
        self.assertEqual(error_event, pickle.loads(pickle.dumps(error_event)))

        warning_event = DataValidatorEvent.UpdatedRowsValidator(
            severity=Severity.WARNING, message="m3")
        warning_event.event_id = "3916da00-643c-4886-bdd0-963d3ebac536"
        self.assertEqual(
            str(warning_event),
            "(DataValidatorEvent Severity.WARNING) period_type=one-time "
            "event_id=3916da00-643c-4886-bdd0-963d3ebac536: type=UpdatedRowsValidator message=m3"
        )
        self.assertEqual(warning_event,
                         pickle.loads(pickle.dumps(warning_event)))

        info_event = DataValidatorEvent.DeletedRowsValidator(
            severity=Severity.NORMAL, message="m4")
        info_event.event_id = "3916da00-643c-4886-bdd0-963d3ebac536"
        self.assertEqual(
            str(info_event),
            "(DataValidatorEvent Severity.NORMAL) period_type=one-time "
            "event_id=3916da00-643c-4886-bdd0-963d3ebac536: type=DeletedRowsValidator message=m4"
        )
        self.assertEqual(info_event, pickle.loads(pickle.dumps(info_event)))