Sha256: 6d6ef32e69bb3e5d090d8653671dcc7504cef42570a73ee9720d52f125a01f35

Contents?: true

Size: 1.74 KB

Versions: 31

Compression:

Stored size: 1.74 KB

Contents

require 'json'
require 'hybrid_platforms_conductor/common_config_dsl/idempotence_tests'

module HybridPlatformsConductor

  module HpcPlugins

    module Test

      # Test that the node has not diverged since last deployment
      class Divergence < HybridPlatformsConductor::Test

        extend_config_dsl_with CommonConfigDsl::IdempotenceTests, :init_idempotence_tests

        # Check my_test_plugin.rb.sample documentation for signature details.
        def test_on_check_node(stdout, stderr, _exit_status)
          # Check that the output of the check-node returns no changes.
          ignored_tasks = @nodes_handler.select_confs_for_node(@node, @config.ignored_divergent_tasks).inject({}) do |merged_ignored_tasks, conf|
            merged_ignored_tasks.merge(conf[:ignored_tasks])
          end
          @deployer.parse_deploy_output(@node, stdout, stderr).each do |task_info|
            if task_info[:status] == :changed
              if ignored_tasks.key?(task_info[:name])
                # It was expected that this task is not idempotent
                log_debug "Task #{task_info[:name]} was expected to be divergent. Reason: #{ignored_tasks[task_info[:name]]}"
              else
                extra_details = task_info.slice(*(task_info.keys - %i[name status diffs]))
                error_details = []
                error_details << "----- Changes:\n#{task_info[:diffs].strip}\n-----" if task_info[:diffs]
                error_details << "----- Additional details:\n#{JSON.pretty_generate(extra_details)}\n-----" unless extra_details.empty?
                error "Task #{task_info[:name]} has diverged", error_details.empty? ? nil : error_details.join("\n")
              end
            end
          end
        end

      end

    end

  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
hybrid_platforms_conductor-33.9.5 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.9.4 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.9.2 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.9.1 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.9.0 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.8.4 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.8.3 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.8.2 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.8.1 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.8.0 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.7.4 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.7.3 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.7.2 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.7.1 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.7.0 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.6.0 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.5.1 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.5.0 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.4.0 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb
hybrid_platforms_conductor-33.3.0 lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb