From b030d4b898b626dbcecc59569108fcaba24e089b Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Sat, 30 Jun 2018 20:42:53 +0200 Subject: [PATCH] cleanups, tests adaption --- default/rsyncssh.lua | 19 +++++-------------- mantle/delay.lua | 2 -- mantle/sync.lua | 24 ++++++------------------ tests/churn-rsync.lua | 12 ++++++++---- tests/churn-rsyncssh.lua | 17 +++++++++-------- 5 files changed, 28 insertions(+), 46 deletions(-) diff --git a/default/rsyncssh.lua b/default/rsyncssh.lua index abf1cdd..c53dd21 100644 --- a/default/rsyncssh.lua +++ b/default/rsyncssh.lua @@ -15,20 +15,11 @@ -- -- -if not default -then - error( 'default not loaded' ); -end +if not default then error( 'default not loaded' ); end -if not default.rsync -then - error( 'default.rsync not loaded' ); -end +if not default.rsync then error( 'default.rsync not loaded' ); end -if default.rsyncssh -then - error( 'default-rsyncssh already loaded' ); -end +if default.rsyncssh then error( 'default-rsyncssh already loaded' ); end -- -- rsyncssh extends default.rsync @@ -360,7 +351,7 @@ rsyncssh.collect = function if not agent.isList and agent.etype == 'Init' then - local rc = config.rsyncExitCodes[exitcode] + local rc = config.rsyncExitCodes[ exitcode ] if rc == 'ok' then @@ -570,7 +561,7 @@ rsyncssh.exitcodes = false -- -- rsync exit codes -- -rsyncssh.rsyncExitCodes = default.rsync.exitCodes +rsyncssh.rsyncExitCodes = default.rsync.exitcodes -- -- Exitcodes of ssh and what to do. diff --git a/mantle/delay.lua b/mantle/delay.lua index 2eef985..709d846 100644 --- a/mantle/delay.lua +++ b/mantle/delay.lua @@ -36,8 +36,6 @@ local assignable = { dpos = true, etype = true, - path = true, - path2 = true, status = true, } diff --git a/mantle/sync.lua b/mantle/sync.lua index a334ae2..6c05b0e 100644 --- a/mantle/sync.lua +++ b/mantle/sync.lua @@ -183,15 +183,9 @@ local function collect alarm = now() + alarm - for _, d in ipairs( delay ) - do - d:wait( alarm ) - end + for _, d in ipairs( delay ) do d:wait( alarm ) end else - for _, d in ipairs( delay ) - do - removeDelay( self, d ) - end + for _, d in ipairs( delay ) do removeDelay( self, d ) end end log( 'Delay','Finished list = ',exitcode ) @@ -368,10 +362,7 @@ local function delay ' event.' ) - if #self.delays > 0 - then - stack( self.delays:last( ), nd ) - end + if #self.delays > 0 then stack( self.delays:last( ), nd ) end nd.dpos = self.delays:push( nd ) @@ -528,10 +519,7 @@ local function getDelays do local tr = true - if test - then - tr = test( InletFactory.d2e( d ) ) - end + if test then tr = test( InletFactory.d2e( d ) ) end if tr == 'break' then break end @@ -860,10 +848,10 @@ local function new -- since this way it will raise any issues of mindelay or delay -- not being numbers as well - if not ( config.mindelay >= config.delay ) + if not ( config.mindelay <= config.delay ) then error( - 'mindelay (= '..config.mindelay.. ') must be larger '.. + 'mindelay (= '..config.mindelay.. ') must be smaller '.. 'or equal than delay (= '..config.delay..')', level ) diff --git a/tests/churn-rsync.lua b/tests/churn-rsync.lua index 28d3ac9..0bc9200 100644 --- a/tests/churn-rsync.lua +++ b/tests/churn-rsync.lua @@ -16,9 +16,13 @@ churn( srcdir, 100, true ) local logs = { } local pid = spawn( './lsyncd', - '-nodaemon', - '-delay', '5', - '-rsync', srcdir, trgdir, + '-c', + 'sync{ ' + .. 'default.rsync, ' + .. 'delay = 5, ' + .. 'source = "'..srcdir..'", ' + .. 'target = "'..trgdir..'" ' + .. '}', table.unpack( logs ) ) @@ -26,7 +30,7 @@ cwriteln( 'waiting for Lsyncd to startup' ) posix.sleep( 1 ) -churn( srcdir, 500, false ) +churn( srcdir, 100, false ) cwriteln( 'waiting for Lsyncd to finish its jobs.' ) diff --git a/tests/churn-rsyncssh.lua b/tests/churn-rsyncssh.lua index 379dbbb..dacbe88 100644 --- a/tests/churn-rsyncssh.lua +++ b/tests/churn-rsyncssh.lua @@ -21,20 +21,21 @@ logs = { '-log', 'Delay' } local pid = spawn( './lsyncd', - '-nodaemon', - '-delay', - '5', - '-rsyncssh', - srcdir, - 'localhost', - trgdir, + '-c', + 'sync{ ' + .. 'default.rsyncssh, ' + .. 'delay = 5, ' + .. 'source = "'..srcdir..'", ' + .. 'host = "localhost", ' + .. 'targetdir = "'..trgdir..'" ' + .. '}', table.unpack(logs) ) cwriteln( 'waiting for Lsyncd to startup' ) posix.sleep( 1 ) -churn( srcdir, 150, false ) +churn( srcdir, 100, false ) cwriteln( 'waiting for Lsyncd to finish its jobs.' ) posix.sleep( 10 )