XMLWordPrintable

    Details

    • Type: Bug
    • Status: Unconfirmed
    • Priority: High
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Promise type: files
    • Labels:
      None
    • Platform:
      Debian, Other (details)
    • Steps to reproduce:
      Acceptance/unit test attached

      Description

      Two local copy tests, one without digest and one with both fail, but differently.

      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
      
      

        Attachments

          Activity

            People

            • Assignee:
              a10038 jimis (Dimitrios Apostolou)
              Reporter:
              neilhwatson Neil Watson
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:

                Zendesk Support

                  Summary Panel