nwops / puppet-retrospec

The only tool you need to generate puppet code, tests, modules, facts, types, providers, data and everything else.
https://www.retrospec-puppet.com/
GNU Affero General Public License v3.0
137 stars 27 forks source link

Spec files not generated #57

Closed DimitriSteyaert closed 8 years ago

DimitriSteyaert commented 8 years ago

Hi, I have an issue that's somewhat similar to #51. When I run retrospec puppet from within my puppet module directory there are no spec tests generated. Nonetheless my manifests dir contains a bunch of .pp files.

du -ah manifests
4.0K    manifests/apt.pp
4.0K    manifests/proxy.pp
4.0K    manifests/keepalived.pp
4.0K    manifests/base/firewall.pp
4.0K    manifests/base/ssh.pp
4.0K    manifests/base/firewall/post.pp
4.0K    manifests/base/firewall/pre.pp
12K     manifests/base/firewall
4.0K    manifests/base/snmp.pp
4.0K    manifests/base/ntp.pp
4.0K    manifests/base/dnsclient.pp
4.0K    manifests/base/motd.pp
4.0K    manifests/base/global.pp
44K     manifests/base
4.0K    manifests/postfix.pp
4.0K    manifests/quota.pp
4.0K    manifests/mcollective/server.pp
4.0K    manifests/mcollective/broker.pp
12K     manifests/mcollective
4.0K    manifests/apache.pp
4.0K    manifests/repo.pp
4.0K    manifests/nfs/server.pp
4.0K    manifests/nfs/client.pp
12K     manifests/nfs
4.0K    manifests/facts.pp
4.0K    manifests/sudo.pp
4.0K    manifests/params.pp
4.0K    manifests/vsftpd.pp
4.0K    manifests/yum.pp
4.0K    manifests/mysql/server.pp
4.0K    manifests/mysql/client.pp
12K     manifests/mysql
148K    manifests

when I run retrospec puppet I get the following output: Successfully ran hook: /root/.retrospec/repos/retrospec-puppet-templates/clone-hook

But nothing happens:

du -ah spec
4.0K    spec/spec.opts
4.0K    spec/defines
4.0K    spec/classes
4.0K    spec/hosts
4.0K    spec/functions
4.0K    spec/spec_helper.rb
0       spec/fixtures/manifests/site.pp
4.0K    spec/fixtures/manifests
0       spec/fixtures/modules/profiles/files
0       spec/fixtures/modules/profiles/manifests
0       spec/fixtures/modules/profiles/templates
4.0K    spec/fixtures/modules/profiles
8.0K    spec/fixtures/modules
16K     spec/fixtures
44K     spec

ruby: 2.1.8 puppet-retrospec: 0.12.1 retrospec: 0.4.0

Am I missing something?

logicminds commented 8 years ago

I think a recently template contribution broke this again. I'll check it out today.

logicminds commented 8 years ago

I pushed an update to the templates #58 but I don't think that was your issue. Are you using the stock templates? Also do you have the output of running retrospec?

Is this a module? Are you able to share your parent directory structure.

Do you have internet access on that machine as the clone hook needs to go fetch the templates.

DimitriSteyaert commented 8 years ago

I am indeed using the stock templates. The only output I got was the one line "succesfully ran..." I just did a gem install puppet-retrospec and ran the command from inside a puppet module. The full directory path from where I ran this command is /var/git/hosting_cluster/puppet/profiles/. This machine also has full internet access.

logicminds commented 8 years ago

I just released version 0.12.2 which addressed a few minor issues (notably the test matrix) and exception handling and a few other items. Give this new version a try and see if it fixes your issue. I think the exception handling will at least pinpoint the issue.

DimitriSteyaert commented 8 years ago

Hi, I indeed got more feedback after running the 'retrospec puppet' command, which again didn't generate anything for me. This is the output I got:

➜  profiles git:(development) retrospec puppet
remote: Counting objects: 4, done.
remote: Total 4 (delta 3), reused 3 (delta 3), pack-reused 1
Unpacking objects: 100% (4/4), done.
From https://github.com/nwops/retrospec-templates
   488defb..6915796  master     -> origin/master
Successfully ran hook: /root/.retrospec/repos/retrospec-puppet-templates/clone-hook
Updating 488defb..6915796
Fast-forward
 providers/provider_template.rb.retrospec.erb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

undefined method `applications' for #<Puppet::Resource::TypeCollection:0x007ff344fc1a90>
logicminds commented 8 years ago

Run this command in your module grep -rl 'applications'

My guess is that you are referencing the applications somewhere in your code and retrospec tries to load that code and fails. So this could mean you have an error in your code somewhere.

Moreover, retrospec should fail better and let the user know there was a problem loading the code.

Also, I assume you are running 0.12.2 now?

DimitriSteyaert commented 8 years ago

Hi, I don't have a reference to applications in my code. The command grep -rl 'applications' doesn't return anything.

gem list puppet-retrospec

*** LOCAL GEMS ***

puppet-retrospec (0.12.2)

My version is indeed correct, I ran the command retrospec puppet again and now got the feedback:

remote: Counting objects: 10, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 10 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (10/10), done.
From https://github.com/nwops/retrospec-templates
   6915796..53499e7  master     -> origin/master
Successfully ran hook: /root/.retrospec/repos/retrospec-puppet-templates/clone-hook
Updating 6915796..53499e7
Fast-forward
 acceptance/acceptance_spec_test.rb.retrospec.erb | 27 ++++++++++++++++++
 classes/hostclass_spec.rb.retrospec.erb          | 34 ++++++++++++++++++++++
 defines/definition_spec.rb.retrospec.erb         | 36 ++++++++++++++++++++++++
 nodes/node_spec.rb.retrospec.erb                 | 28 ++++++++++++++++++
 4 files changed, 125 insertions(+)
 create mode 100644 acceptance/acceptance_spec_test.rb.retrospec.erb
 create mode 100644 classes/hostclass_spec.rb.retrospec.erb
 create mode 100644 defines/definition_spec.rb.retrospec.erb
 create mode 100644 nodes/node_spec.rb.retrospec.erb

undefined method `applications' for #<Puppet::Resource::TypeCollection:0x007f18dddce5b8>

But still no generated spec files.

logicminds commented 8 years ago

Version 1.0.0 has been released. Give this a try now.

DimitriSteyaert commented 8 years ago

Can you publish the gem on rubygems.org please? :)

logicminds commented 8 years ago

It was pushed yesterday.

DimitriSteyaert commented 8 years ago

Perfect, this release fixed the issue for me. Thanks!