-
Notifications
You must be signed in to change notification settings - Fork 117
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
Make asynchronous process test run asynchronously #657
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
################################################################## | ||
# Copyright 2018 Open Source Geospatial Foundation and others # | ||
# licensed under MIT, Please consult LICENSE.txt for details # | ||
################################################################## | ||
|
||
import unittest | ||
import time | ||
from pywps import Service, configuration | ||
from pywps import get_ElementMakerForVersion | ||
from pywps.tests import client_for, assert_response_accepted | ||
from .processes import Sleep | ||
from owslib.wps import WPSExecution | ||
from pathlib import Path | ||
|
||
VERSION = "1.0.0" | ||
|
||
WPS, OWS = get_ElementMakerForVersion(VERSION) | ||
|
||
|
||
class ExecuteTest(unittest.TestCase): | ||
def setUp(self) -> None: | ||
configuration.CONFIG.set('processing', 'mode', 'distributed') | ||
|
||
def tearDown(self) -> None: | ||
configuration.load_configuration() | ||
|
||
def test_async(self): | ||
client = client_for(Service(processes=[Sleep()])) | ||
wps = WPSExecution() | ||
|
||
# Build an asynchronous request (requires specifying outputs and setting the mode). | ||
doc = wps.buildRequest('sleep', | ||
inputs=[('seconds', '.01')], | ||
output=[('finished', None, None)], | ||
mode='async') | ||
|
||
resp = client.post_xml(doc=doc) | ||
wps.parseResponse(resp.xml) | ||
assert_response_accepted(resp) | ||
|
||
# Wait for process to complete. The test will fail otherwise, which confirms the process is asynchronous. | ||
time.sleep(.5) | ||
|
||
# Parse response to extract the status file path | ||
url = resp.xml.xpath("//@statusLocation")[0] | ||
|
||
# OWSlib only reads from URLs, not local files. So we need to read the response manually. | ||
p = Path(url[6:]) | ||
wps.checkStatus(response=p.read_bytes(), sleepSecs=0) | ||
assert wps.status == 'ProcessSucceeded' | ||
|
||
|
||
def load_tests(loader=None, tests=None, pattern=None): | ||
if not loader: | ||
loader = unittest.TestLoader() | ||
suite_list = [ | ||
loader.loadTestsFromTestCase(ExecuteTest), | ||
] | ||
return unittest.TestSuite(suite_list) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The check should be done explicitly to validate that the current status is still running with a new
checkStatus
, but is not yetProcessSucceeded
.If the process is somehow running in sync, this would not confirm that async was applied. It would just do a small wait before checking the status of an already completed process.