Skip to content

Commit 40a4547

Browse files
committed
Added acceptance test for immutable with transformer
Ticket: ENT-10961, CFE-1840 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 4369f2f commit 40a4547

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
##############################################################################
2+
#
3+
# Test that agent can override the immutable bit when using transformer
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/11_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+
create => "true";
32+
33+
commands:
34+
"chattr +i $(global.testfile)"
35+
contain => in_shell;
36+
}
37+
38+
bundle agent test
39+
{
40+
meta:
41+
"description" -> { "CFE-1840", "ENT-10961" }
42+
string => "Test that agent can override the immutable bit on a file while using the transformer attribute";
43+
44+
"test_skip_unsupported"
45+
string => "hpux|aix|solaris|windows";
46+
47+
vars:
48+
"gzip_path"
49+
string => ifelse(
50+
isexecutable("/bin/gzip"),
51+
"/bin/gzip",
52+
"/usr/bin/gzip"
53+
);
54+
55+
files:
56+
"$(global.testfile)"
57+
fsattrs => set_immutable,
58+
transformer => "$(gzip_path) $(this.promiser)";
59+
60+
}
61+
62+
bundle agent check
63+
{
64+
classes:
65+
"original_exists"
66+
expression => fileexists("$(global.testfile)");
67+
"transformed_exists"
68+
expression => fileexists("$(global.testfile).gz");
69+
"ok"
70+
expression => "!original_exists&transformed_exists";
71+
72+
reports:
73+
ok::
74+
"$(this.promise_filename) Pass";
75+
!ok::
76+
"$(this.promise_filename) FAIL";
77+
any::
78+
"Expected file '$(global.testfile)' to not exists $(with)"
79+
with => ifelse("!original_exists", "and it does not", "but it does");
80+
"Expected file '$(global.testfile).gz' to exists $(with)"
81+
with => ifelse("transformed_exists", "and it does", "but it does not");
82+
}
83+
84+
bundle agent destroy
85+
{
86+
commands:
87+
"chattr -i $(global.testfile)"
88+
contain => in_shell,
89+
handle => "is mutable 1",
90+
if => fileexists("$(global.testfile)");
91+
"chattr -i $(global.testfile).gz"
92+
contain => in_shell,
93+
handle => "is mutable 2",
94+
if => fileexists("$(global.testfile).gz");
95+
96+
files:
97+
"$(global.testfile)"
98+
delete => tidy,
99+
depends_on => { "is mutable 1" };
100+
files:
101+
"$(global.testfile).gz"
102+
delete => tidy,
103+
depends_on => { "is mutable 2" };
104+
}

0 commit comments

Comments
 (0)