-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Add unit test to spark_ec2 script #134
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| *.ipr | ||
| *.iml | ||
| *.iws | ||
| *.pyc | ||
| .idea/ | ||
| sbt/*.jar | ||
| .settings | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #!/usr/bin/env python | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| """ | ||
| Module: tests.py | ||
|
|
||
| This module holds all unit tests defined for the deployment to EC2 | ||
| functionality of Spark. Run this module directly to execute the tests: | ||
|
|
||
| $ python tests.py | ||
| """ | ||
| import unittest | ||
|
|
||
| from boto import ec2 | ||
| import mock | ||
| import moto | ||
|
|
||
| import spark_ec2 | ||
|
|
||
|
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. extra newline
Author
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. The extra newline before classes is required by the
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. Actually I check code in pyspark as well and we do follow the flake8 defaults of extra newline before classes. So keep this in is absolutely fine. |
||
|
|
||
|
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. Can you also add some class level comments and instructions on how to run this test here ?
Author
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. Done |
||
| class CommandTests(unittest.TestCase): | ||
| """ | ||
| CommandTests defines unit tests for the commands that can be passed to the | ||
| deployment script: launch, destroy, login, etc ... | ||
| """ | ||
|
|
||
| @moto.mock_ec2 | ||
| def test_destroy(self): | ||
| spark_ec2.AWS_EVENTUAL_CONSISTENCY = 1 | ||
| opts = mock.MagicMock(name='opts') | ||
| opts.region = "us-east-1" | ||
| conn = ec2.connect_to_region(opts.region) | ||
| cluster_name = "cluster_name" | ||
| try: | ||
| spark_ec2.destroy_cluster(conn, opts, cluster_name) | ||
| except: | ||
| self.fail("destroy_cluster raised unexpected exception") | ||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
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.
This should probably include
and definitely include the Apache license header
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.
Done