mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
Remove test/resources directory, update README (#2124)
* Remove test/resources directory, update README The test/resources directory is stale and no longer used. Rather, we favor Test Kitchen-backed integration tests in test/integration. This change removes the stale tests and updates the README accordingly. Signed-off-by: Adam Leff <adam@leff.co> * Remove resources tests from travis Signed-off-by: Adam Leff <adam@leff.co>
This commit is contained in:
parent
dbb4311693
commit
8b8d240fe6
10 changed files with 24 additions and 324 deletions
|
@ -19,12 +19,6 @@ matrix:
|
|||
- rvm: 2.4.1
|
||||
script: bundle exec rake $SUITE
|
||||
env: SUITE="lint test test:functional"
|
||||
- rvm: 2.4.1
|
||||
script: bundle exec rake $SUITE
|
||||
env: SUITE="test:resources config=test/test.yaml" N=2
|
||||
- rvm: 2.4.1
|
||||
script: bundle exec rake $SUITE
|
||||
env: SUITE="test:resources config=test/test-extra.yaml" N=2
|
||||
- rvm: 2.4.1
|
||||
bundler_args: "--without guard tools"
|
||||
script: bundle exec rake $SUITE
|
||||
|
@ -70,8 +64,6 @@ matrix:
|
|||
script: ./support/ci/deploy_website_to_acceptance.sh
|
||||
|
||||
allow_failures:
|
||||
- env: SUITE="test:resources config=test/test.yaml" N=2
|
||||
- env: SUITE="test:resources config=test/test-extra.yaml" N=2
|
||||
- env:
|
||||
- AFFECTED_DIRS="www"
|
||||
- secure: "jdzXUhP1o7RkfSikZLKgUcCIaKqLjqWa35dnxWnz7qAQ2draRKa7I7cXmUv76BZkW8HBUUH11dOi8YOVxPYPOzaqvcTCfqNqGVxsT9epgWa7rA8aXMXkECp548ry1rYJQpti9zpwsoe2GQyNPr9vNiWMiyj51CaABmZ6JzmFEEqlZc8vqpqWeqJvIqaibQGk7ByLKmi4R44fVwFKIG39RuxV+alc/G4nnQ2zmNTFuy8uFGs5EghQvRytzWY+s2AKtDiZ0YXYOII1Nl1unXNnNoQt9oI209ztlSm1+XOuTPelW6bEIx5i7OZFaSRPgJzWnkGN85C9nBE08L2az9Jz18/rYJF4fdVRttdGskueyYI21lh1FwlAg51ZG0RfLTYk2Pq+k4c+NO1cfmGcaXBwihfD5BWqrILU5HHkYszXCSmgl4hscC7/BS4Kgcq2z32JJwV8B+x4XngM0G4uzIn1Soia3lZXEKdnfVsxFDdMQ7FK60F3uQlq/44LRkZujRhqfAKOiz+0tsLexWzj7wK+DJY9Y00CUfh7xcxRxDxFNpOv1FWYFB9lUlaOt3HDHgUoksqbURiUzhOZZzTE/1MAtF2K6mbpME5CbN08J88L5JBlb+CX79XCzj30lNMeS0I/dCRQEmkygr2eJYxvRO2qsBNuphs4SWk8NZyS/llVZFI="
|
||||
|
|
58
README.md
58
README.md
|
@ -339,11 +339,10 @@ The InSpec community and maintainers are very active and helpful. This project b
|
|||
|
||||
## Testing InSpec
|
||||
|
||||
We perform `unit`, `resource` and `integration` tests.
|
||||
We perform `unit` and `integration` tests.
|
||||
|
||||
* `unit` tests ensure the intended behaviour of the implementation
|
||||
* `resource` tests run against docker containers
|
||||
* `integration` tests run against VMs via test-kitchen and [kitchen-inspec](https://github.com/chef/kitchen-inspec)
|
||||
- `unit` tests ensure the intended behaviour of the implementation
|
||||
- `integration` tests run against Docker-based VMs via test-kitchen and [kitchen-inspec](https://github.com/chef/kitchen-inspec)
|
||||
|
||||
### Unit tests
|
||||
|
||||
|
@ -351,60 +350,51 @@ We perform `unit`, `resource` and `integration` tests.
|
|||
bundle exec rake test
|
||||
```
|
||||
|
||||
If you like to run only one test, use
|
||||
If you like to run only one test file:
|
||||
|
||||
```bash
|
||||
bundle exec ruby -W -Ilib:test test/unit/resources/user_test.rb
|
||||
bundle exec m test/unit/resources/user_test.rb
|
||||
```
|
||||
|
||||
### Resource tests
|
||||
|
||||
Resource tests make sure the backend execution layer behaves as expected. These tests will take a while, as a lot of different operating systems and configurations are being tested.
|
||||
|
||||
You will require:
|
||||
|
||||
* docker
|
||||
|
||||
Run `resource` tests with
|
||||
You may also run a single test within a file by line number:
|
||||
|
||||
```bash
|
||||
bundle exec rake test:resources config=test/test.yaml
|
||||
bundle exec rake test:resources config=test/test-extra.yaml
|
||||
bundle exec m test/unit/resources/user_test.rb -l 123
|
||||
```
|
||||
|
||||
### Integration tests
|
||||
|
||||
These tests download various virtual machines, to ensure InSpec is working as expected across different operating systems.
|
||||
|
||||
You will require:
|
||||
These tests require the following gems:
|
||||
|
||||
* vagrant with virtualbox
|
||||
* test-kitchen
|
||||
- test-kitchen
|
||||
- kitchen-dokken
|
||||
- kitchen-inspec
|
||||
|
||||
**Run `integration` tests with vagrant:**
|
||||
These gems are provided via the `integration` group in the project's Gemfile.
|
||||
|
||||
In addition, these test require Docker to be available on your machine or a remote Docker machine configured via the standard Docker environment variables.
|
||||
|
||||
#### Running Integration tests
|
||||
|
||||
List the various test instances available:
|
||||
|
||||
```bash
|
||||
KITCHEN_YAML=.kitchen.vagrant.yml bundle exec kitchen test
|
||||
bundle exec kitchen list`
|
||||
```
|
||||
|
||||
**Run `integration` tests with AWS EC2:**
|
||||
The platforms and test suites are configured in the `.kitchen.yml` file. Once you know which instance you wish to test, test that instance:
|
||||
|
||||
```bash
|
||||
export AWS_ACCESS_KEY_ID=enteryouryourkey
|
||||
export AWS_SECRET_ACCESS_KEY=enteryoursecreykey
|
||||
export AWS_KEYPAIR_NAME=enteryoursshkeyid
|
||||
export EC2_SSH_KEY_PATH=~/.ssh/id_aws.pem
|
||||
KITCHEN_YAML=.kitchen.ec2.yml bundle exec kitchen test
|
||||
bundle exec kitchen test <INSTANCE_NAME>
|
||||
```
|
||||
|
||||
In addition you may need to add your ssh key to `.kitchen.ec2.yml`
|
||||
You may test all instances in parallel with:
|
||||
|
||||
```bash
|
||||
bundle exec kitchen test -c
|
||||
```
|
||||
transport:
|
||||
ssh_key: /Users/chartmann/aws/aws_chartmann.pem
|
||||
username: ec2-user
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
# encoding: utf-8
|
||||
# author: Dominik Richter
|
||||
# author: Christoph Hartmann
|
||||
|
||||
describe command('echo hello') do
|
||||
its('stdout') { should eq "hello\n" }
|
||||
its('stderr') { should eq '' }
|
||||
its('exit_status') { should eq 0 }
|
||||
end
|
||||
|
||||
describe command('>&2 echo error') do
|
||||
its('stdout') { should eq '' }
|
||||
its('stderr') { should eq "error\n" }
|
||||
its('exit_status') { should eq 0 }
|
||||
end
|
||||
|
||||
describe command('exit 123') do
|
||||
its('stdout') { should eq '' }
|
||||
its('stderr') { should eq '' }
|
||||
its('exit_status') { should eq 123 }
|
||||
end
|
||||
|
||||
describe command('/bin/sh').exist? do
|
||||
it { should eq true }
|
||||
end
|
||||
|
||||
describe command('sh').exist? do
|
||||
it { should eq true }
|
||||
end
|
||||
|
||||
describe command('this is not existing').exist? do
|
||||
it { should eq false }
|
||||
end
|
|
@ -1,45 +0,0 @@
|
|||
# encoding: utf-8
|
||||
# author: Dominik Richter
|
||||
# author: Christoph Hartmann
|
||||
|
||||
describe command('echo hello') do
|
||||
its('stdout') { should eq "hello\n" }
|
||||
end
|
||||
|
||||
describe 'describe + it + expect' do
|
||||
it 'should echo something' do
|
||||
out = rand.to_s
|
||||
expect(command("echo -n #{out}").stdout).to eq(out)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'describe and expect without it' do
|
||||
it 'will raise an error' do
|
||||
expect(proc{
|
||||
describe rand.to_s do
|
||||
expect(true).to eq(true)
|
||||
end
|
||||
}).to raise_error StandardError
|
||||
end
|
||||
end
|
||||
|
||||
rule 'rule + describe' do
|
||||
out = rand.to_s
|
||||
describe command("echo -n #{out}") do
|
||||
its('stdout') { should eq out }
|
||||
end
|
||||
end
|
||||
|
||||
rule 'rule + describe + it + expect' do
|
||||
out = rand.to_s
|
||||
describe 'a rule' do
|
||||
it 'must echo something' do
|
||||
expect(command("echo -n #{out}").stdout).to eq(out)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
rule 'rule + expect only' do
|
||||
out = rand.to_s
|
||||
expect(command("echo -n #{out}").stdout).to eq(out)
|
||||
end
|
|
@ -1,148 +0,0 @@
|
|||
# encoding: utf-8
|
||||
# author: Dominik Richter
|
||||
# author: Christoph Hartmann
|
||||
|
||||
#
|
||||
# On most systems I've used a link to /proc/kcore is placed at
|
||||
# /dev/core. However, on TravisCI we also see it at /dev/kcore.
|
||||
#
|
||||
# Since we are using this file to test some properties of symlinks, we
|
||||
# don't particularly care where it is, so here we use /dev/kcore if it
|
||||
# exists and otherwise fall back to /dev/core.
|
||||
#
|
||||
kcore_dev = if file('/dev/kcore').exist?
|
||||
'/dev/kcore'
|
||||
else
|
||||
'/dev/core'
|
||||
end
|
||||
|
||||
describe file('/tmp') do
|
||||
it { should exist }
|
||||
end
|
||||
|
||||
describe file('/tmpest') do
|
||||
it { should_not exist }
|
||||
end
|
||||
|
||||
describe file('/tmp') do
|
||||
its('type') { should eq :directory }
|
||||
it { should be_directory }
|
||||
end
|
||||
|
||||
describe file('/proc/version') do
|
||||
its('type') { should eq :file }
|
||||
it { should be_file }
|
||||
it { should_not be_directory }
|
||||
end
|
||||
|
||||
describe file('/dev/stdout') do
|
||||
its('type') { should eq :pipe }
|
||||
its('source.type') { should eq :symlink }
|
||||
it { should be_symlink }
|
||||
it { should be_pipe }
|
||||
it { should_not be_file }
|
||||
it { should_not be_directory }
|
||||
end
|
||||
|
||||
describe file('/dev/zero') do
|
||||
its('type') { should eq :character_device }
|
||||
it { should be_character_device }
|
||||
it { should_not be_file }
|
||||
it { should_not be_directory }
|
||||
end
|
||||
|
||||
# describe file('...') do
|
||||
# its('type') { should eq :block_device }
|
||||
# it { should be_block_device }
|
||||
# end
|
||||
|
||||
# describe file('...') do
|
||||
# its('type') { should eq :socket }
|
||||
# it { should be_socket }
|
||||
# end
|
||||
|
||||
# describe file('...') do
|
||||
# its('type') { should eq :pipe }
|
||||
# it { should be_pipe }
|
||||
# end
|
||||
|
||||
describe file('/dev') do
|
||||
its('mode') { should eq 00755 }
|
||||
its('mode') { should cmp '00755' }
|
||||
its('mode') { should_not cmp '00777' }
|
||||
end
|
||||
|
||||
describe file('/dev') do
|
||||
it { should be_mode 00755 }
|
||||
end
|
||||
|
||||
describe file('/root') do
|
||||
its('owner') { should eq 'root' }
|
||||
end
|
||||
|
||||
describe file('/dev') do
|
||||
it { should be_owned_by 'root' }
|
||||
end
|
||||
|
||||
describe file('/root') do
|
||||
its('group') { should eq 'root' }
|
||||
end
|
||||
|
||||
describe file('/dev') do
|
||||
it { should be_grouped_into 'root' }
|
||||
end
|
||||
|
||||
describe file(kcore_dev) do
|
||||
its('link_path') { should eq '/proc/kcore' }
|
||||
end
|
||||
|
||||
describe file(kcore_dev) do
|
||||
it { should be_linked_to '/proc/kcore' }
|
||||
end
|
||||
|
||||
describe file('/proc/cpuinfo') do
|
||||
its('content') { should match /^processor/ }
|
||||
end
|
||||
|
||||
describe file('/').mtime.to_i do
|
||||
it { should <= Time.now.to_i }
|
||||
it { should >= Time.now.to_i - 1000}
|
||||
end
|
||||
|
||||
describe file('/') do
|
||||
its('size') { should be > 64 }
|
||||
its('size') { should be < 10240 }
|
||||
end
|
||||
|
||||
describe file('/proc/cpuinfo') do
|
||||
its('size') { should be 0 }
|
||||
end
|
||||
|
||||
# @TODO selinux_label
|
||||
|
||||
# @TODO skip as the mount command is not reliably present on all test containers
|
||||
# describe file('/proc') do
|
||||
# it { should be_mounted }
|
||||
# end
|
||||
|
||||
describe file('/proc/cpuinfo') do
|
||||
it { should_not be_mounted }
|
||||
end
|
||||
|
||||
# @TODO immutable?
|
||||
# @TODO product_version
|
||||
# @TODO file_version
|
||||
# @TODO version?
|
||||
|
||||
require 'digest'
|
||||
cpuinfo = file('/proc/cpuinfo').content
|
||||
|
||||
md5sum = Digest::MD5.hexdigest(cpuinfo)
|
||||
describe file('/proc/cpuinfo') do
|
||||
its('md5sum') { should eq md5sum }
|
||||
end
|
||||
|
||||
sha256sum = Digest::SHA256.hexdigest(cpuinfo)
|
||||
describe file('/proc/cpuinfo') do
|
||||
its('sha256sum') { should eq sha256sum }
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# encoding: utf-8
|
||||
# author: Dominik Richter
|
||||
# author: Christoph Hartmann
|
||||
|
||||
return unless command('ssh').exist?
|
||||
|
||||
describe ssh_config do
|
||||
its('SendEnv') { should include('GORDON_CLIENT') }
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# encoding: utf-8
|
||||
# author: Dominik Richter
|
||||
# author: Christoph Hartmann
|
||||
|
||||
return unless command('sshd').exist?
|
||||
|
||||
describe sshd_config do
|
||||
its('AcceptEnv') { should include('GORDON_SERVER') }
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# encoding: utf-8
|
||||
# author: Joseph Benden
|
||||
|
||||
return unless os.bsd?
|
||||
return unless command('/sbin/zfs').exist?
|
||||
return unless command('/sbin/zpool').exist?
|
||||
|
||||
describe zfs_pool('tank') do
|
||||
it { should exist }
|
||||
its('failmode') { should eq('continue') }
|
||||
end
|
||||
|
||||
describe zfs_dataset('tank/tmp') do
|
||||
it { should exist }
|
||||
its('exec') { should eq('off') }
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
images:
|
||||
- centos:5.11
|
||||
- centos:7.0.1406
|
||||
- debian:6.0.10
|
||||
- fedora:20
|
||||
- oraclelinux:5.11
|
||||
- oraclelinux:6.7
|
||||
- oraclelinux:7.1
|
||||
- ubuntu:10.04
|
||||
- ubuntu:13.04
|
||||
- ubuntu:15.10
|
|
@ -1,11 +0,0 @@
|
|||
images:
|
||||
- centos:6.6
|
||||
- centos:6.7
|
||||
- centos:7.1.1503
|
||||
- debian:7.9
|
||||
- debian:8.2
|
||||
- fedora:21
|
||||
- fedora:22
|
||||
- ubuntu:12.04
|
||||
- ubuntu:14.04
|
||||
- ubuntu:15.04
|
Loading…
Reference in a new issue