Generate Test Automations

<% require "toaster/test/test_suite" require "toaster/chef/chef_util" require "toaster/util/lxc" require "toaster/markup/markup_util" require "toaster/state/state_transition_graph" require "toaster/test/test_coverage" require "toaster/api" $session = session test_suites = [] output = "" automation = cur_auto message = "" prototypes = [] errors = "" test_coverage = nil test_suite = nil begin # restore previously loaded data from session if $session['gen.prototypes'] && $session['gen.prototypes'].to_s.strip != "" prototypes = Toaster::MarkupUtil.parse_json($session['gen.prototypes']) end rescue => ex errors += "\nError: #{ex} - #{ex.backtrace.join("\n")}" end begin begin if param('submitGen') != "" test_suite_id = param('test_id') ? param('test_id') : $session['gen.test_suite_id'] test_suite = Toaster::TestSuite.load(test_suite_id) errors += "Could not find test suite with ID '#{test_suite_id}'. Please reload." if !test_suite # set/update parameter values (0..1000).each do |i| param_name = "paramvalues_taskparam#{i}" if param(param_name) != "" param_id = param(param_name) param_values = param("paramvalues_value#{i}") test_suite.parameter_test_values[param_id] = param_values else break end end test_suite.save() cookbook = param("cookbook") recipes = param("recipes") prototype = param("prototype") client = ToasterAppClient.new(param('server')) output += client.runtests(test_suite.uuid.to_s) end rescue => ex errors += "\nError: #{ex} - #{ex.backtrace.join("\n")}" end if param('initSuite') != "" output = "" prototype_name = param('prototype') if prototype_name == "" errors += "Please load the list of prototypes and select (or create) a prototype container." else recipes = param('recipe','default') cookbook = param('cookbook') destroy_lxc = param('destroyLXC') != "" ? true : false client = ToasterAppClient.new(param('server')) if param('download') != "" output += client.download(cookbook, prototype_name, "latest", recipes) end output += client.testinit(cookbook, recipes, prototype_name, destroy_lxc) end # if we don't clear the cache here, the new test suite will not be loaded.. clear_cache(true) end if param('loadTest') != "" && param('test_id') != "" test_suite = Toaster::TestSuite.load(param('test_id')) elsif $session['gen.test_suite_id'] != "" begin test_suite = Toaster::TestSuite.load($session['gen.test_suite_id']) rescue => ex #errors += "#{ex}\n" $session['gen.test_suite_id'] = "" end end if test_suite automation = test_suite.automation if test_suite && test_suite.automation set_param('cookbook', automation.get_short_name()) end $session['gen.test_suite_id'] = test_suite.id.to_s end if param("loadProtos") != "" || $session['gen.prototypes'] == "" prototypes = Toaster::LXC.get_prototypes_for_host($session['service.host']) #puts "protos: #{prototypes}" prototypes = prototypes.keys.collect { |name| Toaster::LXC.get_prototype_name(name) } $session['gen.prototypes'] = Toaster::MarkupUtil.to_json(prototypes) end if test_suite && param('compCoverage') != "" state_graph = StateTransitionGraph.build_graph_for_test_suite(test_suite) test_coverage = TestCoverage.new(test_suite, state_graph) end test_suites = Toaster::TestSuite.find().to_a test_suites.sort! { |x,y| (!x.last_test || !y.last_test) ? 0 : x.last_test.start_time.to_i <=> y.last_test.start_time.to_i } rescue => ex errors += "\nError: #{ex} - #{ex.backtrace.join("\n")}" end %> <% if output && output.to_s.strip != "" %> Script Output:
<%= output %>
<% end %> <% if errors && errors.to_s != "" %>
<%= errors.gsub("\n", "
") %>
<% end %> <% if message && message.to_s != "" %>
<%= message %>
<% end %>

Automation

<% if !automation %>
Select Automation: <%= select_tag(:automation, options_for_select(Automation.find().to_a.collect{|a| ["\"#{a.name}\" (ID: #{a.id})",a.id] })) %>
<% else executed_tasks = automation.get_globally_executed_tasks() %>
Automation<%= automation.name %>
Automation Tasks <% executed_tasks.each do |t| %> <% t.task_parameters.each_with_index do |p,index| %> <% end %> <% end %>
ParameterDefault ValueTest Values
Task '<%= t.name %>' (<%= t.global_states_reduced().size %> distinct state(s))
<%= p ? p.key : "n/a" %><%= p ? automation.get_default_value(p.key) : "n/a" %>

Container Environment

Use Prototype:
Options Download latest version from opscode.com (copy files into prototype)

Test Configuration

Test Settings:
IdempotenceN ∈ { }
(test idempotence of N consecutive tasks)
Combinations skip-N:N ∈ {}
skip-N-successive:N ∈ {}
combine-N:N ∈ {}
combine-N-successive:N ∈ {}
Graph Coverage

Generate!

(May take a while, please press button only once)

<% end %>