laborantin 0.0.14 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. data/INFO +1 -0
  2. data/README +148 -4
  3. data/Rakefile +73 -27
  4. data/TODO +27 -6
  5. data/bin/labor +2 -404
  6. data/lib/laborantin.rb +13 -26
  7. data/lib/laborantin/core/analysis.rb +231 -0
  8. data/lib/laborantin/core/command.rb +234 -0
  9. data/lib/laborantin/core/completeable.rb +30 -0
  10. data/lib/laborantin/core/configurable.rb +28 -0
  11. data/lib/laborantin/core/datable.rb +13 -0
  12. data/lib/laborantin/core/describable.rb +11 -0
  13. data/lib/laborantin/core/environment.rb +90 -52
  14. data/lib/laborantin/core/hookable.rb +20 -0
  15. data/lib/laborantin/core/monkey_patches.rb +0 -1
  16. data/lib/laborantin/core/multi_name.rb +25 -0
  17. data/lib/laborantin/core/parameter.rb +5 -12
  18. data/lib/laborantin/core/parameter_hash.rb +6 -2
  19. data/lib/laborantin/core/scenario.rb +93 -70
  20. data/lib/laborantin/core/table.rb +84 -0
  21. data/lib/laborantin/extra/commands/git.rb +40 -0
  22. data/lib/laborantin/extra/commands/git/check.rb +25 -0
  23. data/lib/laborantin/extra/commands/git/run.rb +100 -0
  24. data/lib/laborantin/extra/vectorial_product.rb +31 -0
  25. data/lib/laborantin/runner.rb +247 -0
  26. data/lib/laborantin/runner/commands/analyze.rb +58 -0
  27. data/lib/laborantin/runner/commands/cleanup.rb +40 -0
  28. data/lib/laborantin/runner/commands/complete.rb +111 -0
  29. data/lib/laborantin/runner/commands/config.rb +169 -0
  30. data/lib/laborantin/runner/commands/create.rb +61 -0
  31. data/lib/laborantin/runner/commands/describe.rb +215 -0
  32. data/lib/laborantin/runner/commands/find.rb +82 -0
  33. data/lib/laborantin/runner/commands/load_classes.rb +75 -0
  34. data/lib/laborantin/runner/commands/load_results.rb +143 -0
  35. data/lib/laborantin/runner/commands/note.rb +35 -0
  36. data/lib/laborantin/runner/commands/replay.rb +89 -0
  37. data/lib/laborantin/runner/commands/rm.rb +107 -0
  38. data/lib/laborantin/runner/commands/run.rb +131 -0
  39. data/lib/laborantin/runner/commands/scan.rb +77 -0
  40. metadata +45 -13
  41. data/bin/files/README.erb +0 -29
  42. data/bin/files/TODO.erb +0 -2
  43. data/bin/files/config/ftp.yaml.erb +0 -6
  44. data/bin/files/config/xmpp.yaml.erb +0 -7
  45. data/bin/files/environments/environment.rb.erb +0 -10
  46. data/bin/files/scenarii/scenario.rb.erb +0 -13
@@ -0,0 +1,82 @@
1
+ #runner/commands/find.rb
2
+
3
+ =begin
4
+
5
+ This file is part of Laborantin.
6
+
7
+ Laborantin is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ Laborantin is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with Laborantin. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ Copyright (c) 2009, Lucas Di Cioccio
21
+
22
+ =end
23
+
24
+ require 'laborantin'
25
+ require 'fileutils'
26
+
27
+ module Laborantin
28
+ module Commands
29
+ class Find < Command
30
+ describe "Finds and prints the result dir for a set of parameters / environments / scnarios"
31
+
32
+ option(:scenarii) do
33
+ describe "comma separated list of scenarios to describe"
34
+ short "-s"
35
+ long "--scenarii=OPTIONAL"
36
+ type Array
37
+ default []
38
+ complete do |cmd|
39
+ completion_propositions_iterating_on(cmd, Laborantin::Scenario.all.map(&:cli_name))
40
+ end
41
+ end
42
+
43
+ option(:environments) do
44
+ describe "comma separated list of environments to describe"
45
+ short "-e"
46
+ long "--envs=OPTIONAL"
47
+ type Array
48
+ default []
49
+ complete do |cmd|
50
+ completion_propositions_iterating_on(cmd, Laborantin::Environment.all.map(&:cli_name))
51
+ end
52
+ end
53
+
54
+ option(:parameters) do
55
+ describe "filter for parameters (a hash as Ruby syntax code)"
56
+ short '-p'
57
+ long '--parameters=OPTIONAL'
58
+ type String
59
+ default ''
60
+ end
61
+
62
+ option(:successful_only) do
63
+ describe "filter out results in failed environments"
64
+ long '--successful'
65
+ default false
66
+ end
67
+
68
+ option(:failed_only) do
69
+ describe "filter out results in sucessfuls environments"
70
+ long '--failed'
71
+ default false
72
+ end
73
+
74
+ execute do
75
+ results = Laborantin::Commands::LoadResults.new.run([], opts)
76
+ results[:scii].each do |sc|
77
+ puts "#{sc.rundir} #{sc.params.inspect}"
78
+ end
79
+ end # execute
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,75 @@
1
+ #runner/commands/load_classes.rb
2
+
3
+ =begin
4
+
5
+ This file is part of Laborantin.
6
+
7
+ Laborantin is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ Laborantin is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with Laborantin. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ Copyright (c) 2009, Lucas Di Cioccio
21
+
22
+ =end
23
+
24
+ require 'logger'
25
+ require 'fileutils'
26
+
27
+ module Laborantin
28
+ module Commands
29
+ class LoadClasses < Command
30
+ describe "Plumbery command to load classes."
31
+ plumbery!
32
+
33
+ option(:scenarii) do
34
+ describe "comma separated list of scenarios classes to load"
35
+ short "-s"
36
+ long "--scenarii=OPTIONAL"
37
+ type Array
38
+ default []
39
+ end
40
+
41
+ option(:environments) do
42
+ describe "comma separated list of environments classes to load"
43
+ short "-e"
44
+ long "--envs=OPTIONAL"
45
+ type Array
46
+ default []
47
+ end
48
+
49
+ execute do
50
+ # Environments and Scenarii filtering
51
+ envklasses = if opts[:environments].empty?
52
+ Laborantin::Environment.all
53
+ else
54
+ Laborantin::Environment.all.select do |e|
55
+ opts[:environments].find do |cli_name|
56
+ cli_name == e.cli_name
57
+ end
58
+ end
59
+ end
60
+
61
+ sciiklasses = if opts[:scenarii].empty?
62
+ Laborantin::Scenario.all
63
+ else
64
+ Laborantin::Scenario.all.select do |sc|
65
+ opts[:scenarii].find do |cli_name|
66
+ cli_name == sc.cli_name
67
+ end
68
+ end
69
+ end
70
+
71
+ {:envs => envklasses, :scii => sciiklasses}
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,143 @@
1
+ #runner/commands/load_results.rb
2
+
3
+ =begin
4
+
5
+ This file is part of Laborantin.
6
+
7
+ Laborantin is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ Laborantin is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with Laborantin. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ Copyright (c) 2009, Lucas Di Cioccio
21
+
22
+ =end
23
+
24
+ require 'logger'
25
+ require 'fileutils'
26
+
27
+ module Laborantin
28
+ module Commands
29
+ class LoadResults < Command
30
+ describe "Plumbery command to load results."
31
+ plumbery!
32
+
33
+ VERSIONS = ['0.0.20']
34
+
35
+ option(:version) do
36
+ describe "the Laborantin version's loader to use #{VERSIONS.inspect}"
37
+ short '-v'
38
+ long "--version=OPTIONAL"
39
+ type String
40
+ default Laborantin::VERSION
41
+ end
42
+
43
+ option(:scenarii) do
44
+ describe "comma separated list of scenarios to describe"
45
+ short "-s"
46
+ long "--scenarii=OPTIONAL"
47
+ type Array
48
+ default []
49
+ end
50
+
51
+ option(:environments) do
52
+ describe "comma separated list of environments to describe"
53
+ short "-e"
54
+ long "--envs=OPTIONAL"
55
+ type Array
56
+ default []
57
+ end
58
+
59
+ option(:parameters) do
60
+ describe "filter for parameters (a hash as Ruby syntax code)"
61
+ short '-p'
62
+ long '--parameters=OPTIONAL'
63
+ type String
64
+ default ''
65
+ end
66
+
67
+ option(:successful_only) do
68
+ describe "only load successful results"
69
+ long '--successful'
70
+ default false
71
+ end
72
+
73
+ option(:failed_only) do
74
+ describe "filter out results in sucessfuls environments"
75
+ long '--failed'
76
+ default false
77
+ end
78
+
79
+ option(:after_date) do
80
+ describe "filter only environments which date is later than"
81
+ long '--after=OPTIONAL'
82
+ type String
83
+ default ''
84
+ end
85
+
86
+ option(:before_date) do
87
+ describe "filter only environments which date is earlier than"
88
+ long '--before=OPTIONAL'
89
+ type String
90
+ default ''
91
+ end
92
+
93
+ def keep_env?(e, classes)
94
+ (classes[:envs].find{|k| e.is_a? k}) and
95
+ ((opts[:successful_only] ? e.successful? : true) and
96
+ (opts[:failed_only] ? e.failed? : true))
97
+ end
98
+
99
+
100
+ execute do
101
+ sym = unless VERSIONS.include?(opts[:version])
102
+ :execute_latest
103
+ else
104
+ "execute_#{opts[:version]}"
105
+ end
106
+ send sym
107
+ end
108
+
109
+ define_method(:"execute_0.0.20") do
110
+ # Parameters parsing
111
+ params = eval(opts[:parameters]) unless opts[:parameters].empty?
112
+ params ||= {}
113
+ params.each_key{|k| params[k] = [params[k]].flatten}
114
+
115
+ # Loading classes
116
+ classes = Laborantin::Commands::LoadClasses.new.run([], opts)
117
+
118
+ # Loading results now
119
+ envs = Laborantin::Environment.scan_resdir('results').select do |e|
120
+ keep_env?(e, classes)
121
+ end
122
+
123
+ all_scii = envs.map{|env| env.populate }.flatten #loads everything in envs
124
+
125
+ all_selected_scii = all_scii.select do |sc| #keep only klasses we want
126
+ classes[:scii].find{|k| sc.is_a? k}
127
+ end
128
+
129
+ # Filtering the scenarii according to parameters
130
+ scii = all_selected_scii.select do |sc|
131
+ filter_out = params.keys.find do |k|
132
+ not params[k].include?(sc.params[k])
133
+ end
134
+ not filter_out
135
+ end
136
+
137
+ {:envs => envs, :scii => scii}
138
+ end
139
+
140
+ alias :execute_latest :"execute_0.0.20"
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,35 @@
1
+ #runner/commands/note.rb
2
+
3
+ =begin
4
+
5
+ This file is part of Laborantin.
6
+
7
+ Laborantin is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ Laborantin is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with Laborantin. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ Copyright (c) 2009, Lucas Di Cioccio
21
+
22
+ =end
23
+
24
+ module Laborantin
25
+ module Commands
26
+ class Note < Command
27
+ describe "Appends a note to the BOOKNOTE file"
28
+ execute do
29
+ File.open('BOOKNOTE', 'a+') do |f|
30
+ f.puts "#{Time.now}: #{args.join(' ')}"
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,89 @@
1
+ #runner/commands/replay.rb
2
+
3
+ =begin
4
+
5
+ This file is part of Laborantin.
6
+
7
+ Laborantin is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ Laborantin is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with Laborantin. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ Copyright (c) 2009, Lucas Di Cioccio
21
+
22
+ =end
23
+
24
+ require 'logger'
25
+ require 'fileutils'
26
+
27
+ module Laborantin
28
+ module Commands
29
+ class Replay < Command
30
+ describe "Reproduces the scenarios' product for scenarios that match the filter"
31
+
32
+ option(:scenarii) do
33
+ describe "comma separated list of scenarios to describe"
34
+ short "-s"
35
+ long "--scenarii=OPTIONAL"
36
+ type Array
37
+ default []
38
+ complete do |cmd|
39
+ completion_propositions_iterating_on(cmd, Laborantin::Scenario.all.map(&:cli_name))
40
+ end
41
+ end
42
+
43
+ option(:environments) do
44
+ describe "comma separated list of environments to describe"
45
+ short "-e"
46
+ long "--envs=OPTIONAL"
47
+ type Array
48
+ default []
49
+ complete do |cmd|
50
+ completion_propositions_iterating_on(cmd, Laborantin::Environment.all.map(&:cli_name))
51
+ end
52
+ end
53
+
54
+ option(:parameters) do
55
+ describe "filter for parameters (a hash as Ruby syntax code)"
56
+ short '-p'
57
+ long '--parameters=OPTIONAL'
58
+ type String
59
+ default ''
60
+ end
61
+
62
+ option(:methods) do
63
+ describe "list of methods to call, default to all the products"
64
+ short '-m'
65
+ long '--methods=OPTIONAL'
66
+ type Array
67
+ default []
68
+ end
69
+
70
+ execute do
71
+ results = Laborantin::Commands::LoadResults.new.run([], opts)
72
+
73
+ logger = Logger.new(STDOUT)
74
+ results[:envs].each{|env| env.loggers << logger}
75
+
76
+ results[:scii].each do |sc|
77
+ sc.environment.log "#{sc.environment.class.name} - #{sc.class.name}", :info
78
+ sc.environment.log "Replaying products #{sc.params.inspect}"
79
+ if opts[:methods].empty?
80
+ sc.analyze!
81
+ else
82
+ opts[:methods].each{ |meth| sc.send meth }
83
+ end
84
+ end
85
+ end # execute
86
+ end
87
+ end
88
+ end
89
+
@@ -0,0 +1,107 @@
1
+ #runner/commands/rm.rb
2
+
3
+ =begin
4
+
5
+ This file is part of Laborantin.
6
+
7
+ Laborantin is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ Laborantin is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with Laborantin. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ Copyright (c) 2009, Lucas Di Cioccio
21
+
22
+ =end
23
+
24
+ module Laborantin
25
+ module Commands
26
+ class Rm < Command
27
+ describe "Removes the result directories of the matching scenarios and cleanup empty environments results directories"
28
+
29
+ option(:scenarii) do
30
+ describe "comma separated list of scenarios to describe"
31
+ short "-s"
32
+ long "--scenarii=OPTIONAL"
33
+ type Array
34
+ default []
35
+ complete do |cmd|
36
+ completion_propositions_iterating_on(cmd, Laborantin::Scenario.all.map(&:cli_name))
37
+ end
38
+ end
39
+
40
+ option(:environments) do
41
+ describe "comma separated list of environments to describe"
42
+ short "-e"
43
+ long "--envs=OPTIONAL"
44
+ type Array
45
+ default []
46
+ complete do |cmd|
47
+ completion_propositions_iterating_on(cmd, Laborantin::Environment.all.map(&:cli_name))
48
+ end
49
+ end
50
+
51
+ option(:parameters) do
52
+ describe "filter for parameters (a hash as Ruby syntax code)"
53
+ short '-p'
54
+ long '--parameters=OPTIONAL'
55
+ type String
56
+ default ''
57
+ end
58
+
59
+ option(:force) do
60
+ describe "disable check that prevents removing everything when there is no option on the CLI"
61
+ short '-f'
62
+ long '--force'
63
+ default false
64
+ end
65
+
66
+ option(:successful_only) do
67
+ describe "filter out results in failed environments"
68
+ long '--successful'
69
+ default false
70
+ end
71
+
72
+ option(:failed_only) do
73
+ describe "filter out results in sucessfuls environments"
74
+ long '--failed'
75
+ default false
76
+ end
77
+
78
+ def has_listed_parameters?
79
+ [:environments, :scenarii, :parameters].map{|i| opts[i].empty?}.include?(false)
80
+ end
81
+
82
+ def has___only_parameter?
83
+ (opts[:failed_only] == true) or (opts[:successful_only] == true)
84
+ end
85
+
86
+ def at_risk?
87
+ (not has_listed_parameters?) and
88
+ (not has___only_parameter?)
89
+ end
90
+
91
+ execute do
92
+ if at_risk?
93
+ #i.e., if there is no option on the CLI (matches all results)
94
+ unless opts[:force]
95
+ puts "This is at risk, please set the force flag."
96
+ exit
97
+ end
98
+ end
99
+ results = Laborantin::Commands::LoadResults.new.run([],opts)
100
+ results[:scii].each do |sc|
101
+ FileUtils.rm_rf(sc.rundir, :verbose => true)
102
+ end
103
+ Laborantin::Commands::Cleanup.new.run([],{})
104
+ end
105
+ end
106
+ end
107
+ end