Last active
August 29, 2015 14:13
-
-
Save neilhwatson/baad0e7723156db11d62 to your computer and use it in GitHub Desktop.
Rootwyrm_'s bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body common control | |
| { | |
| bundlesequence => { "init", "work", "check" }; | |
| } | |
| bundle agent init | |
| { | |
| vars: | |
| "contents" slist => { | |
| "root neil", | |
| "webmaster neil" | |
| }; | |
| files: | |
| "/tmp/test_src" | |
| edit_defaults => empty, | |
| create => 'true', | |
| edit_line => insert_lines( @{contents} ); | |
| } | |
| bundle agent work | |
| { | |
| files: | |
| "/tmp/test_target" | |
| create => 'true', | |
| copy_from => local_cp( "/tmp/test_src" ); | |
| } | |
| bundle agent check | |
| { | |
| vars: | |
| "target_size" int => filesize( "/tmp/test_target" ); | |
| classes: | |
| "PASS" | |
| expression => | |
| returnszero( "/usr/bin/diff /tmp/test_src /tmp/test_target", | |
| "noshell" ); | |
| "FAIL" | |
| not => | |
| returnszero( "/usr/bin/diff /tmp/test_src /tmp/test_target", | |
| "noshell" ); | |
| "FAIL" expression => strcmp( "0", "${target_size}" ); | |
| reports: | |
| PASS.!FAIL:: "PASS"; | |
| FAIL:: "FAIL"; | |
| } | |
| body edit_defaults empty | |
| { | |
| empty_file_before_editing => "true"; | |
| edit_backup => "false"; | |
| } | |
| bundle edit_line insert_lines(lines) | |
| { | |
| insert_lines: | |
| "$(lines)" | |
| comment => "Append lines if they don't exist"; | |
| } | |
| body copy_from local_cp(from) | |
| { | |
| source => "$(from)"; | |
| } | |
| Run it: | |
| neil@ettin ~/.cfagent/inputs $ cf-agent -Kf ./bug.cf | |
| 1,2d0 | |
| < root neil | |
| < webmaster neil | |
| 1,2d0 | |
| < root neil | |
| < webmaster neil | |
| 1,2d0 | |
| < root neil | |
| < webmaster neil | |
| R: FAIL | |
| Now with digest copy | |
| body common control | |
| { | |
| bundlesequence => { "init", "work", "check" }; | |
| } | |
| bundle agent init | |
| { | |
| vars: | |
| "contents" slist => { | |
| "root neil", | |
| "webmaster neil" | |
| }; | |
| files: | |
| "/tmp/test_src" | |
| edit_defaults => empty, | |
| create => 'true', | |
| edit_line => insert_lines( @{contents} ); | |
| } | |
| bundle agent work | |
| { | |
| files: | |
| "/tmp/test_target" | |
| create => 'true', | |
| copy_from => local_cp( "/tmp/test_src" ); | |
| } | |
| bundle agent check | |
| { | |
| vars: | |
| "target_size" int => filesize( "/tmp/test_target" ); | |
| classes: | |
| "PASS" | |
| expression => | |
| returnszero( "/usr/bin/diff /tmp/test_src /tmp/test_target", | |
| "noshell" ); | |
| "FAIL" | |
| not => | |
| returnszero( "/usr/bin/diff /tmp/test_src /tmp/test_target", | |
| "noshell" ); | |
| "FAIL" expression => strcmp( "0", "${target_size}" ); | |
| reports: | |
| PASS.!FAIL:: "PASS"; | |
| FAIL:: "FAIL"; | |
| } | |
| body edit_defaults empty | |
| { | |
| empty_file_before_editing => "true"; | |
| edit_backup => "false"; | |
| } | |
| bundle edit_line insert_lines(lines) | |
| { | |
| insert_lines: | |
| "$(lines)" | |
| comment => "Append lines if they don't exist"; | |
| } | |
| body copy_from local_cp(from) | |
| { | |
| source => "$(from)"; | |
| compare => "digest"; | |
| } | |
| And run it twice: | |
| $ rm /tmp/test_src /tmp/test_target; cf-agent -Kf ./bug.cf ; cf-agent -Kf ./bug.cf | |
| /usr/bin/diff: /tmp/test_src: No such file or directory | |
| /usr/bin/diff: /tmp/test_target: No such file or directory | |
| /usr/bin/diff: /tmp/test_src: No such file or directory | |
| /usr/bin/diff: /tmp/test_target: No such file or directory | |
| /usr/bin/diff: /tmp/test_src: No such file or directory | |
| /usr/bin/diff: /tmp/test_target: No such file or directory | |
| R: FAIL | |
| R: PASS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment