})
end
- def vary_scheduling_parameters(**kwargs)
- # kwargs is a hash that maps scheduling parameters to an array of values.
- # This function enumerates every possible combination of
- # scheduling parameters from those keys and their associated values.
+ def vary_parameters(**kwargs)
+ # kwargs is a hash that maps parameters to an array of values.
+ # This function enumerates every possible hash where each key has one of
+ # the values from its array.
+ # The output keys are strings since that's what container hash attributes
+ # want.
+ # A nil value yields a hash without that key.
[[:_, nil]].product(
*kwargs.map { |(key, values)| [key.to_s].product(values) },
).map { |param_pairs| Hash[param_pairs].compact }
).each do |preemptible_a|
test "retry requests scheduled with preemptible=#{preemptible_a}" do
configure_preemptible_instance_type
- param_hashes = vary_scheduling_parameters(preemptible: preemptible_a)
+ param_hashes = vary_parameters(preemptible: preemptible_a)
container = retry_with_scheduling_parameters(param_hashes)
assert_equal(preemptible_a.all?,
container.scheduling_parameters["preemptible"] || false)
partition_values.permutation(2),
).each do |partitions_a|
test "retry requests scheduled with partitions=#{partitions_a}" do
- param_hashes = vary_scheduling_parameters(partitions: partitions_a)
+ param_hashes = vary_parameters(partitions: partitions_a)
container = retry_with_scheduling_parameters(param_hashes)
expected = if partitions_a.any? { |value| value.nil? or value.empty? }
[]
runtime_values.permutation(3),
).each do |max_run_time_a|
test "retry requests scheduled with max_run_time=#{max_run_time_a}" do
- param_hashes = vary_scheduling_parameters(max_run_time: max_run_time_a)
+ param_hashes = vary_parameters(max_run_time: max_run_time_a)
container = retry_with_scheduling_parameters(param_hashes)
expected = if max_run_time_a.any? { |value| value.nil? or value == 0 }
0
test "retry requests with unset scheduling parameters" do
configure_preemptible_instance_type
- param_hashes = vary_scheduling_parameters(
+ param_hashes = vary_parameters(
preemptible: [nil, true],
partitions: [nil, ["alpha"]],
max_run_time: [nil, 5],
test "retry requests with default scheduling parameters" do
configure_preemptible_instance_type
- param_hashes = vary_scheduling_parameters(
+ param_hashes = vary_parameters(
preemptible: [false, true],
partitions: [[], ["bravo"]],
max_run_time: [0, 1],