Merge branch '11097-reuse-impure'
[arvados.git] / services / api / test / unit / container_request_test.rb
1 require 'test_helper'
2 require 'helpers/docker_migration_helper'
3
4 class ContainerRequestTest < ActiveSupport::TestCase
5   include DockerMigrationHelper
6
7   def create_minimal_req! attrs={}
8     defaults = {
9       command: ["echo", "foo"],
10       container_image: links(:docker_image_collection_tag).name,
11       cwd: "/tmp",
12       environment: {},
13       mounts: {"/out" => {"kind" => "tmp", "capacity" => 1000000}},
14       output_path: "/out",
15       runtime_constraints: {"vcpus" => 1, "ram" => 2},
16       name: "foo",
17       description: "bar",
18     }
19     cr = ContainerRequest.create!(defaults.merge(attrs))
20     cr.reload
21     return cr
22   end
23
24   def check_bogus_states cr
25     [nil, "Flubber"].each do |state|
26       assert_raises(ActiveRecord::RecordInvalid) do
27         cr.state = state
28         cr.save!
29       end
30       cr.reload
31     end
32   end
33
34   test "Container request create" do
35     set_user_from_auth :active
36     cr = create_minimal_req!
37
38     assert_nil cr.container_uuid
39     assert_nil cr.priority
40
41     check_bogus_states cr
42
43     # Ensure we can modify all attributes
44     cr.command = ["echo", "foo3"]
45     cr.container_image = "img3"
46     cr.cwd = "/tmp3"
47     cr.environment = {"BUP" => "BOP"}
48     cr.mounts = {"BAR" => "BAZ"}
49     cr.output_path = "/tmp4"
50     cr.priority = 2
51     cr.runtime_constraints = {"vcpus" => 4}
52     cr.name = "foo3"
53     cr.description = "bar3"
54     cr.save!
55
56     assert_nil cr.container_uuid
57   end
58
59   [
60     {"vcpus" => 1},
61     {"vcpus" => 1, "ram" => nil},
62     {"vcpus" => 0, "ram" => 123},
63     {"vcpus" => "1", "ram" => "123"}
64   ].each do |invalid_constraints|
65     test "Create with #{invalid_constraints}" do
66       set_user_from_auth :active
67       assert_raises(ActiveRecord::RecordInvalid) do
68         cr = create_minimal_req!(state: "Committed",
69                                  priority: 1,
70                                  runtime_constraints: invalid_constraints)
71         cr.save!
72       end
73     end
74
75     test "Update with #{invalid_constraints}" do
76       set_user_from_auth :active
77       cr = create_minimal_req!(state: "Uncommitted", priority: 1)
78       cr.save!
79       assert_raises(ActiveRecord::RecordInvalid) do
80         cr = ContainerRequest.find_by_uuid cr.uuid
81         cr.update_attributes!(state: "Committed",
82                               runtime_constraints: invalid_constraints)
83       end
84     end
85   end
86
87   test "Update from fixture" do
88     set_user_from_auth :active
89     cr = ContainerRequest.find_by_uuid(container_requests(:running).uuid)
90     cr.update_attributes!(description: "New description")
91     assert_equal "New description", cr.description
92   end
93
94   test "Update with valid runtime constraints" do
95       set_user_from_auth :active
96       cr = create_minimal_req!(state: "Uncommitted", priority: 1)
97       cr.save!
98       cr = ContainerRequest.find_by_uuid cr.uuid
99       cr.update_attributes!(state: "Committed",
100                             runtime_constraints: {"vcpus" => 1, "ram" => 23})
101       assert_not_nil cr.container_uuid
102   end
103
104   test "Container request priority must be non-nil" do
105     set_user_from_auth :active
106     cr = create_minimal_req!(priority: nil)
107     cr.state = "Committed"
108     assert_raises(ActiveRecord::RecordInvalid) do
109       cr.save!
110     end
111   end
112
113   test "Container request commit" do
114     set_user_from_auth :active
115     cr = create_minimal_req!(runtime_constraints: {"vcpus" => 2, "ram" => 30})
116
117     assert_nil cr.container_uuid
118
119     cr.reload
120     cr.state = "Committed"
121     cr.priority = 1
122     cr.save!
123
124     cr.reload
125
126     assert_not_nil cr.container_uuid
127     c = Container.find_by_uuid cr.container_uuid
128     assert_not_nil c
129     assert_equal ["echo", "foo"], c.command
130     assert_equal collections(:docker_image).portable_data_hash, c.container_image
131     assert_equal "/tmp", c.cwd
132     assert_equal({}, c.environment)
133     assert_equal({"/out" => {"kind"=>"tmp", "capacity"=>1000000}}, c.mounts)
134     assert_equal "/out", c.output_path
135     assert_equal({"keep_cache_ram"=>268435456, "vcpus" => 2, "ram" => 30}, c.runtime_constraints)
136     assert_equal 1, c.priority
137
138     assert_raises(ActiveRecord::RecordInvalid) do
139       cr.priority = nil
140       cr.save!
141     end
142
143     cr.priority = 0
144     cr.save!
145
146     cr.reload
147     c.reload
148     assert_equal 0, cr.priority
149     assert_equal 0, c.priority
150   end
151
152
153   test "Container request max priority" do
154     set_user_from_auth :active
155     cr = create_minimal_req!(priority: 5, state: "Committed")
156
157     c = Container.find_by_uuid cr.container_uuid
158     assert_equal 5, c.priority
159
160     cr2 = create_minimal_req!
161     cr2.priority = 10
162     cr2.state = "Committed"
163     cr2.container_uuid = cr.container_uuid
164     act_as_system_user do
165       cr2.save!
166     end
167
168     # cr and cr2 have priority 5 and 10, and are being satisfied by
169     # the same container c, so c's priority should be
170     # max(priority)=10.
171     c.reload
172     assert_equal 10, c.priority
173
174     cr2.update_attributes!(priority: 0)
175
176     c.reload
177     assert_equal 5, c.priority
178
179     cr.update_attributes!(priority: 0)
180
181     c.reload
182     assert_equal 0, c.priority
183   end
184
185
186   test "Independent container requests" do
187     set_user_from_auth :active
188     cr1 = create_minimal_req!(command: ["foo", "1"], priority: 5, state: "Committed")
189     cr2 = create_minimal_req!(command: ["foo", "2"], priority: 10, state: "Committed")
190
191     c1 = Container.find_by_uuid cr1.container_uuid
192     assert_equal 5, c1.priority
193
194     c2 = Container.find_by_uuid cr2.container_uuid
195     assert_equal 10, c2.priority
196
197     cr1.update_attributes!(priority: 0)
198
199     c1.reload
200     assert_equal 0, c1.priority
201
202     c2.reload
203     assert_equal 10, c2.priority
204   end
205
206   test "Request is finalized when its container is cancelled" do
207     set_user_from_auth :active
208     cr = create_minimal_req!(priority: 1, state: "Committed", container_count_max: 1)
209
210     act_as_system_user do
211       Container.find_by_uuid(cr.container_uuid).
212         update_attributes!(state: Container::Cancelled)
213     end
214
215     cr.reload
216     assert_equal "Final", cr.state
217   end
218
219   test "Request is finalized when its container is completed" do
220     set_user_from_auth :active
221     project = groups(:private)
222     cr = create_minimal_req!(owner_uuid: project.uuid,
223                              priority: 1,
224                              state: "Committed")
225
226     c = act_as_system_user do
227       c = Container.find_by_uuid(cr.container_uuid)
228       c.update_attributes!(state: Container::Locked)
229       c.update_attributes!(state: Container::Running)
230       c
231     end
232
233     cr.reload
234     assert_equal "Committed", cr.state
235
236     output_pdh = '1f4b0bc7583c2a7f9102c395f4ffc5e3+45'
237     log_pdh = 'fa7aeb5140e2848d39b416daeef4ffc5+45'
238     act_as_system_user do
239       c.update_attributes!(state: Container::Complete,
240                            output: output_pdh,
241                            log: log_pdh)
242     end
243
244     cr.reload
245     assert_equal "Final", cr.state
246     ['output', 'log'].each do |out_type|
247       pdh = Container.find_by_uuid(cr.container_uuid).send(out_type)
248       assert_equal(1, Collection.where(portable_data_hash: pdh,
249                                        owner_uuid: project.uuid).count,
250                    "Container #{out_type} should be copied to #{project.uuid}")
251     end
252     assert_not_nil cr.output_uuid
253     assert_not_nil cr.log_uuid
254     output = Collection.find_by_uuid cr.output_uuid
255     assert_equal output_pdh, output.portable_data_hash
256     log = Collection.find_by_uuid cr.log_uuid
257     assert_equal log_pdh, log.portable_data_hash
258   end
259
260   test "Container makes container request, then is cancelled" do
261     set_user_from_auth :active
262     cr = create_minimal_req!(priority: 5, state: "Committed", container_count_max: 1)
263
264     c = Container.find_by_uuid cr.container_uuid
265     assert_equal 5, c.priority
266
267     cr2 = create_minimal_req!
268     cr2.update_attributes!(priority: 10, state: "Committed", requesting_container_uuid: c.uuid, command: ["echo", "foo2"], container_count_max: 1)
269     cr2.reload
270
271     c2 = Container.find_by_uuid cr2.container_uuid
272     assert_equal 10, c2.priority
273
274     act_as_system_user do
275       c.state = "Cancelled"
276       c.save!
277     end
278
279     cr.reload
280     assert_equal "Final", cr.state
281
282     cr2.reload
283     assert_equal 0, cr2.priority
284
285     c2.reload
286     assert_equal 0, c2.priority
287   end
288
289   [
290     ['running_container_auth', 'zzzzz-dz642-runningcontainr'],
291     ['active_no_prefs', nil],
292   ].each do |token, expected|
293     test "create as #{token} and expect requesting_container_uuid to be #{expected}" do
294       set_user_from_auth token
295       cr = ContainerRequest.create(container_image: "img", output_path: "/tmp", command: ["echo", "foo"])
296       assert_not_nil cr.uuid, 'uuid should be set for newly created container_request'
297       assert_equal expected, cr.requesting_container_uuid
298     end
299   end
300
301   [[{"vcpus" => [2, nil]},
302     lambda { |resolved| resolved["vcpus"] == 2 }],
303    [{"vcpus" => [3, 7]},
304     lambda { |resolved| resolved["vcpus"] == 3 }],
305    [{"vcpus" => 4},
306     lambda { |resolved| resolved["vcpus"] == 4 }],
307    [{"ram" => [1000000000, 2000000000]},
308     lambda { |resolved| resolved["ram"] == 1000000000 }],
309    [{"ram" => [1234234234]},
310     lambda { |resolved| resolved["ram"] == 1234234234 }],
311   ].each do |rc, okfunc|
312     test "resolve runtime constraint range #{rc} to values" do
313       cr = ContainerRequest.new(runtime_constraints: rc)
314       resolved = cr.send :runtime_constraints_for_container
315       assert(okfunc.call(resolved),
316              "container runtime_constraints was #{resolved.inspect}")
317     end
318   end
319
320   [[{"/out" => {
321         "kind" => "collection",
322         "uuid" => "zzzzz-4zz18-znfnqtbbv4spc3w",
323         "path" => "/foo"}},
324     lambda do |resolved|
325       resolved["/out"] == {
326         "portable_data_hash" => "1f4b0bc7583c2a7f9102c395f4ffc5e3+45",
327         "kind" => "collection",
328         "path" => "/foo",
329       }
330     end],
331    [{"/out" => {
332         "kind" => "collection",
333         "uuid" => "zzzzz-4zz18-znfnqtbbv4spc3w",
334         "portable_data_hash" => "1f4b0bc7583c2a7f9102c395f4ffc5e3+45",
335         "path" => "/foo"}},
336     lambda do |resolved|
337       resolved["/out"] == {
338         "portable_data_hash" => "1f4b0bc7583c2a7f9102c395f4ffc5e3+45",
339         "kind" => "collection",
340         "path" => "/foo",
341       }
342     end],
343   ].each do |mounts, okfunc|
344     test "resolve mounts #{mounts.inspect} to values" do
345       set_user_from_auth :active
346       cr = ContainerRequest.new(mounts: mounts)
347       resolved = cr.send :mounts_for_container
348       assert(okfunc.call(resolved),
349              "mounts_for_container returned #{resolved.inspect}")
350     end
351   end
352
353   test 'mount unreadable collection' do
354     set_user_from_auth :spectator
355     m = {
356       "/foo" => {
357         "kind" => "collection",
358         "uuid" => "zzzzz-4zz18-znfnqtbbv4spc3w",
359         "path" => "/foo",
360       },
361     }
362     cr = ContainerRequest.new(mounts: m)
363     assert_raises(ArvadosModel::UnresolvableContainerError) do
364       cr.send :mounts_for_container
365     end
366   end
367
368   test 'mount collection with mismatched UUID and PDH' do
369     set_user_from_auth :active
370     m = {
371       "/foo" => {
372         "kind" => "collection",
373         "uuid" => "zzzzz-4zz18-znfnqtbbv4spc3w",
374         "portable_data_hash" => "fa7aeb5140e2848d39b416daeef4ffc5+45",
375         "path" => "/foo",
376       },
377     }
378     cr = ContainerRequest.new(mounts: m)
379     assert_raises(ArgumentError) do
380       cr.send :mounts_for_container
381     end
382   end
383
384   ['arvados/apitestfixture:latest',
385    'arvados/apitestfixture',
386    'd8309758b8fe2c81034ffc8a10c36460b77db7bc5e7b448c4e5b684f9d95a678',
387   ].each do |tag|
388     test "container_image_for_container(#{tag.inspect})" do
389       set_user_from_auth :active
390       cr = ContainerRequest.new(container_image: tag)
391       resolved = cr.send :container_image_for_container
392       assert_equal resolved, collections(:docker_image).portable_data_hash
393     end
394   end
395
396   test "container_image_for_container(pdh)" do
397     set_user_from_auth :active
398     [:docker_image, :docker_image_1_12].each do |coll|
399       pdh = collections(coll).portable_data_hash
400       cr = ContainerRequest.new(container_image: pdh)
401       resolved = cr.send :container_image_for_container
402       assert_equal resolved, pdh
403     end
404   end
405
406   ['acbd18db4cc2f85cedef654fccc4a4d8+3',
407    'ENOEXIST',
408    'arvados/apitestfixture:ENOEXIST',
409   ].each do |img|
410     test "container_image_for_container(#{img.inspect}) => 422" do
411       set_user_from_auth :active
412       cr = ContainerRequest.new(container_image: img)
413       assert_raises(ArvadosModel::UnresolvableContainerError) do
414         cr.send :container_image_for_container
415       end
416     end
417   end
418
419   test "migrated docker image" do
420     Rails.configuration.docker_image_formats = ['v2']
421     add_docker19_migration_link
422
423     set_user_from_auth :active
424     cr = create_minimal_req!(command: ["true", "1"],
425                              container_image: collections(:docker_image).portable_data_hash)
426     assert_equal(cr.send(:container_image_for_container),
427                  collections(:docker_image_1_12).portable_data_hash)
428
429     cr = create_minimal_req!(command: ["true", "2"],
430                              container_image: links(:docker_image_collection_tag).name)
431     assert_equal(cr.send(:container_image_for_container),
432                  collections(:docker_image_1_12).portable_data_hash)
433   end
434
435   test "requestor can retrieve container owned by dispatch" do
436     assert_not_empty Container.readable_by(users(:admin)).where(uuid: containers(:running).uuid)
437     assert_not_empty Container.readable_by(users(:active)).where(uuid: containers(:running).uuid)
438     assert_empty Container.readable_by(users(:spectator)).where(uuid: containers(:running).uuid)
439   end
440
441   [
442     [{"var" => "value1"}, {"var" => "value1"}, nil],
443     [{"var" => "value1"}, {"var" => "value1"}, true],
444     [{"var" => "value1"}, {"var" => "value1"}, false],
445     [{"var" => "value1"}, {"var" => "value2"}, nil],
446   ].each do |env1, env2, use_existing|
447     test "Container request #{((env1 == env2) and (use_existing.nil? or use_existing == true)) ? 'does' : 'does not'} reuse container when committed#{use_existing.nil? ? '' : use_existing ? ' and use_existing == true' : ' and use_existing == false'}" do
448       common_attrs = {cwd: "test",
449                       priority: 1,
450                       command: ["echo", "hello"],
451                       output_path: "test",
452                       runtime_constraints: {"vcpus" => 4,
453                                             "ram" => 12000000000,
454                                             "keep_cache_ram" => 268435456},
455                       mounts: {"test" => {"kind" => "json"}}}
456       set_user_from_auth :active
457       cr1 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Committed,
458                                                     environment: env1}))
459       if use_existing.nil?
460         # Testing with use_existing default value
461         cr2 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Uncommitted,
462                                                       environment: env2}))
463       else
464
465         cr2 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Uncommitted,
466                                                       environment: env2,
467                                                       use_existing: use_existing}))
468       end
469       assert_not_nil cr1.container_uuid
470       assert_nil cr2.container_uuid
471
472       # Update cr2 to commited state and check for container equality on different cases:
473       # * When env1 and env2 are equal and use_existing is true, the same container
474       #   should be assigned.
475       # * When use_existing is false, a different container should be assigned.
476       # * When env1 and env2 are different, a different container should be assigned.
477       cr2.update_attributes!({state: ContainerRequest::Committed})
478       assert_equal (cr2.use_existing == true and (env1 == env2)),
479                    (cr1.container_uuid == cr2.container_uuid)
480     end
481   end
482
483   test "requesting_container_uuid at create is not allowed" do
484     set_user_from_auth :active
485     assert_raises(ActiveRecord::RecordNotSaved) do
486       create_minimal_req!(state: "Uncommitted", priority: 1, requesting_container_uuid: 'youcantdothat')
487     end
488   end
489
490   test "Retry on container cancelled" do
491     set_user_from_auth :active
492     cr = create_minimal_req!(priority: 1, state: "Committed", container_count_max: 2)
493     cr2 = create_minimal_req!(priority: 1, state: "Committed", container_count_max: 2, command: ["echo", "baz"])
494     prev_container_uuid = cr.container_uuid
495
496     c = act_as_system_user do
497       c = Container.find_by_uuid(cr.container_uuid)
498       c.update_attributes!(state: Container::Locked)
499       c.update_attributes!(state: Container::Running)
500       c
501     end
502
503     cr.reload
504     cr2.reload
505     assert_equal "Committed", cr.state
506     assert_equal prev_container_uuid, cr.container_uuid
507     assert_not_equal cr2.container_uuid, cr.container_uuid
508     prev_container_uuid = cr.container_uuid
509
510     act_as_system_user do
511       c.update_attributes!(state: Container::Cancelled)
512     end
513
514     cr.reload
515     cr2.reload
516     assert_equal "Committed", cr.state
517     assert_not_equal prev_container_uuid, cr.container_uuid
518     assert_not_equal cr2.container_uuid, cr.container_uuid
519     prev_container_uuid = cr.container_uuid
520
521     c = act_as_system_user do
522       c = Container.find_by_uuid(cr.container_uuid)
523       c.update_attributes!(state: Container::Cancelled)
524       c
525     end
526
527     cr.reload
528     cr2.reload
529     assert_equal "Final", cr.state
530     assert_equal prev_container_uuid, cr.container_uuid
531     assert_not_equal cr2.container_uuid, cr.container_uuid
532   end
533
534   test "Output collection name setting using output_name with name collision resolution" do
535     set_user_from_auth :active
536     output_name = collections(:foo_file).name
537
538     cr = create_minimal_req!(priority: 1,
539                              state: ContainerRequest::Committed,
540                              output_name: output_name)
541     act_as_system_user do
542       c = Container.find_by_uuid(cr.container_uuid)
543       c.update_attributes!(state: Container::Locked)
544       c.update_attributes!(state: Container::Running)
545       c.update_attributes!(state: Container::Complete,
546                            exit_code: 0,
547                            output: '1f4b0bc7583c2a7f9102c395f4ffc5e3+45',
548                            log: 'fa7aeb5140e2848d39b416daeef4ffc5+45')
549     end
550     cr.save
551     assert_equal ContainerRequest::Final, cr.state
552     output_coll = Collection.find_by_uuid(cr.output_uuid)
553     # Make sure the resulting output collection name include the original name
554     # plus the date
555     assert_not_equal output_name, output_coll.name,
556                      "It shouldn't exist more than one collection with the same owner and name '${output_name}'"
557     assert output_coll.name.include?(output_name),
558            "New name should include original name"
559     assert_match /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, output_coll.name,
560                  "New name should include ISO8601 date"
561   end
562
563   test "Finalize committed request when reusing a finished container" do
564     set_user_from_auth :active
565     cr = create_minimal_req!(priority: 1, state: ContainerRequest::Committed)
566     cr.reload
567     assert_equal ContainerRequest::Committed, cr.state
568     act_as_system_user do
569       c = Container.find_by_uuid(cr.container_uuid)
570       c.update_attributes!(state: Container::Locked)
571       c.update_attributes!(state: Container::Running)
572       c.update_attributes!(state: Container::Complete,
573                            exit_code: 0,
574                            output: '1f4b0bc7583c2a7f9102c395f4ffc5e3+45',
575                            log: 'fa7aeb5140e2848d39b416daeef4ffc5+45')
576     end
577     cr.reload
578     assert_equal ContainerRequest::Final, cr.state
579
580     cr2 = create_minimal_req!(priority: 1, state: ContainerRequest::Committed)
581     assert_equal cr.container_uuid, cr2.container_uuid
582     assert_equal ContainerRequest::Final, cr2.state
583
584     cr3 = create_minimal_req!(priority: 1, state: ContainerRequest::Uncommitted)
585     assert_equal ContainerRequest::Uncommitted, cr3.state
586     cr3.update_attributes!(state: ContainerRequest::Committed)
587     assert_equal cr.container_uuid, cr3.container_uuid
588     assert_equal ContainerRequest::Final, cr3.state
589   end
590
591   [
592     [{"vcpus" => 1, "ram" => 123, "keep_cache_ram" => 100}, ContainerRequest::Committed, 100],
593     [{"vcpus" => 1, "ram" => 123}, ContainerRequest::Uncommitted],
594     [{"vcpus" => 1, "ram" => 123}, ContainerRequest::Committed],
595     [{"vcpus" => 1, "ram" => 123, "keep_cache_ram" => -1}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
596     [{"vcpus" => 1, "ram" => 123, "keep_cache_ram" => '123'}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
597   ].each do |rc, state, expected|
598     test "create container request with #{rc} in state #{state} and verify keep_cache_ram #{expected}" do
599       common_attrs = {cwd: "test",
600                       priority: 1,
601                       command: ["echo", "hello"],
602                       output_path: "test",
603                       runtime_constraints: rc,
604                       mounts: {"test" => {"kind" => "json"}}}
605       set_user_from_auth :active
606
607       if expected == ActiveRecord::RecordInvalid
608         assert_raises(ActiveRecord::RecordInvalid) do
609           create_minimal_req!(common_attrs.merge({state: state}))
610         end
611       else
612         cr = create_minimal_req!(common_attrs.merge({state: state}))
613         expected = Rails.configuration.container_default_keep_cache_ram if state == ContainerRequest::Committed and expected.nil?
614         assert_equal expected, cr.runtime_constraints['keep_cache_ram']
615       end
616     end
617   end
618
619   [
620     [{"partitions" => ["fastcpu","vfastcpu", 100]}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
621     [{"partitions" => ["fastcpu","vfastcpu", 100]}, ContainerRequest::Uncommitted],
622     [{"partitions" => "fastcpu"}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
623     [{"partitions" => "fastcpu"}, ContainerRequest::Uncommitted],
624     [{"partitions" => ["fastcpu","vfastcpu"]}, ContainerRequest::Committed],
625   ].each do |sp, state, expected|
626     test "create container request with scheduling_parameters #{sp} in state #{state} and verify #{expected}" do
627       common_attrs = {cwd: "test",
628                       priority: 1,
629                       command: ["echo", "hello"],
630                       output_path: "test",
631                       scheduling_parameters: sp,
632                       mounts: {"test" => {"kind" => "json"}}}
633       set_user_from_auth :active
634
635       if expected == ActiveRecord::RecordInvalid
636         assert_raises(ActiveRecord::RecordInvalid) do
637           create_minimal_req!(common_attrs.merge({state: state}))
638         end
639       else
640         cr = create_minimal_req!(common_attrs.merge({state: state}))
641         assert_equal sp, cr.scheduling_parameters
642
643         if state == ContainerRequest::Committed
644           c = Container.find_by_uuid(cr.container_uuid)
645           assert_equal sp, c.scheduling_parameters
646         end
647       end
648     end
649   end
650 end