Bug #12490

execution_spec is stomping on process ENV variables

Added by Chris Price 3 months ago. Updated 7 days ago.

Status:Merged - Pending Release Start date:02/07/2012
Priority:Urgent Due date:
Assignee:Chris Price % Done:

0%

Category:testing
Target version:3.0.0
Affected Puppet version:development Branch:https://github.com/puppetlabs/puppet/pull/478
Keywords:
Votes: 0

Description

The execute_posix method:

a) Should not be called during windows test runs, and

b) Needs to take more care not to inadvertently set environment variables in the main ruby process.

When the test was written, I assumed that the latter would not be a problem because the environment variable manipulation was only supposed to happen in a forked process; however, because these tests stub the Kernel.fork method, the process is never actually forked and thus the environment variable manipulation happens in the parent process.


Related issues

related to Puppet - Bug #12336: executing system commands may fail if user's PATH contain... Merged - Pending Release 01/31/2012

History

Updated by Chris Price 3 months ago

  • Description updated (diff)

Updated by Daniel Pittman 3 months ago

Chris Price wrote:

The execute_posix method:

a) Should not be called during windows test runs, and

Ideally we want to test as much of the behaviour on Windows as we can, just as we want to test as much Windows behaviour on our Unix systems as we can. The less places a test runs the less likely we are to catch a problem early.

b) Needs to take more care not to inadvertently set environment variables in the main ruby process.

Yeah. That test is a bad test, since assuming that nothing bad can possibly happen inside the forked child when it gets run in the parent is … terrible.

This would expose the issue of, for example, the work-around for fork vs ActiveRecord that will start closing file descriptors too. Having to know that much is a real problem.

We should probably better not unit test this at all, or abstract the platform details to an easy to stub interface if we must, than to assume we can make fork and yield equivalent safely.

Updated by Chris Price 3 months ago

  • Status changed from Accepted to In Topic Branch Pending Review
  • Branch set to https://github.com/puppetlabs/puppet/pull/472

Updated by Chris Price 3 months ago

I’ve committed a fix that should get the tests passing again, but would be happy to do further work on this test to get rid of the “fork” stub if desired.

Updated by Josh Cooper 3 months ago

  • Category set to testing
  • Status changed from In Topic Branch Pending Review to Merged - Pending Release
  • Target version set to 3.X
  • Affected Puppet version set to development

I merged this into master in https://github.com/puppetlabs/puppet/commit/194b2c3. If you want to spend more time to address Daniel’s concerns, that’d be great too.

Updated by Chris Price 3 months ago

  • Status changed from Merged - Pending Release to Tests Insufficient

Updated by Chris Price 3 months ago

  • Status changed from Tests Insufficient to In Topic Branch Pending Review
  • Branch changed from https://github.com/puppetlabs/puppet/pull/472 to https://github.com/puppetlabs/puppet/pull/478

There were still some tests failing on windows; they weren’t exactly the same issue but I’m just re-using this ticket and the corresponding git branch.

Updated by Daniel Pittman 3 months ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release

Updated by Daniel Pittman 7 days ago

  • Target version changed from 3.X to 3.0.0

Also available in: Atom PDF