Commit 18d5356a authored by Michael Terry's avatar Michael Terry

tests: add quiescent test

parent 5cbca4bf
......@@ -30,6 +30,7 @@ AUTO_TESTS = \
backup/full \
backup/mkdir \
backup/permissions \
backup/quiescent \
backup/spaces \
backup/symlinks \
basic/badversion \
......
......@@ -24,12 +24,12 @@ import sys
sys.path.insert(0, sys.path[0]+'/..')
import base
import ldtp
import time
def wait_for_volume(destdir):
count = 0
while len(os.listdir(destdir)) < 2 and count < 200:
print count, os.listdir(destdir)
ldtp.wait(1)
time.sleep(1)
count += 1
assert count < 200
......@@ -40,16 +40,16 @@ def test():
wait_for_volume(destdir)
ldtp.click('frmBackUp', 'btnCancel')
base.backup_simple(finish=False, encrypt=False)
ldtp.wait(5)
time.sleep(5)
ldtp.click('frmBackUp', 'btnCancel')
base.backup_simple(finish=False, encrypt=False)
ldtp.wait(4)
time.sleep(4)
ldtp.click('frmBackUp', 'btnCancel')
base.backup_simple(finish=False, encrypt=False)
wait_for_volume(destdir)
ldtp.click('frmBackUp', 'btnCancel')
base.backup_simple(finish=False, encrypt=False)
ldtp.wait(7)
time.sleep(7)
ldtp.click('frmBackUp', 'btnCancel')
base.run(test)
#!/usr/bin/env python
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 2; coding: utf-8 -*-
#
# This file is part of Déjà Dup.
# For copyright information, see AUTHORS.
#
# Déjà Dup is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Déjà Dup is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
# Test how well we handle user mucking with files while we back up
import sys
import os
sys.path.insert(0, sys.path[0]+'/..')
import base
import ldtp
import time
import re
last_written = 'a'
def rewrite(name, size):
global last_written
f = open(name, 'wb')
string = ('{:%s<%d}' % (last_written, size)).format('')
f.write(string)
f.close()
last_written = chr(ord(last_written) + 1) if last_written != 'z' else 'a'
def keep_writing(destdir, sourcename):
count = 0
rewrite(sourcename, 30 * 1024 * 1024)
assert ldtp.waittillguiexist('frmBackUp')
while ldtp.guiexist('frmBackUp'):
rewrite(sourcename, 30 * 1024 * 1024)
count += 1
assert count < 200
def wait_for_volume(destdir):
count = 0
while len(os.listdir(destdir)) < 2 and count < 200:
time.sleep(1)
count += 1
def writing():
global last_written
last_written = 'a'
base.setup()
sourcedir = base.get_temp_name('source')
os.makedirs(sourcedir)
sourcefile = os.path.join(sourcedir, 'file')
base.backup_simple(backend='file', includes=[sourcedir], finish=False)
destdir = base.get_temp_name('local')
keep_writing(destdir, sourcefile)
restoredir = base.get_temp_name('restore')
restorefile = os.path.join(restoredir, './'+sourcefile)
base.restore_simple(restoredir)
# make sure that whatever version of the file got written, got written complete
f = open(restorefile, 'rb')
string = f.read()
f.close()
assert re.match('^%c+$' % string[0], string), string[0:1024]
def pause_before():
global last_written
last_written = 'a'
base.setup()
sourcedir = base.get_temp_name('source')
os.makedirs(sourcedir)
rewrite(os.path.join(sourcedir, 'a'), 20)
rewrite(os.path.join(sourcedir, 'b'), 30 * 1024 * 1024)
rewrite(os.path.join(sourcedir, 'c'), 30)
base.backup_simple(backend='file', includes=[sourcedir], finish=False)
destdir = base.get_temp_name('local')
wait_for_volume(destdir)
ldtp.click('frmBackUp', 'btnResumeLater')
rewrite(os.path.join(sourcedir, 'a'), 20)
base.backup_simple()
restoredir = base.get_temp_name('restore')
restorefile = os.path.join(restoredir, './'+sourcedir, 'a')
base.restore_simple(restoredir)
f = open(restorefile, 'rb')
string = f.read()
f.close()
assert len(string) == 20, string
assert re.match('^d+$', string), string
def pause_middle():
global last_written
last_written = 'a'
base.setup()
sourcedir = base.get_temp_name('source')
os.makedirs(sourcedir)
rewrite(os.path.join(sourcedir, 'a'), 20)
rewrite(os.path.join(sourcedir, 'b'), 30 * 1024 * 1024)
rewrite(os.path.join(sourcedir, 'c'), 30)
base.backup_simple(backend='file', includes=[sourcedir], finish=False)
destdir = base.get_temp_name('local')
wait_for_volume(destdir)
ldtp.click('frmBackUp', 'btnResumeLater')
rewrite(os.path.join(sourcedir, 'b'), 30 * 1024 * 1024)
base.backup_simple()
restoredir = base.get_temp_name('restore')
restorefile = os.path.join(restoredir, './'+sourcedir, 'b')
base.restore_simple(restoredir)
f = open(restorefile, 'rb')
string = f.read()
f.close()
assert len(string) == 30 * 1024 * 1024, string[0:1024]
assert re.match('^d+$', string), string[0:1024]
base.run(writing)
base.run(pause_before)
base.run(pause_middle)
......@@ -431,7 +431,7 @@ def walk_prefs(backend, dest, includes, excludes):
ldtp.settextvalue('frmBackup', 'txt0', dest) # FIXME txt0 is bad name
ldtp.wait(1) # without this, sometimes ldtp moves so fast, deja-dup doesn't notice dest
ldtp.selectrow('frmBackup', 'tblCategories', 'Files')
ldtp.selectrow('frmBackup', 'tblCategories', 'Folders')
if includes is not None:
set_file_list('frmBackup', 'tblIncludeList', 'btnIncludeListAdd', 'btnIncludeListRemove', includes)
if excludes is not None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment