-
Notifications
You must be signed in to change notification settings - Fork 31
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
Refactor network module - prepare it for easier sub-module testing #1191
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. |
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
,ServerApiTags
OCRD_NETWORK_WORKER_QUEUE_CONNECT_ATTEMPTS
->OCRD_NETWORK_RABBITMQ_CLIENT_CONNECT_ATTEMPTS
UNSET
when not providedStateEnum
->JobState
for better clarificationstatus
->state
to maintain the same variable name everywheresrc/ocrd_network/logging.py
->src/ocrd_network/logging_utils.py
raise_http_exception
method to wrap repetitive linesparse_workflow_tasks
,validate_first_task_input_file_groups_existence
and moved these toutils
orserver_utils
depending on whether a server response is involved or not. Moreover, moved some other full methods which were better fitting insideutils
orserver_utils
such ascreate_processing_message
push_processor_job
->validate_and_forward_job_to_network_agent
where network agent is of kindAgentType
(check Enums above)sync
versions of theasync
methods to directly reuse these in the tests.create_queue
method from processing worker torabbitmq_utils
moduleagent_type
. Check here.path_to_mets
orworkspace_id
. However, settingworkspace_id
toNone
was triggering an error that it's not of typestring
according to the schema. On the other hand, assigning an empty string toworkspace_id
was triggering an error that eitherpath_to_mets
orworkspace_id
could be set but not both. So there was no way to create a result message without a crash. By default, the fieldspath_to_mets
orworkspace_id
are 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.py
and replaced magic values with constantstest_rabbitmq.py
->test_integration_2_rabbitmq.py
and 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.py
test_modules_param_validators.py
test_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_hack
method, 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.