issue-3828: updated-workflow-and-stage-test (#5117)

This commit is contained in:
Abhishek Pandey 2022-05-25 11:10:22 +05:30 committed by GitHub
parent 8fd69e7eb8
commit 0a69a82b98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 25 deletions

View File

@ -1,27 +1,32 @@
{ {
"source": { "source": {
"type": "mysql", "type": "mysql",
"config": { "serviceName": "local_mysql_test",
"username": "openmetadata_user", "serviceConnection": {
"password": "openmetadata_password", "config": {
"database": "openmetadata_db", "type": "Mysql",
"service_name": "local_mysql_test", "username": "openmetadata_user",
"schema_filter_pattern": { "database":"openmetadata_db",
"excludes": ["mysql.*", "information_schema.*", "performance_schema.*", "sys.*"] "password": "openmetadata_password",
"hostPort": "localhost:3306",
"connectionOptions": {},
"connectionArguments": {}
}
},
"sourceConfig": {
"config": {
"enableDataProfiler": false
} }
} }
}, },
"stage": { "sink": {
"type": "file", "type": "metadata-rest",
"config": { "config": {}
"filename": "/tmp/mysql_test"
}
}, },
"metadata_server": { "workflowConfig": {
"type": "metadata-server", "openMetadataServerConfig": {
"config": { "hostPort": "http://localhost:8585/api",
"api_endpoint": "http://localhost:8585/api", "authProvider": "no-auth"
"auth_provider_type": "no-auth"
} }
} }
} }

View File

@ -0,0 +1,28 @@
source:
type: mysql
serviceName: local_mysql_test
serviceConnection:
config:
type: Mysql
username: openmetadata_user
password: openmetadata_password
database: openmetadata_db
hostPort: localhost:3306
connectionOptions: {}
connectionArguments: {}
sourceConfig:
config:
enableDataProfiler: false
schemaFilterPattern:
excludes:
- mysql.*
- information_schema.*
- performance_schema.*
- sys.*
sink:
type: metadata-rest
config: {}
workflowConfig:
openMetadataServerConfig:
hostPort: http://localhost:8585/api
authProvider: no-auth

View File

@ -14,6 +14,9 @@ import pathlib
from unittest import TestCase from unittest import TestCase
from metadata.config.common import ConfigurationError, load_config_file from metadata.config.common import ConfigurationError, load_config_file
from metadata.generated.schema.metadataIngestion.workflow import (
OpenMetadataWorkflowConfig,
)
from metadata.ingestion.api.workflow import Workflow from metadata.ingestion.api.workflow import Workflow
from metadata.ingestion.ometa.ometa_api import OpenMetadata from metadata.ingestion.ometa.ometa_api import OpenMetadata
@ -27,12 +30,11 @@ class WorkflowTest(TestCase):
self.assertEqual((my_class is not None), True) self.assertEqual((my_class is not None), True)
def test_get_4xx(self): def test_get_4xx(self):
my_class = None
key = "metadata.ingestion.sink.MYSQL.mysqlSINK" key = "metadata.ingestion.sink.MYSQL.mysqlSINK"
try: try:
if key.find(".") >= 0: if key.find(".") >= 0:
module_name, class_name = key.rsplit(".", 1) module_name, class_name = key.rsplit(".", 1)
my_class = getattr(importlib.import_module(module_name), class_name) getattr(importlib.import_module(module_name), class_name)
except ModuleNotFoundError: except ModuleNotFoundError:
self.assertRaises(ModuleNotFoundError) self.assertRaises(ModuleNotFoundError)
@ -60,19 +62,18 @@ class WorkflowTest(TestCase):
def test_execute_200(self): def test_execute_200(self):
current_dir = pathlib.Path(__file__).resolve().parent current_dir = pathlib.Path(__file__).resolve().parent
config_file = current_dir.joinpath("mysql_test.json") config_file = current_dir.joinpath("mysql_test.yaml")
workflow_config = load_config_file(config_file) workflow_config = load_config_file(config_file)
workflow = Workflow.create(workflow_config) workflow = Workflow.create(workflow_config)
workflow.execute() workflow.execute()
workflow.stop() workflow.stop()
config = MetadataServerConfig.parse_obj( config = workflow.config.workflowConfig.openMetadataServerConfig
workflow_config.get("metadata_server").get("config")
)
client = OpenMetadata(config).client client = OpenMetadata(config).client
client.delete( client.delete(
f"/services/databaseServices/" f"/services/databaseServices/"
f"{client.get('/services/databaseServices/name/local_mysql_test')['id']}" f"{client.get('/services/databaseServices/name/local_mysql_test')['id']}"
f"?hardDelete=true&recursive=true"
) )
file_path = "/tmp/mysql_test" file_path = "/tmp/mysql_test"
with open(file_path) as ingestionFile: with open(file_path) as ingestionFile:
@ -82,6 +83,6 @@ class WorkflowTest(TestCase):
def test_execute_4xx(self): def test_execute_4xx(self):
config_file = pathlib.Path("/tmp/mysql_test123") config_file = pathlib.Path("/tmp/mysql_test123")
try: try:
workflow_config = load_config_file(config_file) load_config_file(config_file)
except ConfigurationError: except ConfigurationError:
self.assertRaises(ConfigurationError) self.assertRaises(ConfigurationError)