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

Feature/ssh test #53

Merged
merged 12 commits into from
Dec 19, 2023
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ Directory structure:
├── configuration/
│ ├── ... > OR HERE
├── modules/
│ ├── monitor
| ├── ... > OR HERE
└── helpers/
├── ...
```
18 changes: 18 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
23 changes: 23 additions & 0 deletions spec/services/ssh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading