2021-12-08 17:21:16 +00:00
|
|
|
dofile( 'tests/testlib.lua' )
|
|
|
|
|
|
|
|
cwriteln( '****************************************************************' )
|
|
|
|
cwriteln( ' Testing Utils Functions ' )
|
|
|
|
cwriteln( '****************************************************************' )
|
|
|
|
|
|
|
|
assert(isTableEqual(
|
|
|
|
splitQuotedString("-p 22 -i '/home/test/bla blu/id_rsa'"),
|
|
|
|
{"-p", "22", "-i", "/home/test/bla blu/id_rsa"}
|
|
|
|
))
|
|
|
|
|
2022-03-16 16:38:03 +00:00
|
|
|
-- test string replacement
|
|
|
|
local testData = {
|
|
|
|
localPort = 1234,
|
|
|
|
localHost = "localhorst"
|
|
|
|
}
|
Implement tunnel pool mode.
In this mode, multiple tunnel processes are started and connection a load
balanced on the pool of connections.
Example config:
...
sync {
default.rsync,
tunnel = tunnel {
command = {"ssh", "-N", "-L", "localhost:${localport}:localhost:873", "user@testmachine"},
mode = "pool",
parallel = 2,
},
target = "rsync://localhost:${localport}/test",
...
}
2022-03-23 22:44:19 +00:00
|
|
|
assert(substitudeCommands("echo ssh ${localHost}:${localPort}", testData) ==
|
2022-03-16 16:38:03 +00:00
|
|
|
"echo ssh localhorst:1234")
|
|
|
|
|
|
|
|
assert(isTableEqual(
|
Implement tunnel pool mode.
In this mode, multiple tunnel processes are started and connection a load
balanced on the pool of connections.
Example config:
...
sync {
default.rsync,
tunnel = tunnel {
command = {"ssh", "-N", "-L", "localhost:${localport}:localhost:873", "user@testmachine"},
mode = "pool",
parallel = 2,
},
target = "rsync://localhost:${localport}/test",
...
}
2022-03-23 22:44:19 +00:00
|
|
|
substitudeCommands({"-p${doesNotExist}", "2${localHost}2", "-i '${localPort}'"}, testData),
|
2022-03-16 16:38:03 +00:00
|
|
|
{"-p", "2localhorst2", "-i '1234'"}
|
|
|
|
))
|
|
|
|
|
2022-03-17 01:26:00 +00:00
|
|
|
assert(type(lsyncd.get_free_port()) == "number")
|
|
|
|
|
2021-12-08 17:21:16 +00:00
|
|
|
os.exit(0)
|