summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-02-17 13:28:54 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-02-17 13:28:54 +0000
commit263f5d0cb7e64fb0a0ba828cf4ec79bcb7614c6b (patch)
tree5bca491602d5bd7d6725dcb496723227458ead00
parent3f9ac736b63e562b74f3b1ae4f67797ec9e547eb (diff)
downloadsystem-tests-263f5d0cb7e64fb0a0ba828cf4ec79bcb7614c6b.tar.gz
By jove use exceptions damn it!
-rwxr-xr-xtest.py45
1 files changed, 29 insertions, 16 deletions
diff --git a/test.py b/test.py
index a5117ee..a5033fb 100755
--- a/test.py
+++ b/test.py
@@ -1,15 +1,17 @@
#!/usr/bin/env python
+from __future__ import print_function
import os
import shutil
import subprocess
import string
+import sys
import tempfile
TROVE_ADMIN_USER = 'richardipsum'
def remote_runcmd(url, command):
- print 'Running: ' + string.join(command)
+ #print 'Running: ' + string.join(command)
subprocess.check_output(['ssh', url] + command)
# Err find out why this doesn't work when i'm less frazzled
@@ -17,13 +19,15 @@ def remote_runcmd(url, command):
def run_git(args, working_dir):
#return cliapp.runcmd(['git'] + args, **kwargs)
- print 'args', args
- print 'Running: ', ['git'] + args
+ #print 'args', args
+ #print ['git'] + args
p = subprocess.Popen(['git'] + args, cwd=working_dir)
return_code = p.wait()
- return return_code
+ if return_code != 0:
+ print('Git failed', file=sys.stderr)
+ raise Exception
def create_test_project(url, project):
def t(s):
@@ -51,36 +55,43 @@ def create_test_repo(remote_url, project, repo):
['create', "%s/%s/%s" % (trove_id, project, repo)])
def run_git_clone(vm_name, project, repo, workspace_dir):
- return run_git(['clone', 'git@%s:%s/%s/%s'
+ run_git(['clone', 'git@%s:%s/%s/%s'
+ % (vm_name, vm_name, project, repo)], workspace_dir)
+
+def run_git_clone_http(vm_name, project, repo, workspace_dir):
+ run_git(['clone', 'http://%s/git/%s/%s'
% (vm_name, vm_name, project, repo)], workspace_dir)
def can_clone(vm_name, project, repo):
workspace_dir = tempfile.mkdtemp()
- success = run_git_clone(vm_name, project, repo, workspace_dir) == 0
+ run_git_clone(vm_name, project, repo, workspace_dir)
shutil.rmtree(workspace_dir)
- return success
+def can_clone_http(vm_name, project, repo):
+ workspace_dir = tempfile.mkdtemp()
+
+ run_git_clone_http(vm_name, project, repo, workspace_dir)
+
+ shutil.rmtree(workspace_dir)
def can_push(vm_name, project, repo):
workspace_dir = tempfile.mkdtemp()
repodir = os.path.join(workspace_dir, repo)
- cloned = run_git_clone(vm_name, project, repo, workspace_dir)
+ run_git_clone(vm_name, project, repo, workspace_dir)
with open(os.path.join(workspace_dir, repo, filename), 'w') as f:
f.write('A test file')
- added = run_git(['add', filename], repodir)
- committed = run_git(['commit', '-m', 'Add a test file'], repodir)
+ run_git(['add', filename], repodir)
+ run_git(['commit', '-m', 'Add a test file'], repodir)
- pushed = run_git(['push', 'origin', 'master'], repodir)
+ run_git(['push', 'origin', 'master'], repodir)
shutil.rmtree(workspace_dir)
- return cloned + added + committed + pushed == 0
-
vm_name = 'ct-ri-4'
project = 'test-proj'
@@ -91,6 +102,8 @@ remote_url = 'git@' + vm_name
create_test_project(remote_url, project)
create_test_repo(remote_url, project, repo)
-# We should be able to clone
-cloned = can_clone(vm_name, project, repo)
-pushed = can_push(vm_name, project, repo)
+can_clone(vm_name, project, repo)
+can_push(vm_name, project, repo)
+
+#can_clone_http(vm_name, project, repo)
+#can_push_http(vm) \ No newline at end of file