mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 02:29:03 +00:00 
			
		
		
		
	 f07daae196
			
		
	
	
		f07daae196
		
			
		
	
	
	
	
		
			
			* Add domain field to entity jsons * add subdomains ui * Add Domain To create Request * Typo fix * commit progress * allow multiple domains * - add userDomains and teamDomains * - Restrict Api Access * allow multiple domain support * - Add Listing Restricition - Add Search Restrictions * - Field Fix * - Inherit Team Domains * remove glossary filter from ui * - Fix Tag and User Filter * - Id -> FQN in create * - Missing domain on indexes * add domain in creation of team, user and glossary * fix merge conflicts * fix feedbacks * fix tests * add domain playwright * minor changes * fix domain fetching calls * Add Thread Listing with EntityDomain * Fixes for Team Join * Mkae list mutable * Add missing import * Fix Team Test * User Test case fix * Fix User Domain * Minor bug fixes related to sub domains * Fix data retaining in add sub domain modal after closing * fix NavBar unit test * Make Domain Access Work Via Policies * Fix errors introduced after conflict resolutions * update render function in SubDomainsTable.component.tsx to accept an array of owners instead of a single owner * fix java checkstyle * fix py-test * format * Fix the domain e2e owner field type * Fix Failing Tests * fixed pytest list index * update userDomains and teamDomains to domains * Entity Domain to Domain for thread and changeEvent * FIx fields * @Ovveride * FIx * Remove Duplicate Field * Remove Duplicate Field * Fix Failing Test * fix domain related changes * fix subdomains loader * Fix Owners Order * Enforce Domain Permissions * fix domain cleanup * Fix Test * rever owner change --------- Co-authored-by: karanh37 <karanh37@gmail.com> Co-authored-by: Aniket Katkar <aniketkatkar97@gmail.com> Co-authored-by: Pere Miquel Brull <peremiquelbrull@gmail.com> Co-authored-by: sonikashah <sonikashah94@gmail.com> Co-authored-by: Sriharsha Chintalapani <harshach@users.noreply.github.com> Co-authored-by: Onkar Ravgan <onkar.10r@gmail.com> Co-authored-by: Karan Hotchandani <33024356+karanh37@users.noreply.github.com>
		
			
				
	
	
		
			214 lines
		
	
	
		
			7.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			214 lines
		
	
	
		
			7.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| #  Copyright 2021 Collate
 | |
| #  Licensed under the Apache License, Version 2.0 (the "License");
 | |
| #  you may not use this file except in compliance with the License.
 | |
| #  You may obtain a copy of the License at
 | |
| #  http://www.apache.org/licenses/LICENSE-2.0
 | |
| #  Unless required by applicable law or agreed to in writing, software
 | |
| #  distributed under the License is distributed on an "AS IS" BASIS,
 | |
| #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
| #  See the License for the specific language governing permissions and
 | |
| #  limitations under the License.
 | |
| 
 | |
| """
 | |
| Test how we create and update status in Ingestion Pipelines
 | |
| """
 | |
| import json
 | |
| from unittest import TestCase
 | |
| 
 | |
| import pytest
 | |
| 
 | |
| from _openmetadata_testutils.ometa import int_admin_ometa
 | |
| from metadata.generated.schema.entity.services.connections.database.common.basicAuth import (
 | |
|     BasicAuth,
 | |
| )
 | |
| from metadata.generated.schema.entity.services.connections.database.mysqlConnection import (
 | |
|     MysqlConnection,
 | |
| )
 | |
| from metadata.generated.schema.entity.services.databaseService import DatabaseService
 | |
| from metadata.generated.schema.entity.services.ingestionPipelines.ingestionPipeline import (
 | |
|     IngestionPipeline,
 | |
|     PipelineState,
 | |
|     PipelineStatus,
 | |
| )
 | |
| from metadata.generated.schema.entity.services.ingestionPipelines.status import (
 | |
|     IngestionStatus,
 | |
|     StackTraceError,
 | |
|     StepSummary,
 | |
| )
 | |
| from metadata.ingestion.api.status import TruncatedStackTraceError
 | |
| from metadata.workflow.metadata import MetadataWorkflow
 | |
| 
 | |
| from ..integration_base import (
 | |
|     METADATA_INGESTION_CONFIG_TEMPLATE,
 | |
|     generate_name,
 | |
|     get_create_service,
 | |
| )
 | |
| 
 | |
| 
 | |
| class OMetaTableTest(TestCase):
 | |
|     """
 | |
|     Run this integration test with the local API available
 | |
|     Install the ingestion package before running the tests
 | |
|     """
 | |
| 
 | |
|     metadata = int_admin_ometa()
 | |
|     service_name = generate_name()
 | |
| 
 | |
|     @classmethod
 | |
|     def setUpClass(cls) -> None:
 | |
|         """
 | |
|         Prepare ingredients
 | |
|         """
 | |
|         # Create the service entity
 | |
|         create_service = get_create_service(
 | |
|             entity=DatabaseService, name=cls.service_name
 | |
|         )
 | |
|         cls.service_entity = cls.metadata.create_or_update(data=create_service)
 | |
| 
 | |
|         workflow_config = json.loads(
 | |
|             METADATA_INGESTION_CONFIG_TEMPLATE.format(
 | |
|                 type="mysql",
 | |
|                 service_name=cls.service_name,
 | |
|                 service_config=MysqlConnection(
 | |
|                     username="openmetadata_user",
 | |
|                     authType=BasicAuth(
 | |
|                         password="openmetadata_password",
 | |
|                     ),
 | |
|                     hostPort="localhost:3306",
 | |
|                 ).model_dump_json(),
 | |
|                 source_config={},
 | |
|             )
 | |
|         )
 | |
|         workflow_config["ingestionPipelineFQN"] = f"{cls.service_name}.ingestion"
 | |
|         cls.workflow: MetadataWorkflow = MetadataWorkflow.create(workflow_config)
 | |
| 
 | |
|         # Since we won't run the full workflow, let's create the service first
 | |
|         # which is needed to create the ingestion
 | |
|         cls.metadata.get_service_or_create(
 | |
|             entity=DatabaseService, config=cls.workflow.config.source
 | |
|         )
 | |
| 
 | |
|     @classmethod
 | |
|     def tearDownClass(cls) -> None:
 | |
|         """
 | |
|         Clean up
 | |
|         """
 | |
| 
 | |
|         service_id = str(
 | |
|             cls.metadata.get_by_name(
 | |
|                 entity=DatabaseService, fqn=cls.service_name
 | |
|             ).id.root
 | |
|         )
 | |
| 
 | |
|         cls.metadata.delete(
 | |
|             entity=DatabaseService,
 | |
|             entity_id=service_id,
 | |
|             recursive=True,
 | |
|             hard_delete=True,
 | |
|         )
 | |
| 
 | |
|     def test_create_ingestion_pipeline(self) -> None:
 | |
|         """We can create an ingestion pipeline"""
 | |
| 
 | |
|         ingestion_pipeline: IngestionPipeline = self.workflow.ingestion_pipeline
 | |
|         assert ingestion_pipeline is not None
 | |
|         assert ingestion_pipeline.name.root == "ingestion"
 | |
| 
 | |
|     def test_add_status(self) -> None:
 | |
|         """We can add status to the ingestion pipeline"""
 | |
| 
 | |
|         ingestion_pipeline: IngestionPipeline = self.workflow.ingestion_pipeline
 | |
|         assert ingestion_pipeline is not None
 | |
| 
 | |
|         # We can send a status to the ingestion pipeline
 | |
|         ingestion_status = IngestionStatus(
 | |
|             [
 | |
|                 StepSummary(
 | |
|                     name="source",
 | |
|                     failures=[
 | |
|                         StackTraceError(
 | |
|                             name="error",
 | |
|                             error="error",
 | |
|                             stackTrace="stackTrace",
 | |
|                         )
 | |
|                     ],
 | |
|                 )
 | |
|             ]
 | |
|         )
 | |
| 
 | |
|         pipeline_status: PipelineStatus = self.workflow._new_pipeline_status(
 | |
|             PipelineState.success
 | |
|         )
 | |
|         pipeline_status.status = ingestion_status
 | |
| 
 | |
|         # Gets properly created
 | |
|         self.metadata.create_or_update_pipeline_status(
 | |
|             ingestion_pipeline.fullyQualifiedName.root, pipeline_status
 | |
|         )
 | |
| 
 | |
|         real_pipeline_status: PipelineStatus = self.metadata.get_pipeline_status(
 | |
|             ingestion_pipeline.fullyQualifiedName.root, self.workflow.run_id
 | |
|         )
 | |
|         assert real_pipeline_status.pipelineState == PipelineState.success
 | |
| 
 | |
|         # If the status has too long names/errors it will fail
 | |
|         too_long_status = IngestionStatus(
 | |
|             [
 | |
|                 StepSummary(
 | |
|                     name="source",
 | |
|                     failures=[
 | |
|                         StackTraceError(
 | |
|                             name="error",
 | |
|                             error="error" * 20_000_000,
 | |
|                             stackTrace="stackTrace",
 | |
|                         )
 | |
|                     ],
 | |
|                 )
 | |
|             ]
 | |
|         )
 | |
| 
 | |
|         pipeline_status: PipelineStatus = self.workflow._new_pipeline_status(
 | |
|             PipelineState.success
 | |
|         )
 | |
|         pipeline_status.status = too_long_status
 | |
| 
 | |
|         # We get a bad request error
 | |
|         with pytest.raises(Exception) as exc:
 | |
|             self.metadata.create_or_update_pipeline_status(
 | |
|                 ingestion_pipeline.fullyQualifiedName.root, pipeline_status
 | |
|             )
 | |
| 
 | |
|         assert ("exceeds the maximum allowed" in str(exc.value)) or (
 | |
|             "Connection aborted." in str(exc.value)
 | |
|         )
 | |
| 
 | |
|         # If we truncate the status it all runs good
 | |
|         truncated_long_status = IngestionStatus(
 | |
|             [
 | |
|                 StepSummary(
 | |
|                     name="source",
 | |
|                     failures=[
 | |
|                         TruncatedStackTraceError(
 | |
|                             name="error",
 | |
|                             error="error" * 20_000_000,
 | |
|                             stackTrace="stackTrace",
 | |
|                         )
 | |
|                     ],
 | |
|                 )
 | |
|             ]
 | |
|         )
 | |
| 
 | |
|         pipeline_status: PipelineStatus = self.workflow._new_pipeline_status(
 | |
|             PipelineState.success
 | |
|         )
 | |
|         pipeline_status.status = truncated_long_status
 | |
| 
 | |
|         res = self.metadata.create_or_update_pipeline_status(
 | |
|             ingestion_pipeline.fullyQualifiedName.root, pipeline_status
 | |
|         )
 | |
| 
 | |
|         assert (
 | |
|             res["entityFullyQualifiedName"]
 | |
|             == ingestion_pipeline.fullyQualifiedName.root
 | |
|         )
 |