Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using "cmp" Against File Mode Fails #1188

Closed
xiGUAwanOU opened this issue Sep 30, 2016 · 4 comments
Closed

Using "cmp" Against File Mode Fails #1188

xiGUAwanOU opened this issue Sep 30, 2016 · 4 comments
Labels
Type: Bug Feature not working as expected
Milestone

Comments

@xiGUAwanOU
Copy link

xiGUAwanOU commented Sep 30, 2016

Description

I'm writing an inspec description for a file downloaded by s3_file cookbook, to test its mode is correct.

The mode of the downloaded file is set to 0660, which is ensured manually with ls -l in the virtual machine. And my inspec description is like this:

describe file('/tmp/exampleapi.tar.gz') do
  it { should exist }
  its('owner') { should eq 'vagrant' }
  its('group') { should eq 'vagrant' }
  its('mode') { should cmp '0660' }
end

This example fails on one of the build servers (we have two of them), and I've also tried to manually execute kitchen converge and kitchen verify, it still fails.

The failures have following error message:

Failures:

  1) File /tmp/exampleapi.tar.gz mode should cmp "0660"
     Failure/Error: DEFAULT_FAILURE_NOTIFIER = lambda { |failur, _opts| raise failure }

       expected: 0660
            got: 0660

       (compared using `cmp` matcher)

However, if I use should eq 0660, there is no problem any more.

InSpec and Platform Version

Test Kitchen version: 1.7.3

I have no idea about how to get the version of InSpec. I'm using .kitchen.yml and specified the verifier as inspec.

The build server is a Mac mini Server (Late 2012), with OS X El Capitan, Version 10.11.5

@arlimus arlimus added the Type: Bug Feature not working as expected label Oct 1, 2016
@arlimus arlimus added this to the 1.1.0 milestone Oct 1, 2016
@arlimus
Copy link
Contributor

arlimus commented Oct 1, 2016

Thank you for reporting @xiGUAwanOU

I tried to recreate this issue:

vagrant-arch.vagrantup.com:..ec ±> touch test
vagrant-arch.vagrantup.com:..ec ±> chmod 0660 test
vagrant-arch.vagrantup.com:..ec ±> cat > test.rb
describe file('test') do
  it { should exist }
  its('mode') { should cmp '0660' }
end

vagrant-arch.vagrantup.com:..ec ±> inspec exec test.rb

Target:  local://


  File test
     ✔  should exist
     ✔  mode should cmp "0660"

Test Summary: 2 successful, 0 failures, 0 skipped

Is it possible to share the complete example (tiny chef snippet + inspec snippet)?

To help with the version of kitchen-inspec and inspec: Are you using bundler? In that case please run:

bundle list

in the folder of your Gemfile. Otherwise please:

> inspec version
1.0.0
> kitchen version
Test Kitchen version 1.13.2

@xiGUAwanOU
Copy link
Author

xiGUAwanOU commented Oct 4, 2016

I have updated the Chef DK version on the build machine, and this problem doesn't exist anymore. So this could be an already fixed problem.

Since the older Chef DK version has been deleted, it is a little bit tricky to get the InSpec version.

I've found the InSpec version number in the Gemfile.lock from ChefDK 0.13.21, since the Test Kitchen version (1.7.3) provided by this ChefDK matches the number I've mentioned before. So the version number of InSpec should be 0.18.0.

The snippet caused the problem:

s3_file local_path do
  bucket 'dummy_bucket'
  remote_path 'dummy_file'
  aws_access_key_id 'dummy_key'
  aws_secret_access_key 'dummy_secret'
  owner 'vagrant'
  group 'vagrant'
  mode '0660'
  s3_url 'dummy_url'
  action :create
end

@arlimus arlimus added the ready label Oct 6, 2016
@arlimus arlimus modified the milestones: 1.3.0, Prioritized Oct 10, 2016
@vjeffrey
Copy link

@xiGUAwanOU some further testing on our end seems to be confirming that the cmp problem is fixed. If I'm understanding correctly, this is no longer a problem for you as well, right? ("I have updated the Chef DK version on the build machine, and this problem doesn't exist anymore") Please confirm so we can close the issue if that is the case. Thank you :)

@vjeffrey
Copy link

Closing out the issue for now. Please re-open if this is still an issue!! Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Feature not working as expected
Projects
None yet
Development

No branches or pull requests

3 participants