diff --git a/README.md b/README.md index cde9f0c..d1ff784 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,10 @@ Directory structure: ├── configuration/ │ ├── ... > OR HERE │ + ├── modules/ + │ ├── monitor + | ├── ... > OR HERE + │ └── helpers/ ├── ... ``` diff --git a/Rakefile b/Rakefile index f873215..8fabb29 100644 --- a/Rakefile +++ b/Rakefile @@ -6,6 +6,17 @@ require 'rspec/core/rake_task' task default: :spec task spec: 'spec:all' +task ssh: 'only:ssh' + +namespace :only do + host = ENV['TARGET_HOST'] || '10.1.209.20' + desc 'run ssh within the cluster' + RSpec::Core::RakeTask.new(:ssh) do |t| + puts "Running configuration tests on #{host} ..." + t.pattern = 'spec/services/ssh_spec.rb' + t.rspec_opts = '--format documentation' # O "--format progress" + end +end namespace :spec do host = ENV['TARGET_HOST'] || '10.1.209.20' @@ -31,4 +42,11 @@ namespace :spec do t.pattern = 'spec/modules/monitor/*_spec.rb' t.rspec_opts = '--format documentation' # O "--format progress" end + + desc 'run configuration tests' + RSpec::Core::RakeTask.new(:configuration) do |t| + puts "Running configuration tests on #{host} ..." + t.pattern = 'spec/configuration/*_spec.rb' + t.rspec_opts = '--format documentation' # O "--format progress" + end end diff --git a/spec/services/ssh_spec.rb b/spec/services/ssh_spec.rb index a00e920..2bdf22d 100644 --- a/spec/services/ssh_spec.rb +++ b/spec/services/ssh_spec.rb @@ -5,3 +5,26 @@ describe port(22) do it { should be_listening } end + +describe 'Service is enabled and running' do + describe service('sshd') do + it { should be_enabled } + it { should be_running } + end +end + +NODE_LIST = command('red node list 2>/dev/null').stdout.chomp.split("\n") +describe 'Executing commands into nodes one by one' do + it 'There is at least one node in the list' do + expect(NODE_LIST).not_to be_empty + end + + NODE_LIST.each do |node| + it "Executing basic echo on Node: #{node}" do + result = command("red node execute #{node} 'echo SERVERSPEC'") + expect(result.exit_status).to eq(0) + expect(result.stdout).to include(node.to_s) + expect(result.stdout).to include('SERVERSPEC') + end + end +end