<commit_before>require_relative '../spec_helper.rb'

describe service('zabbix_agentd') do
  it { should be_enabled }
end

describe port(10_050) do
  it { should be_listening.with('tcp') }
end

describe 'connect jmx_server' do
  servers = property[:servers]
  servers.each do |var, server|
    case var[:roles]
    when "ap" then
      if File.exist?('/etc/sysconfig/tomcat7')
        describe "#{svr_name} access check" do
          describe command("hping3 -S #{server[:private_ip]} -p 12345 -c 5") do
            its(:stdout) { should match '/sport=12345 flags=SA/' }
          end
          describe command("hping3 -S #{server[:private_ip]} -p 12346 -c 5") do
            its(:stdout) { should match '/sport=12346 flags=SA/' }
          end
        end
      end
    end
  end
end

describe 'connect zbx_server' do
  servers = property[:servers]

  servers.each do |svr_name, server|
    next unless server[:roles] == 'monitoring'
    describe "#{svr_name} access check" do
      describe command("hping3 -S #{server[:private_ip]} -p 10051 -c 5") do
        its(:stdout) { should match '/sport=10051 flags=SA/' }
      end
    end
  end
end<commit_msg>Modify logic of spec test files.<commit_after>require_relative '../spec_helper.rb'

describe service('zabbix_agentd') do
  it { should be_enabled }
end

describe port(10_050) do
  it { should be_listening.with('tcp') }
end

describe 'connect jmx_server' do
  servers = property[:servers]
  servers['roles'].each do |svr_name,server|
    server['roles'].each do |var|
      case var
      when "ap" then
        if File.exist?('/etc/sysconfig/tomcat7')
          describe "#{svr_name} access check" do
            describe command("hping3 -S #{server[:private_ip]} -p 12345 -c 5") do
              its(:stdout) { should match '/sport=12345 flags=SA/' }
            end
            describe command("hping3 -S #{server[:private_ip]} -p 12346 -c 5") do
              its(:stdout) { should match '/sport=12346 flags=SA/' }
            end
          end
        end
      end
    end
  end
end

describe 'connect zbx_server' do
  servers = property[:servers]

  servers.each do |svr_name, server|
    next unless server[:roles] == 'monitoring'
    describe "#{svr_name} access check" do
      describe command("hping3 -S #{server[:private_ip]} -p 10051 -c 5") do
        its(:stdout) { should match '/sport=10051 flags=SA/' }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12603993344425957, 'fraction_numerical': 0.03494176372712146, 'mean_word_length': 2.6717557251908395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4217054', 'n_tokens_mistral': 840, 'n_tokens_neox': 783, 'n_words': 227}