apache/incubator-spark — pull request #668 by logc (2014-03-12 15:46:00+00:00)
Title: Add unit test to spark_ec2 script

Add a unittest for a refactored function to destroy cluster. Relies on mock and moto dependencies to avoid sending out EC2 requests.

We noticed at work that the supplied script does not work always when destroying clusters, specially for regions outside "us-east-1". This pull request adds a test on the command. If this is accepted, we can continue debugging why exactly are such clusters not terminated correctly.

Run the test with:

```console
$ python ec2/tests.py
Searching for existing cluster cluster_name...
Terminating master...
Terminating slaves...
Deleting security groups (this will take some time)...
Attempt 1
.
----------------------------------------------------------------------
Ran 1 test in 1.040s
```

Please notice that the test relies on [moto](https://github.com/spulec/moto) and [mock](https://pypi.python.org/pypi/mock) to run. Since I did not know how you handle such dependencies, I have not added a `requirements.txt` or a `setup.py` script, but can update the pull request in that sense.