<commit_before>require 'stacks/environment'

describe 'Stacks::VirtualService' do
  before do
    extend Stacks::DSL
  end

  it 'provides the default vips when to_vip_spec is run' do
    stack "test" do
      virtual_appserver 'myvs'
    end

    env 'env', :primary_site => 'mars' do
      instantiate_stack 'test'
    end

    vip_spec = find('env-myvs-001.mgmt.mars.net.local').virtual_service.to_vip_spec
    vip_spec[:qualified_hostnames].should eql(:prod => 'env-myvs-vip.mars.net.local')
  end

  it 'provides the both front and prod vips when if enable_nat is turned on' do
    stack "test" do
      virtual_appserver 'myvs' do
        enable_nat
      end
    end

    env 'env', :primary_site => 'mars' do
      instantiate_stack 'test'
    end

    vip_spec = find('env-myvs-001.mgmt.mars.net.local').virtual_service.to_vip_spec
    vip_spec[:qualified_hostnames].should eql(:prod  => 'env-myvs-vip.mars.net.local',
                                              :front => 'env-myvs-vip.front.mars.net.local')
  end

  it 'allows a virtual service to add a vip on additional networks' do
    stack "test" do
      virtual_appserver 'myvs' do
        add_vip_network :mgmt
      end
    end

    env 'env', :primary_site => 'mars' do
      instantiate_stack 'test'
    end

    vip_spec = find('env-myvs-001.mgmt.mars.net.local').virtual_service.to_vip_spec
    vip_spec[:qualified_hostnames].should eql(:prod => 'env-myvs-vip.mars.net.local',
                                              :mgmt => 'env-myvs-vip.mgmt.mars.net.local')
  end
end
<commit_msg>rpearce: Convert virtual_service_spec tests to use newer test_framework<commit_after>require 'stacks/test_framework'

describe 'Stacks::VirtualService' do
  describe_stack 'provides the default vips when to_vip_spec is run' do
    given do
      stack "test" do
        virtual_appserver 'myvs'
      end

      env 'env', :primary_site => 'mars' do
        instantiate_stack 'test'
      end
    end

    host('env-myvs-001.mgmt.mars.net.local') do |host|
      vip_spec = host.virtual_service.to_vip_spec
      vip_spec[:qualified_hostnames].should eql(:prod => 'env-myvs-vip.mars.net.local')
    end
  end

  describe_stack 'provides the both front and prod vips when if enable_nat is turned on' do
    given do
      stack "test" do
        virtual_appserver 'myvs' do
          enable_nat
        end
      end

      env 'env', :primary_site => 'mars' do
        instantiate_stack 'test'
      end
    end

    host('env-myvs-001.mgmt.mars.net.local') do |host|
      vip_spec = host.virtual_service.to_vip_spec
      vip_spec[:qualified_hostnames].should eql(
        :prod  => 'env-myvs-vip.mars.net.local',
        :front => 'env-myvs-vip.front.mars.net.local'
      )
    end
  end

  describe_stack 'allows a virtual service to add a vip on additional networks' do
    given do
      stack "test" do
        virtual_appserver 'myvs' do
          add_vip_network :mgmt
        end
      end

      env 'env', :primary_site => 'mars' do
        instantiate_stack 'test'
      end
    end

    host('env-myvs-001.mgmt.mars.net.local') do |host|
      vip_spec = host.virtual_service.to_vip_spec
      vip_spec[:qualified_hostnames].should eql(
        :prod => 'env-myvs-vip.mars.net.local',
        :mgmt => 'env-myvs-vip.mgmt.mars.net.local'
      )
    end
  end
end

{'fraction_non_alphanumeric': 0.10433482810164424, 'fraction_numerical': 0.0053811659192825115, 'mean_word_length': 2.467357512953368, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6420723', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1158, 'n_words': 265}