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

PostgreSQL_Session Resource #302

Closed
paulmakl opened this issue Dec 7, 2015 · 3 comments
Closed

PostgreSQL_Session Resource #302

paulmakl opened this issue Dec 7, 2015 · 3 comments
Labels
Type: Bug Feature not working as expected
Milestone

Comments

@paulmakl
Copy link

paulmakl commented Dec 7, 2015

I am writing a new cookbook and validating its configuration with kitchen-inspec. I am using a postgres_session resource to make sure a postgresql parameter was set properly. I know that this can be done with the postgres_conf resource, but I am trying to make sure that the postgres_session resource works so that I can use it to run more complex queries against my database.

The following inspec test fails ...

database_test_spec.rb
postgres = postgres_session('postgres', 'pass')
describe postgres.query('show ssl;') do
its('output') { should eq(" ssl\n -----\n on\n (1 row)\n ") }
end

... with the following output.

  1. RSpec::ExampleGroups::PostgreSQLQueryShowSsl output should eq " ssl\n -----\n on\n (1 row)\n "
    Failure/Error: DEFAULT_FAILURE_NOTIFIER = lambda { |failure, _opts| raise failure }
   expected: " ssl\n  -----\n   on\n   (1 row)\n   "
        got: output to some stream

   (compared using ==)

   Diff:
   @@ -1,6 +1,2 @@
   - ssl
   -  -----
   -   on
   -   (1 row)
   -
   +(output to some stream)
 # ./test/integration/standard_database_setup94/database_test_spec.rb:20:in `block (2 levels) in load'
 # /Users/foo/.chefdk/gem/ruby/2.1.0/gems/inspec-0.9.5/lib/inspec/runner.rb:97:in `run_with'
 # /Users/foo/.chefdk/gem/ruby/2.1.0/gems/inspec-0.9.5/lib/inspec/runner.rb:93:in `run'

I am using inspec (0.9.5) and kitchen-inspec (0.9.0)

I don't understand what I am doing wrong here. Am I using this resource incorrectly, or is this some sort of bug on my end? Any help would be much appreciated.

@srenatus srenatus self-assigned this Dec 8, 2015
@srenatus srenatus added the Type: Bug Feature not working as expected label Dec 8, 2015
@srenatus
Copy link
Contributor

srenatus commented Dec 8, 2015

@paulmakl thanks for reporting this. Currently, there is some magic in place that will prepare the output from psql for matching. So, to match what you're aiming at, you'd just write

postgres = postgres_session('postgres', 'inspec')
describe postgres.query('show ssl;') do
  its('output') { should eq 'on' }
end

because headers are already removed.

However, I had some trouble with this resource acting strange when there was a failure in the psql command executing, started working on that here. Also tracked down "output to some stream".

@paulmakl
Copy link
Author

paulmakl commented Dec 8, 2015

Thank you for looking into this!

@chris-rock
Copy link
Contributor

@paulmakl This should be fixed with #381 If you still experience issues, please let us know.

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

4 participants