def test_replays(self):
        self.print_str('\n\n----- Testing Replays -----')
        commit = self.resolve_tag()
        self.run_lisod(commit.tree)
        time.sleep(3)
        replays_dir = os.path.join(self.grader.tmp_dir, 'replays')
        if not os.path.exists(replays_dir):
            os.makedirs(replays_dir)
        files = os.listdir(replays_dir)
        num_passed = 0
        num_files = 0
        for fname in files:
            basename, extension = os.path.splitext(fname)
            if extension == '.test': 
                num_files += 1
                self.print_str('testing %s...' % fname)
                fname = os.path.join(self.grader.tmp_dir + 'replays', fname)
                outfile = os.path.join(self.grader.tmp_dir + 'replays', '%s_%s.out' % (basename, self.repo))
                command = 'ncat -i 1s localhost %d < %s > %s' % (self.port, fname, outfile)

                check_both(command, False, False)
                with open(os.path.join(self.grader.tmp_dir + 'replays', basename+'.out')) as f:
                    with open(outfile) as f2:
                        outhash = hashlib.sha256(f.read()).hexdigest()
                        out2hash = hashlib.sha256(f2.read()).hexdigest()
                        if outhash == out2hash:
                            self.print_str('ok')
                            num_passed += 1
                        else:
                            self.print_str('failed')
                check_both('rm %s' % outfile)
        self.print_str('passed %d of %d' % (num_passed, num_files))
        self.pAssertEqual(num_passed,num_files)
Example #2
0
    def exposed_gather_browser_stats(self, type):
        # write to etc/hosts.xia
        check_output('echo "%s %s" > %s' % (BROWSER_ADDR, rpc(MASTER_SERVER, 'get_neighbor_webserver', (type,)), ETC_HOSTS))

        print check_output('cat %s' % ETC_HOSTS)

        while True:
            try:
                check_output('ps -e | grep proxy.py')
                break
            except:
                if type == 'tunneling':
                    Popen(PROXY_CMD, shell=True)
                else:
                    proxy_dag = rpc(MASTER_SERVER, 'exposed_get_proxy_address', (type,))
                    print 'proxy going to start'
                    print proxy_dag
                    Popen('%s "%s"' % (PROXY_CMD, proxy_dag), shell=True)
                time.sleep(1)
        time.sleep(3)
        print 'running browser cmd'
        p = Popen(BROWSER_CMD,shell=True)
        p.wait()
        time.sleep(3)
        while True:
            (out, rc) = check_both(BROWSER_CMD, check=False)
            if rc == 1:
                raise Execption("BROWSER_CMD failed")
            if rc == 0:
                break
            time.sleep(1)
        out = out[0].split('\n')[-2].split(' ')[-1]
        rpc(MASTER_SERVER, 'browser_stats', (out,type))
        check_output('killall proxy.py')
    def __init__(self, andrewid, cp_num, due_date, source_reminder):
        self.andrewid = andrewid
        self.cp_num = cp_num
        self.root_repo = ROOT_REPO_TEMPLATE % (andrewid, andrewid)
        self.tmp_dir = '/tmp/%s/cp%d/' % (getpass.getuser(), self.cp_num)
        self.due_date = due_date
        self.source_reminder = source_reminder
        self.notes = os.path.join(self.tmp_dir, '%s-cp%d.notes' % (self.andrewid, self.cp_num))
        self.results = os.path.join(self.tmp_dir, '%s-cp%d.results' % (self.andrewid, self.cp_num))
        check_both('rm %s' % self.notes, False, False)
        check_both('rm %s' % self.results, False, False)

        # set where we want resources to *end up*; then copy them there
        self.priv_key = os.path.join(self.tmp_dir, 'grader.key')
        self.cert = os.path.join(self.tmp_dir, 'grader.crt')
        self.www = os.path.join(self.tmp_dir, 'www/')
        self.cgi = os.path.join(self.tmp_dir, 'cgi/cgi_script.py')
 def run_lisod(self, tree):
     path = self.get_path()
     liso = self.liso_name()
     port = self.get_port()
     tls_port = self.get_tls_port()
     if not path: path = self.find_path('Makefile', tree)
     print 'switching to: %s' % path
     os.chdir(path)
     check_both('make clean', False, False)
     check_output('make')
     self.ran = True
     resource.setrlimit(resource.RLIMIT_STACK, (resource.RLIM_INFINITY, resource.RLIM_INFINITY))
     cmd = '%s %d %d %slisod.log %slisod.lock %s %s %s %s&' % (liso, port, tls_port, self.grader.tmp_dir, self.grader.tmp_dir, self.grader.www[:-1], self.grader.cgi, self.grader.priv_key, self.grader.cert)
     #cmd = 'nohup ' + cmd
     #cmd = cmd + " > /dev/null"
     print cmd
     self.pAssertEqual(0, os.system(cmd))
     return liso
    def __init__(self, andrewid, cp_num, due_date, source_reminder):
        self.andrewid = andrewid
        self.cp_num = cp_num
        self.root_repo = ROOT_REPO_TEMPLATE % (andrewid, andrewid)
        self.tmp_dir = '/tmp/%s/cp%d/' % (getpass.getuser(), self.cp_num)
        self.due_date = due_date
        self.source_reminder = source_reminder
        self.notes = os.path.join(
            self.tmp_dir, '%s-cp%d.notes' % (self.andrewid, self.cp_num))
        self.results = os.path.join(
            self.tmp_dir, '%s-cp%d.results' % (self.andrewid, self.cp_num))
        check_both('rm %s' % self.notes, False, False)
        check_both('rm %s' % self.results, False, False)

        # set where we want resources to *end up*; then copy them there
        self.priv_key = os.path.join(self.tmp_dir, 'grader.key')
        self.cert = os.path.join(self.tmp_dir, 'grader.crt')
        self.www = os.path.join(self.tmp_dir, 'www/')
        self.cgi = os.path.join(self.tmp_dir, 'cgi/cgi_script.py')
 def run_lisod(self, tree):
     path = self.get_path()
     liso = self.liso_name()
     port = self.get_port()
     tls_port = self.get_tls_port()
     if not path: path = self.find_path('Makefile', tree)
     print 'switching to: %s' % path
     os.chdir(path)
     check_both('make clean', False, False)
     check_output('make')
     self.ran = True
     resource.setrlimit(resource.RLIMIT_STACK,
                        (resource.RLIM_INFINITY, resource.RLIM_INFINITY))
     cmd = '%s %d %d %slisod.log %slisod.lock %s %s %s %s&' % (
         liso, port, tls_port, self.grader.tmp_dir, self.grader.tmp_dir,
         self.grader.www[:-1], self.grader.cgi, self.grader.priv_key,
         self.grader.cert)
     #cmd = 'nohup ' + cmd
     #cmd = cmd + " > /dev/null"
     print cmd
     self.pAssertEqual(0, os.system(cmd))
     return liso
 def edit_notes(self, new_note):
     notef = self.grader.notes
     try:
         check_both('cat %s' % (notef), False)
         new_note = '\n' + new_note
     except:
         pass
     check_both('echo "%s\nGood." >> %s' % (new_note, notef), False)
     check_both('%s %s' % (self.grader.editor, notef))
    def test_replays(self):
        self.print_str('\n\n----- Testing Replays -----')
        commit = self.resolve_tag()
        self.run_lisod(commit.tree)
        time.sleep(3)
        replays_dir = os.path.join(self.grader.tmp_dir, 'replays')
        if not os.path.exists(replays_dir):
            os.makedirs(replays_dir)
        files = os.listdir(replays_dir)
        num_passed = 0
        num_files = 0
        for fname in files:
            basename, extension = os.path.splitext(fname)
            if extension == '.test':
                num_files += 1
                self.print_str('testing %s...' % fname)
                fname = os.path.join(self.grader.tmp_dir + 'replays', fname)
                outfile = os.path.join(self.grader.tmp_dir + 'replays',
                                       '%s_%s.out' % (basename, self.repo))
                command = 'ncat -i 1s localhost %d < %s > %s' % (
                    self.port, fname, outfile)

                check_both(command, False, False)
                with open(
                        os.path.join(self.grader.tmp_dir + 'replays',
                                     basename + '.out')) as f:
                    with open(outfile) as f2:
                        outhash = hashlib.sha256(f.read()).hexdigest()
                        out2hash = hashlib.sha256(f2.read()).hexdigest()
                        if outhash == out2hash:
                            self.print_str('ok')
                            num_passed += 1
                        else:
                            self.print_str('failed')
                check_both('rm %s' % outfile)
        self.print_str('passed %d of %d' % (num_passed, num_files))
        self.pAssertEqual(num_passed, num_files)
 def edit_notes(self, new_note):
     notef = self.grader.notes
     try:
         check_both('cat %s' % (notef), False)
         new_note = '\n'+new_note
     except:
         pass
     check_both('echo "%s\nGood." >> %s' % (new_note, notef), False)
     check_both('%s %s' % (self.grader.editor,notef))
 def tearDown(self):
     #check_both('rm ' + self.grader.tmp_dir + 'lisod.log', False, False)
     check_both('rm ' + self.grader.tmp_dir + 'lisod.lock', False, False)
     os.chdir(self.grader.tmp_dir)
     shutil.rmtree(self.repo)
     if sys.exc_info() == (None, None, None): #test succeeded
         self.out_string += '\nok'
     else:
         self.out_string += '\nfailed'
     if self.out_string:
         check_both('echo "%s" >> %s' % (self.out_string, self.grader.results))
     if self.ran:
         print 'trying "killall -9 %s"' % os.path.basename(self.liso_name)
         check_both('killall -9 %s' % os.path.basename(self.liso_name), True, False)
 def tearDown(self):
     #check_both('rm ' + self.grader.tmp_dir + 'lisod.log', False, False)
     check_both('rm ' + self.grader.tmp_dir + 'lisod.lock', False, False)
     os.chdir(self.grader.tmp_dir)
     shutil.rmtree(self.repo)
     if sys.exc_info() == (None, None, None):  #test succeeded
         self.out_string += '\nok'
     else:
         self.out_string += '\nfailed'
     if self.out_string:
         check_both('echo "%s" >> %s' %
                    (self.out_string, self.grader.results))
     if self.ran:
         print 'trying "killall -9 %s"' % os.path.basename(self.liso_name)
         check_both('killall -9 %s' % os.path.basename(self.liso_name),
                    True, False)
#!/usr/bin/env python

import sys
sys.path.append('../common/')

from plcommon import check_both


andrewids = open('../common/andrewids').read().split('\n')[:-1]
for a in andrewids:
    print a
    check_both("./get_replays.sh %s" % a)

Example #13
0
#!/usr/bin/env python

import sys
import os
sys.path.append('../common/')

from plcommon import check_both

CP_NUM = 2
NOTES_DIR = './notes'
RESULTS_DIR = './results'
GRADES_DIR = './grades'

andrewids = open('../common/andrewids').read().split('\n')[:-1]

if len(sys.argv) > 1:
    andrewids = [sys.argv[1]]

for a in andrewids:
    print a
    check_both("./move_grades.sh %s %d %s %s %s" %
               (a, CP_NUM, NOTES_DIR, RESULTS_DIR, GRADES_DIR))
#!/usr/bin/env python

import sys
import os
sys.path.append('../common/')

from plcommon import check_both

CP_NUM = 2
NOTES_DIR = './notes'
RESULTS_DIR = './results'
GRADES_DIR = './grades'

andrewids = open('../common/andrewids').read().split('\n')[:-1]

if len(sys.argv) > 1:
    andrewids = [sys.argv[1]]

for a in andrewids:
    print a
    check_both("./move_grades.sh %s %d %s %s %s" % (a, CP_NUM, NOTES_DIR, RESULTS_DIR, GRADES_DIR))
 def test_make(self):
     #if self.testsuite.scores['test_git'] <= 0:
     #    self.skipTest("Not a git repo, skip rest of the test.")
     check_both('make clean', False, False)
     check_output('make')
     self.testsuite.scores['test_make'] = 1
 def test_git(self):
     check_both(GIT_TAG)
     check_both(GIT_SWITCH_TAG % self.testsuite.checkpoint)
     self.testsuite.scores['test_git'] = 1
     return
#!/usr/bin/env python

import sys
sys.path.append('../common/')

from plcommon import check_both

ANDREW_PATH = '/afs/andrew/course/15/441-641/'
REPO_NAME = '-15-441-project-1/.git/'
BARE_REPO_NAME = '-15-441-project-1/branches/'

out = check_both('ls -la %s' % ANDREW_PATH, False)[0][0].split('\n')[3:-1]
out = [o.split(' ')[-1] for o in out]

i = 0
j = 0
k = 0
for o in out:
    try:
        check_both('ls -la %s%s/%s%s' % (ANDREW_PATH, o, o, REPO_NAME), False)
        print o
        i += 1
    except:
        try:
            check_both('ls -la %s%s/%s%s' % (ANDREW_PATH, o, o, BARE_REPO_NAME), False)
            i += 1
        except:
            o2 = check_both('ls -la %s%s' % (ANDREW_PATH, o), False)[0][0].split('\n')[3:-1]
            if not o2:
                j += 1
            else:
Example #18
0
#!/usr/bin/env python

import sys
sys.path.append('../common/')

from plcommon import check_both

ANDREW_PATH = '/afs/andrew/course/15/441-641/'
REPO_NAME = '-15-441-project-1/.git/'
BARE_REPO_NAME = '-15-441-project-1/branches/'

out = check_both('ls -la %s' % ANDREW_PATH, False)[0][0].split('\n')[3:-1]
out = [o.split(' ')[-1] for o in out]

i = 0
j = 0
k = 0
for o in out:
    try:
        check_both('ls -la %s%s/%s%s' % (ANDREW_PATH, o, o, REPO_NAME), False)
        print o
        i += 1
    except:
        try:
            check_both(
                'ls -la %s%s/%s%s' % (ANDREW_PATH, o, o, BARE_REPO_NAME),
                False)
            i += 1
        except:
            o2 = check_both('ls -la %s%s' % (ANDREW_PATH, o),
                            False)[0][0].split('\n')[3:-1]