aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-03-08 23:05:10 -0800
committerelijah <elijah@riseup.net>2014-03-08 23:05:10 -0800
commit4e7e6b8dfe6363469f700260cf191a6fca6c202e (patch)
treec6d9a91b1358f6519c3483bdf47b2b24badfe561
parentf041c31a469a423d0a587ecccc3d4726caa630de (diff)
downloadleap_cli-4e7e6b8dfe6363469f700260cf191a6fca6c202e.tar.gz
leap_cli-4e7e6b8dfe6363469f700260cf191a6fca6c202e.tar.bz2
added support for specifying what order nodes should be tested in.
-rw-r--r--lib/leap_cli/commands/test.rb7
-rw-r--r--lib/leap_cli/config/node.rb8
-rw-r--r--lib/leap_cli/config/object_list.rb18
3 files changed, 32 insertions, 1 deletions
diff --git a/lib/leap_cli/commands/test.rb b/lib/leap_cli/commands/test.rb
index da4a4b5..024ca25 100644
--- a/lib/leap_cli/commands/test.rb
+++ b/lib/leap_cli/commands/test.rb
@@ -13,7 +13,12 @@ module LeapCli; module Commands
test.command :run do |run|
run.switch 'continue', :desc => 'Continue over errors and failures (default is --no-continue).', :negatable => true
run.action do |global_options,options,args|
- manager.filter!(args).each_node do |node|
+ test_order = File.join(Path.platform, 'tests/order.rb')
+ if File.exists?(test_order)
+ require test_order
+ end
+ manager.filter!(args).names_in_test_dependency_order.each do |node_name|
+ node = manager.nodes[node_name]
ssh_connect(node) do |ssh|
ssh.run(test_cmd(options))
end
diff --git a/lib/leap_cli/config/node.rb b/lib/leap_cli/config/node.rb
index 5b911bf..740f9bb 100644
--- a/lib/leap_cli/config/node.rb
+++ b/lib/leap_cli/config/node.rb
@@ -32,6 +32,14 @@ module LeapCli; module Config
end
return vagrant_range.include?(ip_address)
end
+
+ #
+ # can be overridden by the platform.
+ # returns a list of node names that should be tested before this node
+ #
+ def test_dependencies
+ []
+ end
end
end; end
diff --git a/lib/leap_cli/config/object_list.rb b/lib/leap_cli/config/object_list.rb
index 9ca4697..910e2f7 100644
--- a/lib/leap_cli/config/object_list.rb
+++ b/lib/leap_cli/config/object_list.rb
@@ -1,9 +1,12 @@
+require 'tsort'
+
module LeapCli
module Config
#
# A list of Config::Object instances (internally stored as a hash)
#
class ObjectList < Hash
+ include TSort
def initialize(config=nil)
if config
@@ -171,6 +174,21 @@ module LeapCli
end
end
+ #
+ # topographical sort based on test dependency
+ #
+ def tsort_each_node(&block)
+ self.each_key(&block)
+ end
+
+ def tsort_each_child(node_name, &block)
+ self[node_name].test_dependencies.each(&block)
+ end
+
+ def names_in_test_dependency_order
+ self.tsort
+ end
+
end
end
end