Example #1
0
    def fetch_ids_and_schemas_by_subjectversion(self):
        """
        Return all pairs (id, schema) that can be fetched by subject/version, for all versions listed under the subject.
        """
        master_id = self.schema_registry.idx(
            self.schema_registry.get_master_node())
        base_url = self.schema_registry.url(master_id, external=True)
        versions = get_all_versions(base_url, self.register_driver.subject)

        fetched_ids_and_schemas = []
        failed_versions = []
        for version in versions:
            try:
                fetched_schema_info = get_schema_by_version(
                    base_url, self.register_driver.subject, version)
                fetched_schema_string = self.normalize_schema_string(
                    fetched_schema_info["schema"])
                fetched_ids_and_schemas.append(
                    (fetched_schema_info["id"], fetched_schema_string))
            except:
                failed_versions.append(version)
        if len(failed_versions) > 0:
            raise Exception("Failed to fetch versions: " +
                            str(failed_versions))

        return fetched_ids_and_schemas
Example #2
0
    def report_summary(self):
        # Gather statistics
        summary = "\n-------------------------------------------------------------------\n"
        summary += "Summary\n"
        summary += "Histogram of number of attempts needed to successfully register:\n"
        summary += str(self.register_driver.try_histogram) + "\n"

        attempted = self.register_driver.num_attempted_registrations
        succeeded = sum([1 for record in self.register_driver.registration_data if record["success"]])
        summary += "Attempted to register %d schemas. " % attempted + "\n"
        summary += "Max registration attempts allowed: %d\n" % self.num_retries
        summary += "Retry backoff: %f seconds\n" % self.retry_wait_sec
        summary += "Successful: %d/%d = %f\n" % (succeeded, attempted, succeeded / float(attempted))

        success = True

        # Verify that all ids reported as successfully registered can be fetched
        master_id = self.schema_registry.idx(self.schema_registry.get_master_node())
        base_url = self.schema_registry.url(master_id, external=True)
        registered_ids = [record["schema_id"] for record in self.register_driver.registration_data if record["success"]]
        registered_schemas = [record["schema_string"]
                              for record in self.register_driver.registration_data if record["success"]]
        summary += "Validating that schemas reported as successful can be fetched by id...\n"
        for id in registered_ids:
            try:
                schema = get_schema_by_id(base_url, id)
            except:
                success = False
                summary += "%d was reported successful but actually failed\n" % id
        summary += "Success.\n" if success else "Failure.\n"

        # Verify that number of versions fetched matches number of registered ids
        versions = get_all_versions(base_url, self.register_driver.subject)
        summary += \
            "Validating that number of reported successful registrations matches number of versions in subject...\n"
        if len(versions) != len(registered_ids):
            success = False
        summary += "Success.\n" if success else "Failure.\n"

        results = self.validate_schema_consistency()
        summary += results["message"] + "\n"
        success = success and results["success"]

        results = self.validate_registered_vs_subjectversion()
        summary += results["message"] + "\n"
        success = success and results["success"]

        results = self.validate_registered_vs_subjectschema()
        summary += results["message"] + "\n"
        success = success and results["success"]

        summary += "-------------------------------------------------------------------\n"
        assert success, summary
        self.logger.info(summary)
Example #3
0
    def report_summary(self):
        # Gather statistics
        summary = "\n-------------------------------------------------------------------\n"
        summary += "Summary\n"
        summary += "Histogram of number of attempts needed to successfully register:\n"
        summary += str(self.register_driver.try_histogram) + "\n"

        attempted = self.register_driver.num_attempted_registrations
        succeeded = sum([1 for record in self.register_driver.registration_data if record["success"]])
        summary += "Attempted to register %d schemas. " % attempted + "\n"
        summary += "Max registration attempts allowed: %d\n" % self.num_retries
        summary += "Retry backoff: %f seconds\n" % self.retry_wait_sec
        summary += "Successful: %d/%d = %f\n" % (succeeded, attempted, succeeded / float(attempted))

        success = True

        # Verify that all ids reported as successfully registered can be fetched
        master_id = self.schema_registry.idx(self.schema_registry.get_master_node())
        base_url = self.schema_registry.url(master_id, external=True)
        registered_ids = [record["schema_id"] for record in self.register_driver.registration_data if record["success"]]
        registered_schemas = [record["schema_string"]
                              for record in self.register_driver.registration_data if record["success"]]
        summary += "Validating that schemas reported as successful can be fetched by id...\n"
        for id in registered_ids:
            try:
                schema = get_schema_by_id(base_url, id)
            except:
                success = False
                summary += "%d was reported successful but actually failed\n" % id
        summary += "Success.\n" if success else "Failure.\n"

        # Verify that number of versions fetched matches number of registered ids
        versions = get_all_versions(base_url, self.register_driver.subject)
        summary += \
            "Validating that number of reported successful registrations matches number of versions in subject...\n"
        if len(versions) != len(registered_ids):
            success = False
        summary += "Success.\n" if success else "Failure.\n"

        results = self.validate_schema_consistency()
        summary += results["message"] + "\n"
        success = success and results["success"]

        results = self.validate_registered_vs_subjectversion()
        summary += results["message"] + "\n"
        success = success and results["success"]

        results = self.validate_registered_vs_subjectschema()
        summary += results["message"] + "\n"
        success = success and results["success"]

        summary += "-------------------------------------------------------------------\n"
        assert success, summary
        self.logger.info(summary)
Example #4
0
    def fetch_ids_and_schemas_by_subjectversion(self):
        """
        Return all pairs (id, schema) that can be fetched by subject/version, for all versions listed under the subject.
        """
        master_id = self.schema_registry.idx(self.schema_registry.get_master_node())
        base_url = self.schema_registry.url(master_id, external=True)
        versions = get_all_versions(base_url, self.register_driver.subject)

        fetched_ids_and_schemas = []
        failed_versions = []
        for version in versions:
            try:
                fetched_schema_info = get_schema_by_version(base_url, self.register_driver.subject, version)
                fetched_schema_string = self.normalize_schema_string(fetched_schema_info["schema"])
                fetched_ids_and_schemas.append((fetched_schema_info["id"], fetched_schema_string))
            except:
                failed_versions.append(version)
        if len(failed_versions) > 0:
            raise Exception("Failed to fetch versions: " + str(failed_versions))

        return fetched_ids_and_schemas