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

Add tests for chef-server-running.json #1304

Merged
merged 6 commits into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion oc-chef-pedant/bin/oc-chef-pedant
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require 'rspec/core'
require 'pedant'
require 'pedant/organization'

Pedant.config.suite = "api"
Pedant.config.suite = ["api", "running_configs"]
Pedant.setup(ARGV)
puts Pedant::UI.new.info_banner

Expand Down
6 changes: 4 additions & 2 deletions oc-chef-pedant/lib/pedant/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ def self.from_argv(argv, option_sets)
# tests. Includes only the tests specified by the value of
# +Pedant.config.suite+.
def self.test_directories
suite = Pedant.config.suite || raise("Test suite unspecified! Set 'Pedant.config.suite' in the test runner!")
Pedant::Gem.test_directories(suite)
suites = Pedant.config.suite || raise("Test suite unspecified! Set 'Pedant.config.suite' in the test runner!")
Array(suites).map do |suite|
Pedant::Gem.test_directories(suite)
end
end


Expand Down
48 changes: 48 additions & 0 deletions oc-chef-pedant/spec/running_configs/analytics_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require 'json'
require 'pedant/rspec/common'

describe 'running configs required by Analytics Server', :config do
#
# The analyics add-on reads from actions-source.json which is only
# written out in some configurations.
#
running_config = JSON.parse(IO.read('/etc/opscode/chef-server-running.json'))
if !(running_config['private_chef']['insecure_addon_compat'] && running_config['private_chef']['dark_launch']['actions'])
skip 'Analytics config is only written when insecure_addon_compat = true && dark_launch["actions"] = true'
else
let(:actions_source) { JSON.parse(IO.read('/etc/opscode-analytics/actions-source.json')) }
let(:config) { actions_source['private_chef'] }

it 'api_fqdn' do
expect(config['api_fqdn'].to_s).to_not eq('')
end

it 'oc_id_application' do
expect(config['oc_id_application'].class).to eq(Hash)
end

it 'rabbitmq_host' do
expect(config['rabbitmq_host'].to_s).to_not eq('')
end

it 'rabbitmq_port' do
expect(config['rabbitmq_port'].to_i).to_not eq(0)
end

it 'rabbitmq_vhost' do
expect(config['rabbitmq_vhost'].to_s).to_not eq('')
end

it 'rabbitmq_exchange' do
expect(config['rabbitmq_exchange'].to_s).to_not eq('')
end

it 'rabbitmq_user' do
expect(config['rabbitmq_user'].to_s).to_not eq('')
end

it 'rabbitmq_password' do
expect(config['rabbitmq_password'].to_s).to_not eq('')
end
end
end
121 changes: 121 additions & 0 deletions oc-chef-pedant/spec/running_configs/ctl_command_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
require 'json'
require 'pedant/rspec/common'

describe "running configs required by chef-server-ctl", :config do
let (:complete_config) { JSON.parse(IO.read("/etc/opscode/chef-server-running.json")) }
let (:config) { complete_config['private_chef'] }

context "partybus upgrade framework" do
it "postgresql/vip" do
expect(config["postgresql"]["vip"].to_s).to_not eq('')
end

it "postgresql/port" do
expect(config["postgresql"]["port"].to_i).to_not eq(0)
end

it "postgresql/db_superuser" do
expect(config["postgresql"]["db_superuser"].to_s).to_not eq('')
end
end

context "migration 20" do
it "opscode-erchef/sql_user" do
expect(config["opscode-erchef"]["sql_user"].to_s).to_not eq('')
end

it "postgresql/vip" do
expect(config["postgresql"]["vip"].to_s).to_not eq('')
end

it "postgresql/port" do
expect(config["postgresql"]["port"].to_i).to_not eq(0)
end
end

context "migration 31" do
it "rabbitmq/user" do
expect(config["rabbitmq"]["user"].to_s).to_not eq('')
end

it "rabbitmq/actions_user" do
expect(config["rabbitmq"]["actions_user"].to_s).to_not eq('')
end

it "rabbitmq/management_user" do
expect(config["rabbitmq"]["management_user"].to_s).to_not eq('')
end
end

context "password" do
it "ldap/enabled" do
expect(config["ldap"]["enabled"]).to be(true).or be(false).or be(nil)
end
end

context "ha" do
it "runit/sv_dir" do
expect(complete_config["runit"]["sv_dir"].to_s).to_not eq("")
expect(File.exist?(complete_config["runit"]["sv_dir"])).to be(true)
end

it "keepalived/enable" do
expect(config['keepalived']['enable']).to be(true).or be(false)
end

it "keepalived/vrrp_instance_ipaddress" do
expect(config['keepalived']['vrrp_instance_ipaddress'])
end

it "keepalived/vrrp_instance_ipaddress_dev" do
expect(config['keepalived']['vrrp_instance_ipaddress_dev'])
end

it "keepalived/vrrp_instance_interface" do
expect(config['keepalived']['vrrp_instance_interface'])
end
end

context "reindex" do
it "fips_enabled" do
expect(config['fips_enabled']).to be(true).or be(false)
end

it "opscode-erchef/search_queue_mode" do
expect(config["opscode-erchef"]["search_queue_mode"]).to eq("rabbitmq")
.or eq("batch")
.or eq("inline")
end

it "redis_lb/vip" do
expect(config["redis_lb"]["vip"].to_s).to_not eq("")
end

it "redis_lb/port" do
expect(config["redis_lb"]["vip"].to_i).to_not eq(0)
end
end

context "reconfigure" do
#
# The cookbooks themselves require chef-server-running.json to
# populate previous_run.
#
it "bookshelf/storage_type" do
expect(config["bookshelf"]["storage_type"]).to eq("filesystem").or eq("sql")
end

it "opscode-solr4/external" do
expect(config["opscode-solr4"]["external"]).to eq(true).or eq(false)
end

it "postgresql/external" do
expect(config["postgresql"]["external"]).to eq(true).or eq(false)
end

it "postgresql/data_dir" do
expect(config["postgresql"]["data_dir"].to_s).to_not eq("")
expect(File.exist?(config["postgresql"]["data_dir"])).to eq(true)
end
end
end
42 changes: 42 additions & 0 deletions oc-chef-pedant/spec/running_configs/manage_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'json'
require 'pedant/rspec/common'

describe "running configs required by Manages", :config do
let (:config) { JSON.parse(IO.read("/etc/opscode/chef-server-running.json"))['private_chef'] }

it "lb/api_fqdn" do
expect(config['lb']['api_fqdn'].to_s).to_not eq ''
end

it "nginx/ssl_port" do
expect(config['nginx']['ssl_port'].to_i).to_not eq 0
end

it "nginx/ssl_protocols" do
expect(config['nginx']['ssl_protocols'].to_s).to_not eq ''
end

it "nginx/ssl_ciphers" do
expect(config['nginx']['ssl_ciphers'].to_s).to_not eq ''
end

it "nginx/ssl_certificate" do
expect(File.exists?(config['nginx']['ssl_certificate'])).to be true
end

it "nginx/ssl_certificate_key" do
expect(File.exists?(config['nginx']['ssl_certificate_key'])).to be true
end

it "nginx/dir" do
expect(File.exists?(File.join(config['nginx']['dir'], "etc/addon.d"))).to be true
end

it "opscode-erchef/strict_search_result_acls" do
expect(config['opscode-erchef']['strict_search_result_acls']).to be(true).or be(false)
end

it "ldap is a hash" do
expect(config['ldap'].class).to eq(Hash)
end
end
67 changes: 67 additions & 0 deletions oc-chef-pedant/spec/running_configs/pushy_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
require 'json'
require 'pedant/rspec/common'

describe "running configs required by Pushy Server", :config do
let (:complete_config) { JSON.parse(IO.read("/etc/opscode/chef-server-running.json")) }
let (:config) { complete_config['private_chef'] }

it "role" do
expect(config['role'].to_s).to eq("standalone").or eq("backend").or eq("frontend")
end

it "topology" do
expect(config['topology'].to_s).to eq("tier").or eq("ha").or eq("standalone")
end

it "postgresql/vip" do
expect(config['postgresql']['vip'].to_s).to_not eq ''
end

it "postgresql/port" do
expect(config['postgresql']['port'].to_i).to_not eq 0
end

it "postgresql/db_superuser" do
expect(config['postgresql']['db_superuser'].to_s).to_not eq ''
end

it "postgresql/vip or backend_vips/ipaddress" do
if ["ha", "tier"].include? config['topology']
expect(config['backend_vips']['ipaddress'].to_s).not_to eq ''
else
skip "not used for standalone"
end
end

it "postgresql/data_dir" do
expect(File.exists?(config['postgresql']['data_dir'])).to be true
end

it "postgresql/username" do
expect(config['postgresql']['username'].to_s).to_not eq ''
end

it "user/username" do
expect(config['user']['username'].to_s).to_not eq ''
end

it "nginx/dir" do
expect(File.exists?(File.join(config['nginx']['dir'], "etc/addon.d"))).to be true
end

it "nginx/ssl_protocols" do
expect(config['nginx']['ssl_protocols'].to_s).to_not eq ''
end

it "opscode-erchef/strict_search_result_acls" do
expect(config['opscode-erchef']['strict_search_result_acls']).to be(true).or be(false)
end

it "oc-chef-pedant/debug_org_creation" do
expect(config['oc-chef-pedant']['debug_org_creation']).to be(true).or be(false)
end

it "runit" do
expect(complete_config['runit'].class).to eq Hash
end
end
Loading