Skip to content

Commit 841a313

Browse files
committed
Added acceptance test for immutable with copy_from
Ticket: ENT-10961, CFE-1840 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 5b13fea commit 841a313

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
##############################################################################
2+
#
3+
# Test that agent can override the immutable bit when using copy_from
4+
# attribute
5+
#
6+
##############################################################################
7+
8+
body common control
9+
{
10+
inputs => { "../../default.cf.sub" };
11+
bundlesequence => { default("$(this.promise_filename)") };
12+
version => "1.0";
13+
}
14+
15+
bundle agent global
16+
{
17+
vars:
18+
"testfile"
19+
string => "/tmp/03_immutable.txt";
20+
}
21+
22+
body fsattrs set_immutable
23+
{
24+
immutable => "true";
25+
}
26+
27+
bundle agent init
28+
{
29+
files:
30+
"$(global.testfile)"
31+
content => "I'm immutable";
32+
"/tmp/content.txt"
33+
content => "But agent can override";
34+
35+
commands:
36+
"chattr +i $(global.testfile)"
37+
contain => in_shell;
38+
}
39+
40+
bundle agent test
41+
{
42+
meta:
43+
"description" -> { "CFE-1840", "ENT-10961" }
44+
string => "Test that agent can override the immutable bit on a file while using the copy_from attribute";
45+
46+
"test_skip_unsupported"
47+
string => "hpux|aix|solaris|windows";
48+
49+
files:
50+
"$(global.testfile)"
51+
fsattrs => set_immutable,
52+
copy_from => local_dcp("/tmp/content.txt");
53+
}
54+
55+
bundle agent check
56+
{
57+
vars:
58+
"expected"
59+
string => "But agent can override";
60+
"actual"
61+
string => readfile("$(global.testfile)");
62+
63+
classes:
64+
"ok"
65+
expression => strcmp("$(actual)", "$(expected)");
66+
67+
reports:
68+
ok::
69+
"$(this.promise_filename) Pass";
70+
!ok::
71+
"$(this.promise_filename) FAIL";
72+
any::
73+
"Expected: '$(expected)', actual: '$(actual)'";
74+
}
75+
76+
bundle agent destroy
77+
{
78+
commands:
79+
"chattr -i $(global.testfile)"
80+
contain => in_shell,
81+
handle => "is mutable";
82+
83+
files:
84+
"$(global.testfile)"
85+
delete => tidy,
86+
depends_on => { "is mutable" };
87+
"$(global.testfile).cfsaved"
88+
delete => tidy;
89+
"/tmp/content.txt"
90+
delete => tidy;
91+
}

0 commit comments

Comments
 (0)