-
Notifications
You must be signed in to change notification settings - Fork 33
Refactor network module - prepare it for easier sub-module testing #1191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Understandable.
For the processing server specifically, it is better to check the result not the changes. That one file got a lot of modifications and had to become fewer lines (~20% less).
Have you also tried the
Yes, tried to avoid moving stuff inside other modules (shall be the last thing to do) for now since this PR is already big enough. |
kba
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, very thorough. I'll now try to fix the bashlib test case, besides that looks good to go.
Co-authored-by: Konstantin Baierer <[email protected]>
Co-authored-by: Konstantin Baierer <[email protected]>
No, I didn't try that. |
(consider case where for_fileIds is an empty list)
Please feel free to suggest more changes that would lead to easier testing or improve the readability of the code. The Scrutinizer analysis already reports some good improvements so far.
Implemented refactoring changes:
network-module-test,network-integration-test"instead of'for strings to remove the need of escaping the'symbol when the string includes'.AgentType,DeployType,JobState,NetworkLoggingDirs,ServerApiTagsOCRD_NETWORK_WORKER_QUEUE_CONNECT_ATTEMPTS->OCRD_NETWORK_RABBITMQ_CLIENT_CONNECT_ATTEMPTSUNSETwhen not providedStateEnum->JobStatefor better clarificationstatus->stateto maintain the same variable name everywheresrc/ocrd_network/logging.py->src/ocrd_network/logging_utils.pyraise_http_exceptionmethod to wrap repetitive linesparse_workflow_tasks,validate_first_task_input_file_groups_existenceand moved these toutilsorserver_utilsdepending on whether a server response is involved or not. Moreover, moved some other full methods which were better fitting insideutilsorserver_utilssuch ascreate_processing_messagepush_processor_job->validate_and_forward_job_to_network_agentwhere network agent is of kindAgentType(check Enums above)syncversions of theasyncmethods to directly reuse these in the tests.create_queuemethod from processing worker torabbitmq_utilsmoduleagent_type. Check here.path_to_metsorworkspace_id. However, settingworkspace_idtoNonewas triggering an error that it's not of typestringaccording to the schema. On the other hand, assigning an empty string toworkspace_idwas triggering an error that eitherpath_to_metsorworkspace_idcould be set but not both. So there was no way to create a result message without a crash. By default, the fieldspath_to_metsorworkspace_idare set to empty strings when nothing is assigned. Check here.Implemented tests:
test_integration_*ortest_modules_*- the integration tests require access to either the MongoDB or RabbitMQ, but the module tests do not. Hence, the module tests can be executed without starting any extra services (faster for testing).test_db.py->test_integration_1_db.pyand replaced magic values with constantstest_rabbitmq.py->test_integration_2_rabbitmq.pyand replaced magic values with constantstest_integration_3_server_cache_requests.py- tests of the server cache for processing requeststest_integration_4_processing_worker.py- tests of the processing workertest_integration_5_processing_server.py- tests of the processing servertest_modules_logging_utils.pytest_modules_param_validators.pytest_modules_process_helpers.py- Testing invocation of pythonic and bashlib processortest_modules_server_cache_pages.py- Unlike the server cache requests, the pages cache does not require database access.Open issues:
_test_invoke_processor_bash()- Shall be fixed in this PR.deploy_agent_native_get_pid_hackmethod, but now isolated away from the deployer. An eye should be kept on that in another PR.Note: I have not merged the master branch to this PR yet, since v2.63.3 broke some mets caching. I will potentially do that before this PR can be finally merged.
Note2: The macOS tests are disabled since they fail due to a reason not related to this PR itself.