def testCameraSync(): print "---- testCameraSync ----" cam_files = 'cam_files' testrootpath = conf.testrootpath[conf.targetos] testUtils.subscribe(target1, camDatasetUp) testUtils.subscribe(target2, camDatasetDn) print 'target1 [%s] adding photos' % target1 print "Creating golden test files" url = '%s:%s/%s/%s.tar.gz' % (goldenDataHost, httpPort, goldenDataPath, cam_files) testUtils.remoteRun( target1, 'cd %s; wget --progress=dot:mega -O - %s | tar xzvf -' % (testrootpath, url)) testUtils.remoteRun( target2, 'cd %s; wget --progress=dot:mega -O - %s | tar xzvf -' % (testrootpath, url)) # Bug 9181 means simply copying the files into the datast directory that one could end up with partial files since the immediate file update may not advance the timestamp. testUtils.remoteRun( target1, 'cd %s; cp -Rf %s/* %s/\"%s\"' % (testrootpath, cam_files, conf.cloudRoot(True), camDatasetUp)) time.sleep(3) testUtils.ccdWaitUntilInSync(target1, camDatasetUp) time.sleep(3) testUtils.ccdWaitUntilInSync(target2, camDatasetDn) time.sleep(3) testUtils.ccdWaitUntilInSync(target1, camDatasetUp) print 'target2 [%s] verifying photos' % target2 testdiff = conf.logdir + '/' + 'target2_cam.diff' testUtils.remoteRun( target2, 'rm -Rf %s/\"%s\"/%s' % (conf.cloudRoot(True), camDatasetDn, manifestDir)) testUtils.remoteRunAndLog( target2, 'cd %s; diff -r %s/\"%s\" %s --exclude=\".sync_temp\"' % (testrootpath, conf.cloudRoot(True), camDatasetDn, cam_files), testdiff) try: st = os.stat('%s' % testdiff) except (IOError, RuntimeError, OSError): print "Error: checking cam dataset diff %s" % testdiff return False else: if st.st_size > 0: print "Error: %s \"%s\" content mismatch" % (target2, camDatasetDn) return False return True
def testCameraSync(): print "---- testCameraSync ----" cam_files = 'cam_files' testrootpath = conf.testrootpath[conf.targetos] testUtils.subscribe(target1, camDatasetUp) testUtils.subscribe(target2, camDatasetDn) print 'target1 [%s] adding photos' % target1 print "Creating golden test files" url = '%s:%s/%s/%s.tar.gz' % (goldenDataHost, httpPort, goldenDataPath, cam_files) testUtils.remoteRun(target1, 'cd %s; wget --progress=dot:mega -O - %s | tar xzvf -' % (testrootpath, url)) testUtils.remoteRun(target2, 'cd %s; wget --progress=dot:mega -O - %s | tar xzvf -' % (testrootpath, url)) # Bug 9181 means simply copying the files into the datast directory that one could end up with partial files since the immediate file update may not advance the timestamp. testUtils.remoteRun(target1, 'cd %s; cp -Rf %s/* %s/\"%s\"' % (testrootpath, cam_files, conf.cloudRoot(True), camDatasetUp)) time.sleep(3) testUtils.ccdWaitUntilInSync(target1, camDatasetUp) time.sleep(3) testUtils.ccdWaitUntilInSync(target2, camDatasetDn) time.sleep(3) testUtils.ccdWaitUntilInSync(target1, camDatasetUp) print 'target2 [%s] verifying photos' % target2 testdiff = conf.logdir + '/' + 'target2_cam.diff' testUtils.remoteRun(target2, 'rm -Rf %s/\"%s\"/%s' % (conf.cloudRoot(True), camDatasetDn, manifestDir)) testUtils.remoteRunAndLog(target2, 'cd %s; diff -r %s/\"%s\" %s --exclude=\".sync_temp\"' % (testrootpath, conf.cloudRoot(True), camDatasetDn, cam_files), testdiff) try: st = os.stat('%s' % testdiff) except (IOError, RuntimeError, OSError): print "Error: checking cam dataset diff %s" % testdiff return False else: if st.st_size > 0: print "Error: %s \"%s\" content mismatch" % (target2, camDatasetDn) return False return True
def testSimulSync(): print "---- testSimulSync ----" testrootpath = conf.testrootpath[conf.targetos] target1_files = 'target1_files' target2_files = 'target2_files' all_files = 'all_files' for dataset in normalDatasets: testUtils.subscribe(target1, dataset) testUtils.subscribe(target2, dataset) print "Creating golden test files" url = '%s:%s/%s/%s.tar.gz' % (goldenDataHost, httpPort, goldenDataPath, target1_files) testUtils.remoteRun( target1, 'cd %s; wget --progress=dot:mega -O - %s | tar xzvf -' % (testrootpath, url)) testUtils.remoteRun( target2, 'cd %s; wget --progress=dot:mega -O - %s | tar xzvf -' % (testrootpath, url)) url = '%s:%s/%s/%s.tar.gz' % (goldenDataHost, httpPort, goldenDataPath, target2_files) url = '%s:%s/%s/%s.tar.gz' % (goldenDataHost, httpPort, goldenDataPath, target2_files) testUtils.remoteRun( target1, 'cd %s; wget --progress=dot:mega -O - %s | tar xzvf -' % (testrootpath, url)) testUtils.remoteRun( target2, 'cd %s; wget --progress=dot:mega -O - %s | tar xzvf -' % (testrootpath, url)) testUtils.remoteRun( target1, 'cd %s; mkdir -p %s; cp %s/* %s; cp %s/* %s' % (testrootpath, all_files, target1_files, all_files, target2_files, all_files)) testUtils.remoteRun( target2, 'cd %s; mkdir -p %s; cp %s/* %s; cp %s/* %s' % (testrootpath, all_files, target1_files, all_files, target2_files, all_files)) print "Copying data into dataset" for dataset in normalDatasets: # Bug 9181 means simply copying the files into the datast directory that one could end up with partial files since the immediate file update may not advance the timestamp. testUtils.remoteRun( target1, 'cd %s; rm -Rf target_temp; mkdir target_temp; cp -Rf %s/* target_temp; mv target_temp/* %s/\"%s\"' % (testrootpath, target1_files, conf.cloudRoot(True), dataset)) testUtils.remoteRun( target2, 'cd %s; rm -Rf target_temp; mkdir target_temp; cp -Rf %s/* target_temp; mv target_temp/* %s/\"%s\"' % (testrootpath, target2_files, conf.cloudRoot(True), dataset)) time.sleep(3) testUtils.ccdWaitUntilInSync(target1, dataset) time.sleep(3) testUtils.ccdWaitUntilInSync(target2, dataset) time.sleep(3) testUtils.ccdWaitUntilInSync(target1, dataset) print "Checking synced files" for dataset in normalDatasets: # Check target1 testdiff1 = conf.logdir + '/' + 'target1.diff' testUtils.remoteRun( target1, 'rm -Rf %s/\"%s\"/%s' % (conf.cloudRoot(True), dataset, manifestDir)) testUtils.remoteRunAndLog( target1, 'cd %s; diff -r %s/\"%s\" %s --exclude=\".sync_temp\"' % (testrootpath, conf.cloudRoot(True), dataset, all_files), testdiff1) try: st = os.stat('%s' % testdiff1) except (IOError, RuntimeError, OSError): print "Error: checking dataset diff %s" % testdiff1 return False else: if st.st_size > 0: print "Error: %s dataset \"%s\" content mismatch" % (target1, dataset) return False # Check target2 testdiff2 = conf.logdir + '/' + 'target2.diff' testUtils.remoteRun( target2, 'rm -Rf %s/\"%s\"/%s' % (conf.cloudRoot(True), dataset, manifestDir)) testUtils.remoteRunAndLog( target2, 'cd %s; diff -r %s/\"%s\" %s --exclude=\".sync_temp\"' % (testrootpath, conf.cloudRoot(True), dataset, all_files), testdiff2) try: st = os.stat('%s' % testdiff2) except (IOError, RuntimeError, OSError): print "Error: %s checking dataset diff %s" % (target2, testdiff2) return False else: if st.st_size > 0: print "Error: %s dataset \"%s\" content mismatch" % (target2, dataset) return False return True
def testSimulSync(): print "---- testSimulSync ----" testrootpath = conf.testrootpath[conf.targetos] target1_files = 'target1_files' target2_files = 'target2_files' all_files = 'all_files' for dataset in normalDatasets: testUtils.subscribe(target1, dataset) testUtils.subscribe(target2, dataset) print "Creating golden test files" url = '%s:%s/%s/%s.tar.gz' % (goldenDataHost, httpPort, goldenDataPath, target1_files) testUtils.remoteRun(target1, 'cd %s; wget --progress=dot:mega -O - %s | tar xzvf -' % (testrootpath, url)) testUtils.remoteRun(target2, 'cd %s; wget --progress=dot:mega -O - %s | tar xzvf -' % (testrootpath, url)) url = '%s:%s/%s/%s.tar.gz' % (goldenDataHost, httpPort, goldenDataPath, target2_files) url = '%s:%s/%s/%s.tar.gz' % (goldenDataHost, httpPort, goldenDataPath, target2_files) testUtils.remoteRun(target1, 'cd %s; wget --progress=dot:mega -O - %s | tar xzvf -' % (testrootpath, url)) testUtils.remoteRun(target2, 'cd %s; wget --progress=dot:mega -O - %s | tar xzvf -' % (testrootpath, url)) testUtils.remoteRun(target1, 'cd %s; mkdir -p %s; cp %s/* %s; cp %s/* %s' % (testrootpath, all_files, target1_files, all_files, target2_files, all_files)); testUtils.remoteRun(target2, 'cd %s; mkdir -p %s; cp %s/* %s; cp %s/* %s' % (testrootpath, all_files, target1_files, all_files, target2_files, all_files)); print "Copying data into dataset" for dataset in normalDatasets: # Bug 9181 means simply copying the files into the datast directory that one could end up with partial files since the immediate file update may not advance the timestamp. testUtils.remoteRun(target1, 'cd %s; rm -Rf target_temp; mkdir target_temp; cp -Rf %s/* target_temp; mv target_temp/* %s/\"%s\"' % (testrootpath, target1_files, conf.cloudRoot(True), dataset)) testUtils.remoteRun(target2, 'cd %s; rm -Rf target_temp; mkdir target_temp; cp -Rf %s/* target_temp; mv target_temp/* %s/\"%s\"' % (testrootpath, target2_files, conf.cloudRoot(True), dataset)) time.sleep(3) testUtils.ccdWaitUntilInSync(target1, dataset) time.sleep(3) testUtils.ccdWaitUntilInSync(target2, dataset) time.sleep(3) testUtils.ccdWaitUntilInSync(target1, dataset) print "Checking synced files" for dataset in normalDatasets: # Check target1 testdiff1 = conf.logdir + '/' + 'target1.diff' testUtils.remoteRun(target1, 'rm -Rf %s/\"%s\"/%s' % (conf.cloudRoot(True), dataset, manifestDir)) testUtils.remoteRunAndLog(target1, 'cd %s; diff -r %s/\"%s\" %s --exclude=\".sync_temp\"' % (testrootpath, conf.cloudRoot(True), dataset, all_files), testdiff1) try: st = os.stat('%s' % testdiff1) except (IOError, RuntimeError, OSError): print "Error: checking dataset diff %s" % testdiff1 return False else: if st.st_size > 0: print "Error: %s dataset \"%s\" content mismatch" % (target1, dataset) return False # Check target2 testdiff2 = conf.logdir + '/' + 'target2.diff' testUtils.remoteRun(target2, 'rm -Rf %s/\"%s\"/%s' % (conf.cloudRoot(True), dataset, manifestDir)) testUtils.remoteRunAndLog(target2, 'cd %s; diff -r %s/\"%s\" %s --exclude=\".sync_temp\"' % (testrootpath, conf.cloudRoot(True), dataset, all_files), testdiff2) try: st = os.stat('%s' % testdiff2) except (IOError, RuntimeError, OSError): print "Error: %s checking dataset diff %s" % (target2, testdiff2) return False else: if st.st_size > 0: print "Error: %s dataset \"%s\" content mismatch" % (target2, dataset) return False return True