Uploaded image for project: 'Puppet Communications Protocol'
  1. Puppet Communications Protocol
  2. PCP-710

pxp-agent acceptance - improve on reliance on sleep processes

    Details

    • Template:
    • Team:
      Dumpling
    • QA Risk Assessment:
      Needs Assessment

      Description

      A number of pxp-agent acceptance tests rely on having Puppet spawn sleep using an exec resource; to intentionally have a pxp transaction kept in a running state. When the test is ready for the transaction to continue; we grep the process list to determine the sleep pid then send a kill command.

      This works but we need to maintain beaker commands for finding and killing sleep that will work for every platform we support (and are a risk for adding newly supported platforms). It also burdens us with needing to write tests that are very sensitive on timing (e.g. it might take multiple seconds for Puppet to invoke and the sleep process to appear)

      One possibly better approach from a different repo's tests is to have Puppet code that will stall while waiting for a condition (a file to exist)

      e.g.

      Puppet::Type.type(:testsql).provide(:test_file) do
       
        # looks for the unblocking_file until the timeout completes
        # if not found before timeout create method is called, raising an error
        def exists?
          start_time = Time.now
          timeout = resource[:blocking_timeout].to_i
          while (Time.now - start_time).to_i < timeout
            return true if File.file?(resource[:unblocking_file])
            sleep 1
          end
          return false
        end
       
        def create
          raise Puppet::Error, 'The test_file provider timed out'
        end
      end

      The test case signals the Puppet run to complete by creating the unblocking_file file on the SUT.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              james.stocks James Stocks
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Zendesk Support