Permalink
Browse files

tests: Just skip tests if EC2 env vars are unset.

Now, we shouldn't get assertion errors in case the EC2 environment
variables are not set and can continue running the rest of the tests,
which also include some tests for VirtualBox and also two tests that
don't even require any backend.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
  • Loading branch information...
1 parent d11209c commit d77d1f222d2214dc448a40f981399bacfc6ad7e2 @aszlig aszlig committed Jul 26, 2013
Showing with 20 additions and 10 deletions.
  1. +0 −3 coverage-tests.py
  2. +0 −3 tests.py
  3. +12 −3 tests/functional/generic_deployment_test.py
  4. +8 −1 tests/functional/test_encrypted_links.py
View
3 coverage-tests.py
@@ -3,9 +3,6 @@
import os
if __name__ == "__main__":
- assert os.getenv("EC2_SECURITY_GROUP") is not None, "The EC2_SECURITY_GROUP env var must be set to the name of an ec2 security group with inbound ssh access"
- assert os.getenv("EC2_KEY_PAIR") is not None, "The EC2_KEY_PAIR env var must be set to the name of an ec2 keypair"
- assert os.getenv("EC2_PRIVATE_KEY_FILE") is not None, "The EC2_PRIVATE_KEY_FILE env var must be set to the private key of an ec2 keypair"
nose.main(argv=[sys.argv[0], "--with-xunit", "--with-coverage",
"--cover-inclusive", "--cover-xml",
"--cover-xml-file=coverage.xml", "--cover-html",
View
3 tests.py
@@ -3,9 +3,6 @@
import os
if __name__ == "__main__":
- assert os.getenv("EC2_SECURITY_GROUP") is not None, "The EC2_SECURITY_GROUP env var must be set to the name of an ec2 security group with inbound ssh access"
- assert os.getenv("EC2_KEY_PAIR") is not None, "The EC2_KEY_PAIR env var must be set to the name of an ec2 keypair"
- assert os.getenv("EC2_PRIVATE_KEY_FILE") is not None, "The EC2_PRIVATE_KEY_FILE env var must be set to the private key of an ec2 keypair"
config = nose.config.Config(plugins=nose.plugins.manager.DefaultPluginManager())
config.configure(argv=[sys.argv[0], "-e", "^coverage-tests\.py$"] +
sys.argv[1:])
View
15 tests/functional/generic_deployment_test.py
@@ -2,6 +2,8 @@
import subprocess
import nixops.statefile
+from nose import SkipTest
+
from tests.functional import DatabaseUsingTest
class GenericDeploymentTest(DatabaseUsingTest):
@@ -11,9 +13,16 @@ def setup(self):
self.depl.logger.set_autoresponse("y")
def set_ec2_args(self):
- assert os.getenv("EC2_SECURITY_GROUP") is not None, "The EC2_SECURITY_GROUP env var must be set to the name of an ec2 security group with inbound ssh access"
- assert os.getenv("EC2_KEY_PAIR") is not None, "The EC2_KEY_PAIR env var must be set to the name of an ec2 keypair"
- assert os.getenv("EC2_PRIVATE_KEY_FILE") is not None, "The EC2_PRIVATE_KEY_FILE env var must be set to the private key of an ec2 keypair"
+ if os.getenv("EC2_SECURITY_GROUP") is None:
+ raise SkipTest("The EC2_SECURITY_GROUP env var must be set to the"
+ " name of an EC2 security group with inbound ssh"
+ " access")
+ if os.getenv("EC2_KEY_PAIR") is None:
+ raise SkipTest("The EC2_KEY_PAIR env var must be set to the name"
+ " of an EC2 keypair")
+ if os.getenv("EC2_PRIVATE_KEY_FILE") is None:
+ raise SkipTest("The EC2_PRIVATE_KEY_FILE env var must be set to"
+ " the private key of an EC2 keypair")
self.depl.set_argstr("securityGroup", os.getenv("EC2_SECURITY_GROUP"))
self.depl.set_argstr("keyPair", os.getenv("EC2_KEY_PAIR"))
View
9 tests/functional/test_encrypted_links.py
@@ -1,10 +1,12 @@
from os import path
-from nose import tools
+from nose import tools, SkipTest
from tests.functional import generic_deployment_test
from nixops.ssh_util import SSHCommandFailed
+from nixops.util import devnull
import sys
import time
import signal
+import subprocess
parent_dir = path.dirname(__file__)
@@ -17,6 +19,11 @@ def setup(self):
self.depl.nix_exprs = [ logical_spec ]
def test_deploy(self):
+ if subprocess.call(["VBoxManage", "--version"],
+ stdout=devnull,
+ stderr=devnull) != 0:
+ raise SkipTest("VirtualBox is not available")
+
self.depl.debug = True
self.depl.deploy()

0 comments on commit d77d1f2

Please sign in to comment.