Rspec-puppet and testing for expected failures...

427 views
Skip to first unread message

Gavin Williams

unread,
Jan 16, 2014, 12:27:21 PM1/16/14
to puppet...@googlegroups.com
Afternoon all,

I'm trying to add some rspec-puppet testing to my Glassfish module[1], in preparation for releasing it to the forge.

I've got some stuff working fine, however I'm trying to test expected failure scenarios without much luck.

Travis CI[2] highlights the issues I'm seeing.
An example error message is:

Failure/Error: expect {

expected Puppet::Error with message matching /OSFamily Suse not supported/ but nothing was raised

This is as a result of a test[3] which is testing some validation logic in my create_service[4] defined type.

Any pointers on where I could be going wrong?

Thanks in advance for any responses.

Regards
Gavin

[1] https://github.com/fatmcgav/puppet-glassfish
[2] https://travis-ci.org/fatmcgav/puppet-glassfish/jobs/17072897#
[3] https://github.com/fatmcgav/puppet-glassfish/blob/master/spec/defines/create_service_spec.rb#L127-149
[4] https://github.com/fatmcgav/puppet-glassfish/blob/master/manifests/create_service.pp#L14-19

fatmcgav

unread,
Jan 16, 2014, 4:37:37 PM1/16/14
to puppet...@googlegroups.com

Quick update...

Many thanks to @superseb for working up a PR[1] that fixes the expect errors. Trick was to use 'subject' within the expect, rather than a resource title...

@superseb also highlighted an old Puppet bug[2] which I've migrated across to Jira[3] for review/decision.
However as per the notes on Redmine, I should be able to work around said bug by using a case statement rather then the tenary operator...

Onwards and upwards.

Cheers
Gav

[1] https://github.com/fatmcgav/puppet-glassfish/pull/8
[2] http://projects.puppetlabs.com/issues/4598
[3] https://tickets.puppetlabs.com/browse/PUP-1457

--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/Ek0ckKfPGYw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/f04c1f56-60c0-4fa9-be03-f5fbe1129ce5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Gavin Williams

unread,
Jan 17, 2014, 4:39:54 AM1/17/14
to puppet...@googlegroups.com
Morning all...

Next strange error... The Travis CI tests are failing against Puppet 3.0.2 only[1].

The error being returned is:

1) glassfish::create_domain with default params

Failure/Error: })

Puppet::Error:

Unknown function validate_absolute_path at /home/travis/build/fatmcgav/puppet-glassfish/spec/fixtures/modules/glassfish/manifests/create_domain.pp:17 on node testing-worker-linux-3-1-6934-linux-4-17115342.blueboxgrid.com

# ./spec/defines/create_domain_spec.rb:41

Spec tests work fine on multiple other versions of Puppet[2], from 2.7.25 through to 3.4.1, just failing on 3.0.2...

Any ideas?

Cheers
Gavin

[1] https://travis-ci.org/fatmcgav/puppet-glassfish/jobs/17115342
[2] https://travis-ci.org/fatmcgav/puppet-glassfish/builds/17115340
To unsubscribe from this group and all its topics, send an email to puppet-users+unsubscribe@googlegroups.com.

Gavin Williams

unread,
Jan 17, 2014, 11:36:00 AM1/17/14
to puppet...@googlegroups.com
Ok, looks like the error's I was seeing with 3.0.2 was a known bug[1], and so I've updated travis to allow failures on the 3.0.2 builds.

However I've now hit my next error[2]:

1) glassfish on a RedHat OSFamily with create_domain => true and create_service => true

Failure/Error: should contain_glassfish__create_domain('domain1').that_requires('Class[glassfish::install]')

Puppet::Error:

Duplicate declaration: Glassfish::Create_service[domain1] is already declared in file /home/travis/build/fatmcgav/puppet-glassfish/spec/fixtures/modules/glassfish/manifests/init.pp:111; cannot redeclare at /home/travis/build/fatmcgav/puppet-glassfish/spec/fixtures/modules/glassfish/manifests/create_domain.pp:41 on node testing-worker-linux-7-2-11652-linux-5-17137606.localdomain

# ./spec/classes/init_spec.rb:88

Spec test is available here[3], failing test is highlighted.

I've googled and haven't managed to find anything obvious... 

Any ideas/pointers?

Cheers
Gavin

[1] http://projects.puppetlabs.com/issues/17543
[2] https://travis-ci.org/fatmcgav/puppet-glassfish/jobs/17137606
[3] https://github.com/fatmcgav/puppet-glassfish/blob/4ee7a5cfe260494fc5bf48c01964e06ca18facbd/spec/classes/init_spec.rb#L77-96
Reply all
Reply to author
Forward
0 new messages