Class: HybridPlatformsConductor::HpcPlugins::Test::LocalUsers

Inherits:
TestOnlyRemoteNode show all
Defined in:
lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb

Overview

Test that the node’s local users

Defined Under Namespace

Modules: ConfigDslExtension

Constant Summary

Constants included from LoggerHelpers

LoggerHelpers::LEVELS_MODIFIERS, LoggerHelpers::LEVELS_TO_STDERR

Instance Attribute Summary

Attributes inherited from Test

#errors, #expected_failure, #name, #node, #platform

Instance Method Summary collapse

Methods inherited from TestOnlyRemoteNode

only_on_nodes

Methods inherited from Test

#assert_equal, #assert_match, #error, #executed, #executed?, #initialize, only_on_nodes, only_on_platforms, #to_s

Methods inherited from Plugin

extend_config_dsl_with, #initialize, valid?

Methods included from LoggerHelpers

#err, #init_loggers, #log_component=, #log_debug?, #log_level=, #out, #section, #set_loggers_format, #stderr_device, #stderr_device=, #stderr_displayed?, #stdout_device, #stdout_device=, #stdout_displayed?, #stdouts_to_s, #with_progress_bar

Constructor Details

This class inherits a constructor from HybridPlatformsConductor::Test

Instance Method Details

#test_on_nodeObject

Check my_test_plugin.rb.sample documentation for signature details.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb', line 60

def test_on_node
  {
    # TODO: Access the user correctly when the user notion will be moved out of the ssh connector
    "#{@deployer.instance_variable_get(:@actions_executor).connector(:ssh).ssh_user == 'root' ? '' : "#{@nodes_handler.sudo_on(@node)} "}cat /etc/passwd" => proc do |stdout|
      passwd_users = stdout.map { |passwd_line| passwd_line.split(':').first }
      missing_users = @nodes_handler.
        select_confs_for_node(@node, @config.users_that_should_be_present).
        inject([]) { |merged_users, users_info| merged_users + users_info[:users] }.
        uniq - passwd_users
      error "Missing local users that should be present: #{missing_users.join(', ')}" unless missing_users.empty?
      extra_users = passwd_users & @nodes_handler.
        select_confs_for_node(@node, @config.users_that_should_be_absent).
        inject([]) { |merged_users, users_info| merged_users + users_info[:users] }.
        uniq
      error "Extra local users that should be absent: #{extra_users.join(', ')}" unless extra_users.empty?
    end
  }
end