[PCP-710] pxp-agent acceptance - improve on reliance on sleep processes Created: 2017/02/21  Updated: 2019/11/08  Resolved: 2019/11/08

Status: Closed
Project: Puppet Communications Protocol
Component/s: pxp-agent package, QA
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Normal
Reporter: James Stocks Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: maintenance, puppethack, trivial
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Team: Dumpling
QA Risk Assessment: Needs Assessment


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)


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
    return false
  def create
    raise Puppet::Error, 'The test_file provider timed out'

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

Comment by Michael Smith [ 2017/02/22 ]

Seems reasonable.

Comment by Jonathan Newman [ 2019/11/08 ]

Closing due to lack of activity in 2+years. Feel free to reopen if needed.

Generated at Mon Aug 10 23:33:07 PDT 2020 using Jira 8.5.2#805002-sha1:a66f9354b9e12ac788984e5d84669c903a370049.