<commit_before>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
end<commit_msg>[pedant] Add checks for previous_run config used in reconfigure command<commit_after>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
{'fraction_non_alphanumeric': 0.15165045447297082, 'fraction_numerical': 0.002551427204592569, 'mean_word_length': 3.0334405144694534, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6812391', 'n_tokens_mistral': 2222, 'n_tokens_neox': 2220, 'n_words': 385}