diff --git a/README.md b/README.md index ef87428..4319236 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,82 @@ ## redborder-serverspec-manager + Infrastructure integration testing for a redborder manager machine. The idea is to run the tests in a machine that is the validator local machine, so the target machine is affected by the tests. ## Installation + First, clone this repository on your workstation. Then install the gemes by executing this: -```ssh + +```cmd bundle install ``` + Sometimes you need to make sure that you share your public ssh key to target machine: -``` + +```cmd ssh-copy-id root@ ``` ## Running Tests + To run all tests, use the following command: -``` + +```cmd rake spec ``` Optional parameters: -* TARGET_HOST: Machine where the tests will run via SSH. -* LOGIN_USERNAME: Username for SSH connection to the test machine. -* LOGIN_PASSWORD: Password for SSH connection to the test machine. -* IS_CLUSTER: Boolean to indicate if the target machine is a cluster. -* -j 10 -m: To run tests in pararell -Example with optional parameters: -``` -TARGET_HOST="10.1.209.50" LOGIN_USERNAME="root" LOGIN_PASSWORD="redborder" rake spec + +- **TARGET_HOST**: Machine where the tests will run via SSH. +- **LOGIN_USERNAME**: Username for SSH connection to the test machine. +- **LOGIN_PASSWORD**: Password for SSH connection to the test machine. +- **IS_CLUSTER**: Boolean to indicate if the target machine is a cluster. +- **-j 10 -m**: To run tests in pararell + Example with optional parameters: + +```cmd +IS_CLUSTER="false" TARGET_HOST="10.1.209.50" LOGIN_USERNAME="root" LOGIN_PASSWORD="redborder" rake spec ``` To run a specific test type, use the following command: -``` + +```cmd rake spec:configuration ``` To run a specific test in a spec file, better use tags: -``` + +```cmd rspec --tag tag_name -To run a specific script test, use the following command: ``` -rspec spec/services/cgroup_spec.rb + +To run a specific script test, use the following command: + +```cmd +rspec spec/services/cgroup_spec.rb ``` List of Available Rake Tasks: -To view the list of available Rake tasks, use the following command: -``` + +```cmd rake -T ``` ## Developing tests -On creating a new test, is important to follow the Rakefile structure as the directory structure. +When creating a new test, it is important to follow the directory structure outlined in the Rakefile. This structure helps maintain organization and clarity within the test suite. Directory structure: -``` -└── spec/ - ├── spec_helper.rb - │ - ├── services/ - │ ├── ... > PUT YOUR TESTS HERE - │ - ├── configuration/ - │ ├── ... > OR HERE - │ - ├── modules/ - │ ├── monitor - | ├── ... > OR HERE - │ - └── helpers/ - ├── ... -``` -Tag a describe to run by specific command ie: -``` -describe ("Any test for this"), :tagname do -``` +```conf +spec/ +├── spec_helper.rb +├── services/ +│ ├── ... # Place your service-related tests here +├── configuration/ +│ ├── ... # Place your configuration-related tests here +├── modules/ +│ ├── monitor/ +│ ├── ... # Place your module-related tests here +└── helpers/ + ├── ... # Place your helper-related tests here +``` \ No newline at end of file diff --git a/spec/configuration/kafka_spec.rb b/spec/configuration/kafka_spec.rb new file mode 100644 index 0000000..d1571d6 --- /dev/null +++ b/spec/configuration/kafka_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' +set :os, family: 'redhat', release: '9', arch: 'x86_64' +pipelines = %w[ + rb_event rb_event_post + rb_monitor rb_monitor_post + rb_loc rb_locne rb_loc_post rb_loc_post_discard rb_location + rb_mobile + rb_radius + rb_nmsp + rb_metrics + rb_state rb_state_post + rb_vault rb_vault_post + rb_http2k_sync + sflow +] + +describe 'Check logstash config' do + describe file('/etc/kafka/topics_definitions.yml') do + it { should exist } + it { should be_file } + it { should be_readable } + it { should be_writable.by_user('kafka') } + it { should_not be_writable.by('others') } + it { should_not be_executable } + pipelines.each do |pipeline| + it { should contain pipeline } + end + end +end diff --git a/spec/configuration/network_spec.rb b/spec/configuration/network_spec.rb index abaa49b..4047359 100644 --- a/spec/configuration/network_spec.rb +++ b/spec/configuration/network_spec.rb @@ -31,7 +31,7 @@ sync = command('ip addr show').stdout it 'Have a network sync' do interfaces_with_ip = sync.scan(/inet\s+(\d+\.\d+\.\d+\.\d+)/).flatten - if ENV['IS_CLUSTER'] + if ENV['IS_CLUSTER'] == 'true' expect(interfaces_with_ip.length).to be >= 3 else skip 'One node does not need sync interface'