Use the cassandradb_session Chef InSpec audit resource to test Cassandra Query Language (CQL) commands run against a Cassandra database.
This resource is distributed along with Chef InSpec itself. You can use it automatically.
A cassandradb_session resource block declares the username, password, host, and port to use for the session, and then the command to be run:
describe cassandradb_session(user: 'USERNAME', password: 'PASSWORD', host: 'localhost', port: 9042).query('QUERY') do
its('value') { should eq('EXPECTED') }
end
where
cassandradb_session declares a username, password, host and port to run the query.query('QUERY') contains the query to be run.its('value') { should eq('expected') } compares the results of the query against the expected result in the test.The cassandradb_session InSpec resource accepts user, password, host, and port parameters.
In Particular:
userDefault value: cassandra.
passwordDefault value: cassandra.
The following examples show how to use this Chef InSpec audit resource.
cql = cassandradb_session(user: 'MY_USER', password: 'PASSWORD', host: 'localhost', port: 9042)
describe cql.query("SELECT cluster_name FROM system.local") do
its('output') { should match /Test Cluster/ }
end
cql = cassandradb_session(user: 'MY_USER', password: 'PASSWORD', host: 'localhost', port: 9042)
describe cql.query("use SAMPLEDB; SELECT name FROM SAMPLETABLE") do
its('output') { should match /Test Name/ }
end
For a full list of available matchers, please visit our matchers page.
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs.chef.io/inspec/resources/cassandradb_session/