<commit_before># Test Case 4: Service with node (node groups = 2) that contains cmp with bash and rspec actions
# This test script will test following: 
# - converge service instance with action module component
# - execute actions (bash and rspec) on multiple nodes that are part of node group

require './lib/dtk_cli_spec'
require './lib/dtk_common'

assembly_name = 'node-group'
service_name = 'af_test_case_4_instance'
module_location = '/tmp/action_module'
module_name = 'r8/action_module'
module_version = 'master'
service_location = '~/dtk/'
service_instance_location = '~/dtk/af_test_case_4_instance'

dtk_common = Common.new(service_name, assembly_name)

expected_output_1 = {
  command: '/bin/sh /etc/puppet/modules/action_module/bash_tests/test_bash.sh',
  status: 'succeeded',
  return_code: 0
}

expected_output_2 = {
  command: '/opt/puppet-omnibus/embedded/bin/rspec /etc/puppet/modules/action_module/rspec_tests/spec/test_spec.rb',
  status: 'succeeded',
  return_code: 0
}

describe '(Action Framework) Test Case 4: Service with node (node groups = 2) that contains cmp with bash and rspec actions' do
  before(:all) do
    puts '*****************************************************************************************************************', ''
    # Install/clone r8:action_module module with required dependency modules if needed
    location_exist = system("ls #{module_location}")
    unless location_exist
      system("mkdir #{module_location}")
      system("dtk module clone -v #{module_version} #{module_name} #{module_location}")
      system("dtk module install --update-deps -d #{module_location} #{module_name}")
    end
  end

  context "Stage assembly from module" do
    include_context "Stage assembly from module", module_name, module_location, assembly_name, service_name
  end

  context "Converge service instance" do<commit_msg>small fix in test script<commit_after># Test Case 4: Service with node (node groups = 2) that contains cmp with bash and rspec actions
# This test script will test following: 
# - converge service instance with action module component
# - execute actions (bash and rspec) on multiple nodes that are part of node group

require './lib/dtk_cli_spec'
require './lib/dtk_common'

assembly_name = 'node-group'
service_name = 'af_test_case_4_instance'
module_location = '/tmp/action_module'
module_name = 'r8/action_module'
module_version = 'master'
service_location = '~/dtk/'
service_instance_location = '~/dtk/af_test_case_4_instance'

dtk_common = Common.new(service_name, assembly_name)

expected_output_1 = {
  command: '/bin/sh /etc/puppet/modules/action_module/files/bash_tests/test_bash.sh',
  status: 'succeeded',
  return_code: 0,
  stderr: 'ls: cannot access /tmp/action_framework_test/test.txt: No such file or directory'
}

expected_output_2 = {
  command: 'export HOME=/home/ubuntu && cd /etc/puppet/modules/action_module/files/rspec_tests && /opt/puppet-omnibus/embedded/bin/rspec ./spec/test_spec.rb',
  status: 'succeeded',
  return_code: 0
}

describe '(Action Framework) Test Case 4: Service with node (node groups = 2) that contains cmp with bash and rspec actions' do
  before(:all) do
    puts '*****************************************************************************************************************', ''
    # Install/clone r8:action_module module with required dependency modules if needed
    location_exist = system("ls #{module_location}")
    unless location_exist
      system("mkdir #{module_location}")
      system("dtk module clone -v #{module_version} #{module_name} #{module_location}")
      system("dtk module install --update-deps -d #{module_location} #{module_name}")
    end
  end

  context "Stage assembly from module" do
    include_context "Stage assembly from module", module_name, module_location, assembly_name, service_name
  end

  context "Converge service instance" do
{'fraction_non_alphanumeric': 0.15609756097560976, 'fraction_numerical': 0.0061617458279845955, 'mean_word_length': 5.1257861635220126, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5530428', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1139, 'n_words': 336}