summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-02-14 17:50:01 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-02-14 17:50:01 +0000
commit1d4c5c068e1f45b606665614bab09cd4eb74f228 (patch)
tree9a0f0b319f06032fb8ed27c9b89f3636486ea155
parent8890239d939b6fefa88ecb4dd1fcfb313bc6eb82 (diff)
downloadsystem-tests-1d4c5c068e1f45b606665614bab09cd4eb74f228.tar.gz
The basis for our trove tests
Once this is finished it can be integrated with the test suite.
-rwxr-xr-xtest.py84
1 files changed, 84 insertions, 0 deletions
diff --git a/test.py b/test.py
new file mode 100755
index 0000000..9ee74ee
--- /dev/null
+++ b/test.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+
+import os
+import shutil
+import subprocess
+import string
+import tempfile
+
+#TROVE_ADMIN_USER = 'testuser'
+TROVE_ADMIN_USER = 'richardipsum'
+
+def remote_runcmd(url, 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
+ #subprocess.Popen(['ssh', url] + command, shell=True)
+
+def run_git(args, working_dir):
+ #return cliapp.runcmd(['git'] + args, **kwargs)
+ print 'args', args
+ print 'Running: ', ['git'] + args
+ p = subprocess.Popen(['git'] + args, cwd=working_dir)
+ p.wait()
+
+def create_test_project(url, project):
+ def t(s):
+ return project + '-' + s
+
+ remote_runcmd(url, ['group', 'add', t('managers'),
+ 'Managers for ' + project])
+ remote_runcmd(url, ['group', 'adduser', t('managers'), TROVE_ADMIN_USER])
+
+ remote_runcmd(url, ['group', 'add', t('admins'), 'Admins for ' + project])
+ remote_runcmd(url, ['group', 'addgroup', t('admins'), t('managers')])
+
+ remote_runcmd(url, ['group', 'add', t('writers'),
+ 'Users with write access to ' + project])
+ remote_runcmd(url, ['group', 'addgroup', t('writers'), t('admins')])
+
+ remote_runcmd(url, ['group', 'add', t('readers'),
+ 'Users with read access to ' + project])
+ remote_runcmd(url, ['group', 'addgroup', t('readers'), t('writers')])
+
+def create_test_repo(remote_url, project, repo):
+ trove_id = 'ct-ri-4' #self.vm_nhame
+
+ remote_runcmd(remote_url,
+ ['create', "%s/%s/%s" % (trove_id, project, repo)])
+
+vm_name = 'ct-ri-4'
+workspace_dir = tempfile.mkdtemp()
+
+print 'Created temporary workspace in', workspace_dir
+
+project = 'test-proj'
+repo = 'test-repo'
+filename = 'test-file'
+repodir = os.path.join(workspace_dir, repo)
+
+remote_url = 'git@' + vm_name
+
+create_test_project(remote_url, project)
+create_test_repo(remote_url, project, repo)
+
+# We should be able to clone
+#run_git(['clone', 'git@%s:%s/%s' % (self.vm_name, project, repo)],
+# cwd=workspace_dir)
+
+#run_git(['--version'], workspace_dir)
+
+run_git(['clone', 'git@%s:%s/%s/%s' % (vm_name, vm_name, project, repo)],
+ workspace_dir)
+
+with open(os.path.join(workspace_dir, repo, filename), 'w') as f:
+ f.write('A test file')
+
+run_git(['add', filename], repodir)
+run_git(['commit', '-m', 'Add a test file'], repodir)
+run_git(['push', 'origin', 'master'], repodir)
+#run_git(['push', 'origin', '%s/%s/%s/%s'
+# % (vm_name, project, TROVE_ADMIN_USER, 'test')], repodir)
+
+shutil.rmtree(workspace_dir)