-
Notifications
You must be signed in to change notification settings - Fork 46
added the query kill test #884
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
base: integration_tests
Are you sure you want to change the base?
Changes from all commits
1daf8e2
ec84fb7
b7a86b9
5d1607a
9d4607c
51abd45
90ce13b
f8db29e
0cc7905
ed6a3f7
dff2995
3708298
1f1cf19
79eff23
5b3f6b6
e04bd51
a19c259
d13d40a
3b7665f
1be3853
8e56723
a145de2
9602d98
1372a31
ecfcd5e
28ff767
7c6bdeb
308df37
a380ae7
bb84561
cb04414
a29cd0c
2c8c5e2
7a8cd5c
728fcf7
728d73f
418b16b
7105770
eb8ab48
575c81a
6657dc2
2b455e0
597994e
086e0ad
b93d5f2
9f392b9
50db8b9
57a70c5
31ba501
6b2f4c6
03d8260
29ac24e
d5db777
cd9bc44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| import unittest | ||
| from collections import Counter | ||
| from tempfile import NamedTemporaryFile | ||
| from myria import MyriaConnection, MyriaRelation, MyriaQuery, MyriaError | ||
|
|
||
|
|
||
| class MyriaTestBase(unittest.TestCase): | ||
| def setUp(self): | ||
| connection = MyriaConnection(hostname='localhost', port=8753, execution_url="http://127.0.0.1:8080") | ||
| MyriaRelation.DefaultConnection = connection | ||
| self.connection = connection | ||
|
|
||
| def assertListOfDictsEqual(self, left, right): | ||
| self.assertEqual(Counter([kv for d in left for kv in d.items()]), | ||
| Counter([kv for d in right for kv in d.items()])) | ||
|
|
||
| class DoWhileTest(MyriaTestBase): | ||
| def test(self): | ||
| program = """ | ||
| x = [0 as exp, 1 as val]; | ||
| do | ||
| x = [from x emit exp+1 as exp, 2*val as val]; | ||
| while [from x emit max(exp) < 5]; | ||
| store(x, powersOfTwo); | ||
| """ | ||
| query = MyriaQuery.submit(program) | ||
| expected = [{'val': 32, 'exp': 5}] | ||
|
|
||
| self.assertEqual(query.status, 'SUCCESS') | ||
| self.assertListOfDictsEqual(query.to_dict(), expected) | ||
|
|
||
|
|
||
| class IngestEmptyQueryTest(MyriaTestBase): | ||
| def test(self): | ||
| # Create empty file | ||
| with NamedTemporaryFile() as f: | ||
| #TODO change URL to local file | ||
| program = """ | ||
| emptyrelation = load('https://s3-us-west-2.amazonaws.com/bhaynestemp/emptyrelation', csv(schema(foo:string, bar:int))); | ||
| store(emptyrelation, emptyrelation); | ||
| """ | ||
| expected = [] | ||
| query = MyriaQuery.submit(program) | ||
| self.assertEqual(query.status, 'SUCCESS') | ||
| self.assertListOfDictsEqual(query.to_dict(), expected) | ||
|
|
||
|
|
||
| class UploadAndReplaceDataTest(MyriaTestBase): | ||
| def test(self): | ||
| with NamedTemporaryFile() as f: | ||
| data = "foo,3242\n" \ | ||
| "bar,321\n"\ | ||
| "baz,104" | ||
| f.write(data) | ||
| #TODO change URL to local file | ||
| program = """ | ||
| uploaddatatest = load('https://s3-us-west-2.amazonaws.com/bhaynestemp/uploaddatatest', csv(schema(s:string, i:int))); | ||
| store(uploaddatatest, uploaddatatest); | ||
| """ | ||
| expected = [{u's': u'foo', u'i': 3242}, | ||
| {u's': u'bar', u'i': 321}, | ||
| {u's': u'baz', u'i': 104}] | ||
| query = MyriaQuery.submit(program) | ||
| self.assertEqual(query.status, 'SUCCESS') | ||
| self.assertListOfDictsEqual(query.to_dict(), expected) | ||
|
|
||
| # Now replace with another relation | ||
| program = """ | ||
| uploaddatatest = load('https://s3-us-west-2.amazonaws.com/bhaynestemp/uploaddatatest2', | ||
| csv(schema(s:string, i:int), delimiter='\\t')); | ||
| store(uploaddatatest, uploaddatatest); | ||
| """ | ||
| expected = [{u's': u'mexico', u'i': 42}, | ||
| {u's': u'poland', u'i': 12342}, | ||
| {u's': u'belize', u'i': 802304}] | ||
| query = MyriaQuery.submit(program) | ||
| self.assertEqual(query.status, 'SUCCESS') | ||
| self.assertListOfDictsEqual(query.to_dict(), expected) | ||
|
|
||
| class KillQueryTest(MyriaTestBase): | ||
| def test(self): | ||
| # This is a long-running program | ||
| program = """ | ||
| x = [0 as exp, 1 as val]; | ||
| do | ||
| x = [from x emit exp+1 as exp, 2*val as val]; | ||
| while [from x emit max(exp) < 1000]; | ||
| store(x, powersOfTwo); | ||
| """ | ||
| plan = self.connection.compile_program(program) | ||
| # We submit with submit_plan so as to not block | ||
| query = MyriaQuery.submit_plan(plan) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to just call a nonblocking
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we support asynchronous execution in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nonblocking overload added in uwescience/myria-python#62 |
||
|
|
||
| # We kill the query and make sure it was killed | ||
| query.kill() | ||
| self.assertEqual(query.status, 'KILLED') | ||
|
|
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
This file was deleted.
This file was deleted.
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.
May as well make this limit humongous (say a billion) to avoid races, since we're going to kill it at the first opportunity.