Jira (PUP-10813) Unit test error with file resource content using find_template()

11 views
Skip to first unread message

GeorgesZ (Jira)

unread,
Dec 7, 2020, 6:18:03 PM12/7/20
to puppe...@googlegroups.com
GeorgesZ created an issue
 
Puppet / Bug PUP-10813
Unit test error with file resource content using find_template()
Issue Type: Bug Bug
Affects Versions: PUP 6.17.0
Assignee: Unassigned
Attachments: FindTemplateBug.zip
Created: 2020/12/07 3:17 PM
Environment:

Windows and Linux.

Priority: Normal Normal
Reporter: GeorgesZ

Puppet Version: 6.17.0
Puppet Server Version: N/A
OS Name/Version: Windows 10, Linux

Running unit test on puppet code that uses find_template gives error during compilation of the unit test.
Describe steps to reproduce:

  • pdk new module ...

  • pdk new class ...

  • Add to new class a file resource with content using find_template().
  • pdk test unit

Desired Behavior:

The unit test should pass.

Actual Behavior:

When running the unit tests using for example `pdk test unit`, a file resource like this

  file { "${rootFolder}/content_find_template.file":
    ensure  => file,
    content => find_template($template).file,
  }

gives an error like this:

  1) my_test::test_class on centos-7-x86_64 is expected to compile into a catalogue without dependency cycles     Failure/Error: it { is_expected.to compile }       error during compilation: Evaluation Error: Error while evaluating a Method call, Could not find any files from F:/Tools/Puppet/TestFindTemplateBug/my_test/spec/fixtures/modules/my_test/templates/template.erb (file: F:/Tools/Puppet/TestFindTemplateBug/my_test/spec/fixtures/modules/my_test/manifests/test_class.pp, line: 23, column: 40) on node naussma9xzrhk2.ra-int.com     # ./spec/classes/test_class_spec.rb:10:in `block (4 levels) in <top (required)>'

See attached zip file that reproduces the error from scratch using the latest PDK.

A similar error seen on Linux in our CI using a GitLab runner.

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

GeorgesZ (Jira)

unread,
Dec 8, 2020, 9:36:03 AM12/8/20
to puppe...@googlegroups.com
GeorgesZ updated an issue
Change By: GeorgesZ
*Puppet Version: 6.17.0*
*Puppet Server Version: N/A*
*OS Name/Version: Windows 10, Linux*


Running unit test on puppet code that uses find_template gives error during compilation of the unit test.
Describe steps to reproduce:
*
{noformat}

pdk new module ...{noformat}

*
{noformat}

pdk new class ...{noformat}

* Add to new class a file resource with content using find_template().
*
{noformat}

pdk test unit{noformat}

*Desired Behavior:*


The unit test should pass.

*Actual Behavior:*


When running the unit tests using for example `pdk test unit`, a file resource like this
{code:java}
  file { "${rootFolder}/content_find_template.file":
    ensure  => file,
    content => find_template($template).file,
  }
{code}

gives an error like this:
{code:java}
  1) my_test::test_class on centos-7-x86_64 is expected to compile into a catalogue without dependency cycles     Failure/Error: it { is_expected.to compile }       error during compilation: Evaluation Error: Error while evaluating a Method call, Could not find any files from  F: <path> / Tools/Puppet/TestFindTemplateBug/ my_test/spec/fixtures/modules/my_test/templates/template.erb (file:  F: <path> / Tools/Puppet/TestFindTemplateBug/ my_test/spec/fixtures/modules/my_test/manifests/test_class.pp, line: 23, column: 40) on node  naussma9xzrhk2 <nodeName> . ra-int.com     # . /spec/classes/test_class_spec.rb:10:in `block (4 levels) in <top (required)>'
{code}

See attached zip file that reproduces the error from scratch using the latest PDK.

A similar error seen on Linux in our CI using a GitLab runner. The error is something like:
{code:java}
error   during compilation: Evaluation Error: Error while evaluating a Method call, Could not find any files from /mnt/tmpfs/site-modules/<module>/spec/fixtures/modules/<module>/templates/<filename>.erb
{code}
 

Nick Walker (Jira)

unread,
Dec 15, 2020, 11:23:02 AM12/15/20
to puppe...@googlegroups.com
Nick Walker commented on Bug PUP-10813
 
Re: Unit test error with file resource content using find_template()

hi GeorgesZ.  Can you upload a module example of this code?  And can you confirm that the module actually works when run via puppet?  

We're having a hard time telling what the reproduction case is as the example code above includes two variables which aren't defined.  If you can provide a module with just the minimum code to reproduce an issue that'd be great.  We want to make sure it runs via puppet and then we can look at how rspec is failing.  

GeorgesZ (Jira)

unread,
Dec 15, 2020, 4:49:02 PM12/15/20
to puppe...@googlegroups.com
GeorgesZ updated an issue
Change By: GeorgesZ
Attachment: FindTemplateBug2.zip

GeorgesZ (Jira)

unread,
Dec 15, 2020, 4:50:06 PM12/15/20
to puppe...@googlegroups.com
GeorgesZ commented on Bug PUP-10813
 
Re: Unit test error with file resource content using find_template()

Hi Nick Walker. I simplified the code reproducing the error and showing that find_template() does indeed work as expected during a Puppet apply. Just run Test.cmd in the attached FindTemplateBug2.zip. It contains the full content of the folder after running Test.cmd.

 

Mihai Buzgau (Jira)

unread,
Mar 2, 2021, 7:28:56 PM3/2/21
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Mar 2, 2021, 7:28:56 PM3/2/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages