hybrid_platforms_conductor 32.17.1 → 32.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/README.md +3 -0
  4. data/bin/last_deploys +4 -1
  5. data/bin/nodes_to_deploy +5 -5
  6. data/docs/config_dsl.md +22 -0
  7. data/docs/gen/mermaid/README.md-0.png +0 -0
  8. data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
  9. data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
  10. data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
  11. data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
  12. data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
  13. data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
  14. data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
  15. data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
  16. data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
  17. data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
  18. data/docs/plugins.md +25 -0
  19. data/docs/plugins/log/remote_fs.md +26 -0
  20. data/lib/hybrid_platforms_conductor/actions_executor.rb +8 -1
  21. data/lib/hybrid_platforms_conductor/deployer.rb +96 -104
  22. data/lib/hybrid_platforms_conductor/hpc_plugins/log/my_log_plugin.rb.sample +100 -0
  23. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +179 -0
  24. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +7 -20
  25. data/lib/hybrid_platforms_conductor/log.rb +31 -0
  26. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  27. data/spec/hybrid_platforms_conductor_test.rb +22 -6
  28. data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +24 -4
  29. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +187 -212
  30. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +223 -0
  31. data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +1 -1
  32. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +146 -98
  33. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +240 -83
  34. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +2 -1
  35. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +40 -53
  36. data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +2 -2
  37. data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +82 -0
  38. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +103 -0
  39. metadata +10 -2
@@ -69,7 +69,7 @@ module HybridPlatformsConductorTest
69
69
  }
70
70
  end
71
71
  end
72
- actions << proc { |actions_per_nodes| expect_actions_to_upload_logs(actions_per_nodes, services.keys, sudo: sudo) }
72
+ actions << proc { |actions_per_nodes| expect_actions_to_upload_logs(actions_per_nodes, services.keys) }
73
73
  end
74
74
  actions
75
75
  end
@@ -109,7 +109,7 @@ module HybridPlatformsConductorTest
109
109
  additional_config: ''
110
110
  )
111
111
  platform_name = check_mode ? 'platform' : 'my_remote_platform'
112
- with_test_platform(nodes_info, !check_mode, additional_config) do |repository|
112
+ with_test_platform(nodes_info, !check_mode, additional_config + "\nsend_logs_to :test_log") do |repository|
113
113
  # Mock the ServicesHandler accesses
114
114
  expect_services_to_deploy = Hash[nodes_info[:nodes].map do |node, node_info|
115
115
  [node, node_info[:services]]
@@ -0,0 +1,82 @@
1
+ module HybridPlatformsConductorTest
2
+
3
+ # Test log without reading actions
4
+ class TestLogNoReadPlugin < HybridPlatformsConductor::Log
5
+
6
+ class << self
7
+ attr_accessor :calls
8
+ end
9
+
10
+ # Get actions to save logs
11
+ # [API] - This method is mandatory.
12
+ # [API] - The following API components are accessible:
13
+ # * *@config* (Config): Main configuration API.
14
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
15
+ # * *@actions_executor* (ActionsExecutor): Actions executor API.
16
+ #
17
+ # Parameters::
18
+ # * *node* (String): Node for which logs are being saved
19
+ # * *services* (Array<String>): The list of services that have been deployed on this node
20
+ # * *deployment_info* (Hash<Symbol,Object>): Additional information to attach to the logs
21
+ # * *exit_status* (Integer or Symbol): Exit status of the deployment
22
+ # * *stdout* (String): Deployment's stdout
23
+ # * *stderr* (String): Deployment's stderr
24
+ # Result::
25
+ # * Array< Hash<Symbol,Object> >: List of actions to be done
26
+ def actions_to_save_logs(node, services, deployment_info, exit_status, stdout, stderr)
27
+ TestLogNoReadPlugin.calls << {
28
+ method: :actions_to_save_logs,
29
+ node: node,
30
+ services: services,
31
+ # Don't store the date
32
+ deployment_info: deployment_info.select { |k, _v| k != :date },
33
+ exit_status: exit_status,
34
+ stdout: stdout,
35
+ stderr: stderr
36
+ }
37
+ [{ bash: "echo Save test logs to #{node}" }]
38
+ end
39
+
40
+ # Get deployment logs from a node.
41
+ # This method can use the result of actions previously run to read logs, as returned by the actions_to_read_logs method.
42
+ # [API] - This method is mandatory.
43
+ # [API] - The following API components are accessible:
44
+ # * *@config* (Config): Main configuration API.
45
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
46
+ # * *@actions_executor* (ActionsExecutor): Actions executor API.
47
+ #
48
+ # Parameters::
49
+ # * *node* (String): The node we want deployment logs from
50
+ # * *exit_status* (Integer, Symbol or nil): Exit status of actions to read logs, or nil if no action was returned by actions_to_read_logs
51
+ # * *stdout* (String or nil): stdout of actions to read logs, or nil if no action was returned by actions_to_read_logs
52
+ # * *stderr* (String or nil): stderr of actions to read logs, or nil if no action was returned by actions_to_read_logs
53
+ # Result::
54
+ # * Hash<Symbol,Object>: Deployment log information:
55
+ # * *error* (String): Error string in case deployment logs could not be retrieved. If set then further properties will be ignored. [optional]
56
+ # * *services* (Array<String>): List of services deployed on the node
57
+ # * *deployment_info* (Hash<Symbol,Object>): Deployment metadata
58
+ # * *exit_status* (Integer or Symbol): Deployment exit status
59
+ # * *stdout* (String): Deployment stdout
60
+ # * *stderr* (String): Deployment stderr
61
+ def logs_for(node, exit_status, stdout, stderr)
62
+ TestLogNoReadPlugin.calls << {
63
+ method: :logs_for,
64
+ node: node,
65
+ exit_status: exit_status,
66
+ stdout: stdout,
67
+ stderr: stderr
68
+ }
69
+ {
70
+ services: %w[unknown],
71
+ deployment_info: {
72
+ user: 'test_user'
73
+ },
74
+ exit_status: 666,
75
+ stdout: 'Deployment test stdout',
76
+ stderr: 'Deployment test stderr'
77
+ }
78
+ end
79
+
80
+ end
81
+
82
+ end
@@ -0,0 +1,103 @@
1
+ module HybridPlatformsConductorTest
2
+
3
+ # Test log
4
+ class TestLogPlugin < HybridPlatformsConductor::Log
5
+
6
+ class << self
7
+ attr_accessor :calls
8
+ end
9
+
10
+ # Get actions to save logs
11
+ # [API] - This method is mandatory.
12
+ # [API] - The following API components are accessible:
13
+ # * *@config* (Config): Main configuration API.
14
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
15
+ # * *@actions_executor* (ActionsExecutor): Actions executor API.
16
+ #
17
+ # Parameters::
18
+ # * *node* (String): Node for which logs are being saved
19
+ # * *services* (Array<String>): The list of services that have been deployed on this node
20
+ # * *deployment_info* (Hash<Symbol,Object>): Additional information to attach to the logs
21
+ # * *exit_status* (Integer or Symbol): Exit status of the deployment
22
+ # * *stdout* (String): Deployment's stdout
23
+ # * *stderr* (String): Deployment's stderr
24
+ # Result::
25
+ # * Array< Hash<Symbol,Object> >: List of actions to be done
26
+ def actions_to_save_logs(node, services, deployment_info, exit_status, stdout, stderr)
27
+ TestLogPlugin.calls << {
28
+ method: :actions_to_save_logs,
29
+ node: node,
30
+ services: services,
31
+ # Don't store the date
32
+ deployment_info: deployment_info.select { |k, _v| k != :date },
33
+ exit_status: exit_status,
34
+ stdout: stdout,
35
+ stderr: stderr
36
+ }
37
+ [{ bash: "echo Save test logs to #{node}" }]
38
+ end
39
+
40
+ # Get actions to read logs.
41
+ # If provided, this method can return some actions to be executed that will fetch logs from servers or remote nodes.
42
+ # By using this method to run actions instead of the synchronous method logs_from, such actions will be run in parallel which can greatly improve time-consuming operations when querying a lot of nodes.
43
+ # [API] - This method is optional.
44
+ # [API] - The following API components are accessible:
45
+ # * *@config* (Config): Main configuration API.
46
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
47
+ # * *@actions_executor* (ActionsExecutor): Actions executor API.
48
+ #
49
+ # Parameters::
50
+ # * *node* (String): Node for which deployment logs are being read
51
+ # Result::
52
+ # * Array< Hash<Symbol,Object> >: List of actions to be done
53
+ def actions_to_read_logs(node)
54
+ TestLogPlugin.calls << {
55
+ method: :actions_to_read_logs,
56
+ node: node
57
+ }
58
+ [{ bash: "echo Read logs for #{node}" }]
59
+ end
60
+
61
+ # Get deployment logs from a node.
62
+ # This method can use the result of actions previously run to read logs, as returned by the actions_to_read_logs method.
63
+ # [API] - This method is mandatory.
64
+ # [API] - The following API components are accessible:
65
+ # * *@config* (Config): Main configuration API.
66
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
67
+ # * *@actions_executor* (ActionsExecutor): Actions executor API.
68
+ #
69
+ # Parameters::
70
+ # * *node* (String): The node we want deployment logs from
71
+ # * *exit_status* (Integer, Symbol or nil): Exit status of actions to read logs, or nil if no action was returned by actions_to_read_logs
72
+ # * *stdout* (String or nil): stdout of actions to read logs, or nil if no action was returned by actions_to_read_logs
73
+ # * *stderr* (String or nil): stderr of actions to read logs, or nil if no action was returned by actions_to_read_logs
74
+ # Result::
75
+ # * Hash<Symbol,Object>: Deployment log information:
76
+ # * *error* (String): Error string in case deployment logs could not be retrieved. If set then further properties will be ignored. [optional]
77
+ # * *services* (Array<String>): List of services deployed on the node
78
+ # * *deployment_info* (Hash<Symbol,Object>): Deployment metadata
79
+ # * *exit_status* (Integer or Symbol): Deployment exit status
80
+ # * *stdout* (String): Deployment stdout
81
+ # * *stderr* (String): Deployment stderr
82
+ def logs_for(node, exit_status, stdout, stderr)
83
+ TestLogPlugin.calls << {
84
+ method: :logs_for,
85
+ node: node,
86
+ exit_status: exit_status,
87
+ stdout: stdout,
88
+ stderr: stderr
89
+ }
90
+ {
91
+ services: %w[unknown],
92
+ deployment_info: {
93
+ user: 'test_user'
94
+ },
95
+ exit_status: 666,
96
+ stdout: 'Deployment test stdout',
97
+ stderr: 'Deployment test stderr'
98
+ }
99
+ end
100
+
101
+ end
102
+
103
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hybrid_platforms_conductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 32.17.1
4
+ version: 32.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-03 00:00:00.000000000 Z
11
+ date: 2021-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: range_operators
@@ -354,6 +354,7 @@ extra_rdoc_files:
354
354
  - docs/executables/dump_nodes_json.md
355
355
  - docs/plugins/platform_handler/serverless_chef.md
356
356
  - docs/plugins/platform_handler/yaml_inventory.md
357
+ - docs/plugins/log/remote_fs.md
357
358
  - docs/plugins/provisioner/proxmox.md
358
359
  - docs/plugins/provisioner/podman.md
359
360
  - docs/plugins/provisioner/docker.md
@@ -533,6 +534,7 @@ files:
533
534
  - docs/plugins/cmdb/platform_handlers.md
534
535
  - docs/plugins/connector/local.md
535
536
  - docs/plugins/connector/ssh.md
537
+ - docs/plugins/log/remote_fs.md
536
538
  - docs/plugins/platform_handler/serverless_chef.md
537
539
  - docs/plugins/platform_handler/yaml_inventory.md
538
540
  - docs/plugins/provisioner/docker.md
@@ -679,6 +681,8 @@ files:
679
681
  - lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb
680
682
  - lib/hybrid_platforms_conductor/hpc_plugins/connector/my_connector.rb.sample
681
683
  - lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb
684
+ - lib/hybrid_platforms_conductor/hpc_plugins/log/my_log_plugin.rb.sample
685
+ - lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb
682
686
  - lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/platform_handler_plugin.rb.sample
683
687
  - lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb
684
688
  - lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb
@@ -733,6 +737,7 @@ files:
733
737
  - lib/hybrid_platforms_conductor/hpc_plugins/test_report/templates/confluence.html.erb
734
738
  - lib/hybrid_platforms_conductor/io_router.rb
735
739
  - lib/hybrid_platforms_conductor/json_dumper.rb
740
+ - lib/hybrid_platforms_conductor/log.rb
736
741
  - lib/hybrid_platforms_conductor/logger_helpers.rb
737
742
  - lib/hybrid_platforms_conductor/mutex_dir
738
743
  - lib/hybrid_platforms_conductor/nodes_handler.rb
@@ -783,6 +788,7 @@ files:
783
788
  - spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb
784
789
  - spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb
785
790
  - spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb
791
+ - spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb
786
792
  - spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb
787
793
  - spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb
788
794
  - spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker/Dockerfile
@@ -925,6 +931,8 @@ files:
925
931
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/policyfiles/test_policy_2.rb
926
932
  - spec/hybrid_platforms_conductor_test/test_action.rb
927
933
  - spec/hybrid_platforms_conductor_test/test_connector.rb
934
+ - spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb
935
+ - spec/hybrid_platforms_conductor_test/test_log_plugin.rb
928
936
  - spec/hybrid_platforms_conductor_test/test_plugins/global.rb
929
937
  - spec/hybrid_platforms_conductor_test/test_plugins/node.rb
930
938
  - spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb