<commit_before>require 'spec_helper'

describe 'elasticsearch', :type => :class do
  let(:params) do
    { :cluster_name => 'foocluster' }
  end
  home = '/var/lib/elasticsearch-foocluster'

  it do
    should contain_package('elasticsearch')
    should contain_file(home)
      .with_ensure('directory')

    should contain_file("#{home}/config/logging.yml")

    should contain_file("#{home}/config/elasticsearch.yml")
      .with_content(/^\s*cluster.name: foocluster/)
      .with_content(/multicast.enabled: false/)
      .with_content(/mlockall: false/)
      .with_content(/unicast.hosts: \["localhost"\]/)

    should contain_file("/etc/init/elasticsearch-foocluster.conf")
      .with_content(/ES_HOME="#{home}"/)
      .with_content(/ES_HEAP_SIZE="512m"/)
  end

  context "with a list of cluster_hosts" do
    let(:params) do
      {
        :cluster_name => 'foocluster',
        :cluster_hosts => ['one', 'two', 'three']
      }
    end

    it do
      should contain_file("#{home}/config/elasticsearch.yml")
        .with_content(/unicast.hosts: \["one", "two", "three"\]/)<commit_msg>[#51888499] Added a test around publish_host for elasticsearch.yml<commit_after>require 'spec_helper'

describe 'elasticsearch', :type => :class do
  let(:params) do
    { :cluster_name => 'foocluster' }
  end
  home = '/var/lib/elasticsearch-foocluster'

  it do
    should contain_package('elasticsearch')
    should contain_file(home)
      .with_ensure('directory')

    should contain_file("#{home}/config/logging.yml")

    should contain_file("#{home}/config/elasticsearch.yml")
      .with_content(/^\s*cluster.name: foocluster/)
      .with_content(/multicast.enabled: false/)
      .with_content(/mlockall: false/)
      .with_content(/unicast.hosts: \["localhost"\]/)

    should contain_file("/etc/init/elasticsearch-foocluster.conf")
      .with_content(/ES_HOME="#{home}"/)
      .with_content(/ES_HEAP_SIZE="512m"/)
  end

  context "with a list of cluster_hosts" do
    let(:params) do
      {
        :cluster_name => 'foocluster',
        :cluster_hosts => ['one', 'two', 'three'],
        :host => 'one'
      }
    end

    it do
      should contain_file("#{home}/config/elasticsearch.yml")
        .with_content(/unicast.hosts: \["one", "two", "three"\]/)
        .with_content(/network\.publish_host: one/)
{'fraction_non_alphanumeric': 0.16144267926148562, 'fraction_numerical': 0.0060111635895234005, 'mean_word_length': 3.2286751361161525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '3204035', 'n_tokens_mistral': 787, 'n_tokens_neox': 751, 'n_words': 134}