Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
3ad61ef3
Commit
3ad61ef3
authored
Oct 14, 2013
by
Paul Sokolovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copy: Add testcase for recursive copy.
parent
2e668f14
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
154 additions
and
0 deletions
+154
-0
test/TestPlayBook.py
+17
-0
test/playbook-recursive-copy.yml
+133
-0
test/test_recursive_copy/files/subdir/subdir2/subdir3/test1
+2
-0
test/test_recursive_copy/files/subdir/subdir2/subdir3/test2
+2
-0
No files found.
test/TestPlayBook.py
View file @
3ad61ef3
...
@@ -393,6 +393,23 @@ class TestPlaybook(unittest.TestCase):
...
@@ -393,6 +393,23 @@ class TestPlaybook(unittest.TestCase):
assert
utils
.
jsonify
(
expected
,
format
=
True
)
==
utils
.
jsonify
(
actual
,
format
=
True
)
assert
utils
.
jsonify
(
expected
,
format
=
True
)
==
utils
.
jsonify
(
actual
,
format
=
True
)
def
test_recursive_copy
(
self
):
pb
=
'test/playbook-recursive-copy.yml'
actual
=
self
.
_run
(
pb
)
expected
=
{
"localhost"
:
{
"changed"
:
65
,
"failures"
:
0
,
"ok"
:
73
,
"skipped"
:
0
,
"unreachable"
:
0
}
}
assert
utils
.
jsonify
(
expected
,
format
=
True
)
==
utils
.
jsonify
(
actual
,
format
=
True
)
def
_compare_file_output
(
self
,
filename
,
expected_lines
):
def
_compare_file_output
(
self
,
filename
,
expected_lines
):
actual_lines
=
[]
actual_lines
=
[]
with
open
(
filename
)
as
f
:
with
open
(
filename
)
as
f
:
...
...
test/playbook-recursive-copy.yml
0 → 100644
View file @
3ad61ef3
---
# To run me manually, use: -i "localhost,"
-
hosts
:
localhost
connection
:
local
gather_facts
:
no
vars
:
-
testdir
:
/tmp/ansible-rcopy
-
filesdir
:
test_recursive_copy/files
tasks
:
#
# First, regression tests for single-file behavior
#
-
name
:
"
src
single
file,
dest
file"
command
:
rm -rf {{testdir}}
-
file
:
state=directory dest={{testdir}}
-
copy
:
src={{filesdir}}/subdir/subdir2/subdir3/test1 dest={{testdir}}/file1
register
:
res
-
command
:
test -f {{testdir}}/file1
-
command
:
test "{{res.changed}}" == "True"
-
copy
:
src={{filesdir}}/subdir/subdir2/subdir3/test1 dest={{testdir}}/file1
register
:
res
-
command
:
test "{{res.changed}}" == "False"
-
name
:
"
src
single
file,
dest
dir
w/trailing
slash"
command
:
rm -rf {{testdir}}
-
file
:
state=directory dest={{testdir}}
-
copy
:
src={{filesdir}}/subdir/subdir2/subdir3/test1 dest={{testdir}}/
register
:
res
-
command
:
test -f {{testdir}}/test1
-
command
:
test "{{res.changed}}" == "True"
-
copy
:
src={{filesdir}}/subdir/subdir2/subdir3/test1 dest={{testdir}}/
register
:
res
-
command
:
test "{{res.changed}}" == "False"
-
name
:
"
src
single
file,
dest
dir
wo/trailing
slash
-
doesn't
behave
in
sane
way"
command
:
rm -rf {{testdir}}
-
file
:
state=directory dest={{testdir}}
-
copy
:
src={{filesdir}}/subdir/subdir2/subdir3/test1 dest={{testdir}}
register
:
res
-
shell
:
test -f {{testdir}}/test1
-
command
:
test "{{res.changed}}" == "True"
-
copy
:
src={{filesdir}}/subdir/subdir2/subdir3/test1 dest={{testdir}}
register
:
res
-
command
:
test "{{res.changed}}" == "False"
#
# Now, test recursive behavior
#
-
name
:
"
src
dir
w/trailing
slash,
dest
w/trailing
slash"
command
:
rm -rf {{testdir}}
-
file
:
state=directory dest={{testdir}}
-
copy
:
src={{filesdir}}/subdir/ dest={{testdir}}/
register
:
res
-
command
:
test -d {{testdir}}/subdir2
-
command
:
test -d {{testdir}}/subdir2/subdir3
-
command
:
test -d {{testdir}}/subdir2/subdir3
-
command
:
test -f {{testdir}}/subdir2/subdir3/test1
-
command
:
test -f {{testdir}}/subdir2/subdir3/test2
-
command
:
test "{{res.changed}}" == "True"
-
copy
:
src={{filesdir}}/subdir/ dest={{testdir}}/
register
:
res
-
command
:
test "{{res.changed}}" == "False"
# Expecting the same behavior
-
name
:
"
src
dir
w/trailing
slash,
dest
wo/trailing
slash"
command
:
rm -rf {{testdir}}
-
file
:
state=directory dest={{testdir}}
-
copy
:
src={{filesdir}}/subdir/ dest={{testdir}}
register
:
res
-
command
:
test -d {{testdir}}/subdir2
-
command
:
test -d {{testdir}}/subdir2/subdir3
-
command
:
test -d {{testdir}}/subdir2/subdir3
-
command
:
test -f {{testdir}}/subdir2/subdir3/test1
-
command
:
test -f {{testdir}}/subdir2/subdir3/test2
-
command
:
test "{{res.changed}}" == "True"
-
copy
:
src={{filesdir}}/subdir/ dest={{testdir}}
register
:
res
-
command
:
test "{{res.changed}}" == "False"
-
name
:
"
src
dir
wo/trailing
slash,
dest
w/trailing
slash"
command
:
rm -rf {{testdir}}
-
file
:
state=directory dest={{testdir}}
-
copy
:
src={{filesdir}}/subdir dest={{testdir}}/
register
:
res
-
command
:
test -d {{testdir}}/subdir/subdir2
-
command
:
test -d {{testdir}}/subdir/subdir2/subdir3
-
command
:
test -d {{testdir}}/subdir/subdir2/subdir3
-
command
:
test -f {{testdir}}/subdir/subdir2/subdir3/test1
-
command
:
test -f {{testdir}}/subdir/subdir2/subdir3/test2
-
command
:
test "{{res.changed}}" == "True"
-
copy
:
src={{filesdir}}/subdir dest={{testdir}}/
register
:
res
-
command
:
test "{{res.changed}}" == "False"
# Expecting the same behavior
-
name
:
"
src
dir
wo/trailing
slash,
dest
wo/trailing
slash"
command
:
rm -rf {{testdir}}
-
file
:
state=directory dest={{testdir}}
-
copy
:
src={{filesdir}}/subdir dest={{testdir}}
register
:
res
-
command
:
test -d {{testdir}}/subdir/subdir2
-
command
:
test -d {{testdir}}/subdir/subdir2/subdir3
-
command
:
test -d {{testdir}}/subdir/subdir2/subdir3
-
command
:
test -f {{testdir}}/subdir/subdir2/subdir3/test1
-
command
:
test -f {{testdir}}/subdir/subdir2/subdir3/test2
-
command
:
test "{{res.changed}}" == "True"
-
copy
:
src={{filesdir}}/subdir dest={{testdir}}
register
:
res
-
command
:
test "{{res.changed}}" == "False"
-
name
:
"
Verifying
notify
handling
for
recursive
files"
command
:
rm -rf {{testdir}}
-
file
:
state=directory dest={{testdir}}
-
copy
:
src={{filesdir}}/subdir dest={{testdir}}
notify
:
-
files changed
-
meta
:
flush_handlers
-
command
:
test -f {{testdir}}/notify_fired
-
command
:
rm {{testdir}}/notify_fired
-
copy
:
src={{filesdir}}/subdir dest={{testdir}}
notify
:
-
files changed
-
meta
:
flush_handlers
-
command
:
test ! -f {{testdir}}/notify_fired
handlers
:
-
name
:
files changed
command
:
touch {{testdir}}/notify_fired
test/test_recursive_copy/files/subdir/subdir2/subdir3/test1
0 → 100644
View file @
3ad61ef3
test1
test/test_recursive_copy/files/subdir/subdir2/subdir3/test2
0 → 100644
View file @
3ad61ef3
test2
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment