0

I have a file, with sections of content as following. I need to write server spec test file for portnumbers as it belongs to their respective section, as a part of puppet automation of a product.

path: etc/a.Cfg file

Global
 user abc
 group aaa

frontend one
 bind 10.1.0.15:80
 option tcp

frontend two
 bind 10.1.1.25:666
 option tcp 

frontend three 
 bind 10.2.2.45:444
 option tcp

I need to write serverspec test as if port 666 exits and is belonging to section frontend two. And similar way for 444, and 80 ports to exist and belong to their respective sections

I haave already created soe serverspec test statements which are related to checking if these sections exist. like serverspec.rb

 # to check frontend one is exst on server/VM for testing
describe file('a.cfg') do
  it { is_expected.to contain %r{^frontend one} } 
end

Similar way bt im not sure how to to write serverspec test as if port 666 exits and is belonging to section frontend two. And similar way for 444, and 80 ports to exist and belong to their respective sections

please help who know puppet, or serverspec.

Matthew Schuchard
  • 25,172
  • 3
  • 47
  • 67
gopi r
  • 1
  • 1
  • 1
    I'm not seeing how the question is related to Puppet. Even if the files you want to test are managed by Puppet, that has no particular bearing I know of on how you would write tests for them. – John Bollinger Apr 16 '20 at 01:46
  • Are you asking how to test the ports on the server, or the content of the file? – Matthew Schuchard Apr 16 '20 at 11:09
  • Hi Matt, I initially thought about ports related to server. But no, the guy who created ticket said, The port numbers related to contents of this file. And it should be related like section of file. – gopi r Apr 16 '20 at 13:19

0 Answers0