[ARVADOS] updated: f137e22a65cc29d00146a4735fe54d72b299984b
Git user
git at public.curoverse.com
Mon Sep 12 17:11:29 EDT 2016
Summary of changes:
services/api/test/fixtures/container_requests.yml | 53 ------
services/api/test/fixtures/containers.yml | 208 +---------------------
services/api/test/unit/container_test.rb | 182 ++++++++++++++-----
3 files changed, 147 insertions(+), 296 deletions(-)
via f137e22a65cc29d00146a4735fe54d72b299984b (commit)
via e33cb63676097f15842cefe8c3a750965daca751 (commit)
via bcd205719cb6dcaacfae9ee99b43d8e35fe8f072 (commit)
from de4cfeaab629e99014deb10792637649511c91d0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit f137e22a65cc29d00146a4735fe54d72b299984b
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Mon Sep 12 18:09:51 2016 -0300
9623: Restored changes to fixture file
diff --git a/services/api/test/fixtures/containers.yml b/services/api/test/fixtures/containers.yml
index 1492dcc..6df1842 100644
--- a/services/api/test/fixtures/containers.yml
+++ b/services/api/test/fixtures/containers.yml
@@ -7,6 +7,7 @@ queued:
updated_at: 2016-01-11 11:11:11.111111111 Z
container_image: test
cwd: test
+ output: test
output_path: test
command: ["echo", "hello"]
runtime_constraints:
@@ -18,12 +19,12 @@ running:
owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
state: Running
priority: 1
- progress: 10.0
created_at: <%= 1.minute.ago.to_s(:db) %>
updated_at: <%= 1.minute.ago.to_s(:db) %>
started_at: <%= 1.minute.ago.to_s(:db) %>
container_image: test
cwd: test
+ output: test
output_path: test
command: ["echo", "hello"]
runtime_constraints:
@@ -31,17 +32,17 @@ running:
vcpus: 4
auth_uuid: zzzzz-gj3su-077z32aux8dg2s1
-running_older:
+running-older:
uuid: zzzzz-dz642-runningcontain2
owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
state: Running
priority: 1
- progress: 15.0
created_at: <%= 2.minute.ago.to_s(:db) %>
updated_at: <%= 2.minute.ago.to_s(:db) %>
started_at: <%= 2.minute.ago.to_s(:db) %>
container_image: test
cwd: test
+ output: test
output_path: test
command: ["echo", "hello"]
runtime_constraints:
@@ -63,21 +64,6 @@ locked:
ram: 12000000000
vcpus: 4
-locked_higher_priority:
- uuid: zzzzz-dz642-lockedcontainerhigher
- owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- state: Locked
- priority: 3
- created_at: <%= 2.minute.ago.to_s(:db) %>
- updated_at: <%= 2.minute.ago.to_s(:db) %>
- container_image: test
- cwd: test
- output_path: test
- command: ["echo", "hello"]
- runtime_constraints:
- ram: 12000000000
- vcpus: 4
-
completed:
uuid: zzzzz-dz642-compltcontainer
owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
@@ -90,6 +76,7 @@ completed:
finished_at: 2016-01-12 11:12:13.111111111 Z
container_image: test
cwd: test
+ output: test
log: ea10d51bcf88862dbcc36eb292017dfd+45
output: zzzzz-4zz18-znfnqtbbv4spc3w
output_path: test
@@ -111,7 +98,6 @@ completed_older:
container_image: test
cwd: test
output: test
- log: test
output_path: test
command: ["echo", "hello"]
runtime_constraints:
@@ -164,7 +150,6 @@ failed_container:
container_image: test
cwd: test
output: test
- log: test
output_path: test
command: ["echo", "hello"]
runtime_constraints:
commit e33cb63676097f15842cefe8c3a750965daca751
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Mon Sep 12 17:57:59 2016 -0300
9623: Rewrote tests to avoid using fixture records.
diff --git a/services/api/test/unit/container_test.rb b/services/api/test/unit/container_test.rb
index 2f68246..5ea0927 100644
--- a/services/api/test/unit/container_test.rb
+++ b/services/api/test/unit/container_test.rb
@@ -11,6 +11,15 @@ class ContainerTest < ActiveSupport::TestCase
runtime_constraints: {"vcpus" => 1, "ram" => 1},
}
+ REUSABLE_COMMON_ATTRS = {container_image: "test",
+ cwd: "test",
+ command: ["echo", "hello"],
+ output_path: "test",
+ runtime_constraints: {"vcpus" => 4,
+ "ram" => 12000000000},
+ mounts: {"test" => {"kind" => "json"}},
+ environment: {"var" => 'val'}}
+
def minimal_new attrs={}
cr = ContainerRequest.new DEFAULT_ATTRS.merge(attrs)
act_as_user users(:active) do
@@ -94,49 +103,142 @@ class ContainerTest < ActiveSupport::TestCase
assert_equal Container.deep_sort_hash(a).to_json, Container.deep_sort_hash(b).to_json
end
- [
- ["completed", :completed_older],
- ["running", :running_older],
- ["locked", :locked_higher_priority],
- ["queued", :queued_higher_priority],
- ["completed_vs_running", :completed_vs_running_winner],
- ["running_vs_locked", :running_vs_locked_winner],
- ["locked_vs_queued", :locked_vs_queued_winner]
- ].each do |state, c_to_be_selected|
- test "find reusable method for #{state} container" do
- set_user_from_auth :active
- c = Container.find_reusable(container_image: "test",
- cwd: "test",
- command: ["echo", "hello"],
- output_path: "test",
- runtime_constraints: {"vcpus" => 4, "ram" => 12000000000},
- mounts: {"test" => {"kind" => "json"}},
- environment: {"var" => state})
- assert_not_nil c
- assert_equal c.uuid, containers(c_to_be_selected).uuid
- end
+ test "find_reusable method should select higher priority queued container" do
+ set_user_from_auth :active
+ common_attrs = REUSABLE_COMMON_ATTRS.merge({environment:{"var" => "queued"}})
+ c_low_priority, _ = minimal_new(common_attrs.merge({priority:1}))
+ c_high_priority, _ = minimal_new(common_attrs.merge({priority:2}))
+ assert_equal Container::Queued, c_low_priority.state
+ assert_equal Container::Queued, c_high_priority.state
+ reused = Container.find_reusable(common_attrs)
+ assert_not_nil reused
+ assert_equal reused.uuid, c_high_priority.uuid
+ end
+
+ test "find_reusable method should select latest completed container" do
+ set_user_from_auth :active
+ common_attrs = REUSABLE_COMMON_ATTRS.merge({environment: {"var" => "complete"}})
+ completed_attrs = {
+ state: Container::Complete,
+ exit_code: 0,
+ log: 'ea10d51bcf88862dbcc36eb292017dfd+45',
+ output: 'zzzzz-4zz18-znfnqtbbv4spc3w'
+ }
+
+ c_older, _ = minimal_new(common_attrs)
+ c_recent, _ = minimal_new(common_attrs)
+
+ set_user_from_auth :dispatch1
+ c_older.update_attributes!({state: Container::Locked})
+ c_older.update_attributes!({state: Container::Running})
+ c_older.update_attributes!(completed_attrs)
+
+ c_recent.update_attributes!({state: Container::Locked})
+ c_recent.update_attributes!({state: Container::Running})
+ c_recent.update_attributes!(completed_attrs)
+
+ reused = Container.find_reusable(common_attrs)
+ assert_not_nil reused
+ assert_equal reused.uuid, c_recent.uuid
+ end
+
+ test "find_reusable method should select running container most likely to finish sooner" do
+ set_user_from_auth :active
+ common_attrs = REUSABLE_COMMON_ATTRS.merge({environment: {"var" => "running"}})
+ c_slower, _ = minimal_new(common_attrs)
+ c_faster_started_first, _ = minimal_new(common_attrs)
+ c_faster_started_second, _ = minimal_new(common_attrs)
+ set_user_from_auth :dispatch1
+ c_slower.update_attributes!({state: Container::Locked})
+ c_slower.update_attributes!({state: Container::Running,
+ progress: 10.0})
+ c_faster_started_first.update_attributes!({state: Container::Locked})
+ c_faster_started_first.update_attributes!({state: Container::Running,
+ progress: 15.0})
+ c_faster_started_second.update_attributes!({state: Container::Locked})
+ c_faster_started_second.update_attributes!({state: Container::Running,
+ progress: 15.0})
+ reused = Container.find_reusable(common_attrs)
+ assert_not_nil reused
+ assert_equal reused.uuid, c_faster_started_first.uuid
+ end
+
+ test "find_reusable method should select locked container most likely to start sooner" do
+ set_user_from_auth :active
+ common_attrs = REUSABLE_COMMON_ATTRS.merge({environment: {"var" => "locked"}})
+ c_low_priority, _ = minimal_new(common_attrs)
+ c_high_priority_older, _ = minimal_new(common_attrs)
+ c_high_priority_newer, _ = minimal_new(common_attrs)
+ set_user_from_auth :dispatch1
+ c_low_priority.update_attributes!({state: Container::Locked,
+ priority: 1})
+ c_high_priority_older.update_attributes!({state: Container::Locked,
+ priority: 2})
+ c_high_priority_newer.update_attributes!({state: Container::Locked,
+ priority: 2})
+ reused = Container.find_reusable(common_attrs)
+ assert_not_nil reused
+ assert_equal reused.uuid, c_high_priority_older.uuid
+ end
+
+ test "find_reusable method should select complete over running container" do
+ set_user_from_auth :active
+ common_attrs = REUSABLE_COMMON_ATTRS.merge({environment: {"var" => "completed_vs_running"}})
+ c_completed, _ = minimal_new(common_attrs)
+ c_running, _ = minimal_new(common_attrs)
+ set_user_from_auth :dispatch1
+ c_completed.update_attributes!({state: Container::Locked})
+ c_completed.update_attributes!({state: Container::Running})
+ c_completed.update_attributes!({state: Container::Complete,
+ exit_code: 0,
+ log: "ea10d51bcf88862dbcc36eb292017dfd+45",
+ output: "zzzzz-4zz18-znfnqtbbv4spc3w"})
+ c_running.update_attributes!({state: Container::Locked})
+ c_running.update_attributes!({state: Container::Running,
+ progress: 1.5})
+ reused = Container.find_reusable(common_attrs)
+ assert_not_nil reused
+ assert_equal reused.uuid, c_completed.uuid
+ end
+
+ test "find_reusable method should select running over locked container" do
+ set_user_from_auth :active
+ common_attrs = REUSABLE_COMMON_ATTRS.merge({environment: {"var" => "running_vs_locked"}})
+ c_locked, _ = minimal_new(common_attrs)
+ c_running, _ = minimal_new(common_attrs)
+ set_user_from_auth :dispatch1
+ c_locked.update_attributes!({state: Container::Locked})
+ c_running.update_attributes!({state: Container::Locked})
+ c_running.update_attributes!({state: Container::Running,
+ progress: 1.5})
+ reused = Container.find_reusable(common_attrs)
+ assert_not_nil reused
+ assert_equal reused.uuid, c_running.uuid
+ end
+
+ test "find_reusable method should select locked over queued container" do
+ set_user_from_auth :active
+ common_attrs = REUSABLE_COMMON_ATTRS.merge({environment: {"var" => "running_vs_locked"}})
+ c_locked, _ = minimal_new(common_attrs)
+ c_queued, _ = minimal_new(common_attrs)
+ set_user_from_auth :dispatch1
+ c_locked.update_attributes!({state: Container::Locked})
+ reused = Container.find_reusable(common_attrs)
+ assert_not_nil reused
+ assert_equal reused.uuid, c_locked.uuid
end
- test "Container find reusable method should not select failed" do
+ test "find_reusable method should not select failed container" do
set_user_from_auth :active
- attrs = {container_image: "test",
- cwd: "test",
- command: ["echo", "hello"],
- output_path: "test",
- runtime_constraints: {"vcpus" => 4, "ram" => 12000000000},
- mounts: {"test" => {"kind" => "json"}},
- environment: {"var" => "failed"}}
- cf = containers(:failed_container)
- assert_equal cf.container_image, attrs[:container_image]
- assert_equal cf.cwd, attrs[:cwd]
- assert_equal cf.command, attrs[:command]
- assert_equal cf.output_path, attrs[:output_path]
- assert_equal cf.runtime_constraints, attrs[:runtime_constraints]
- assert_equal cf.mounts, attrs[:mounts]
- assert_equal cf.environment, attrs[:environment]
- assert cf.exit_code != 0
- c = Container.find_reusable(attrs)
- assert_nil c
+ attrs = REUSABLE_COMMON_ATTRS.merge({environment: {"var" => "failed"}})
+ c, _ = minimal_new(attrs)
+ set_user_from_auth :dispatch1
+ c.update_attributes!({state: Container::Locked})
+ c.update_attributes!({state: Container::Running})
+ c.update_attributes!({state: Container::Complete,
+ exit_code: 33})
+ reused = Container.find_reusable(attrs)
+ assert_nil reused
end
test "Container running" do
commit bcd205719cb6dcaacfae9ee99b43d8e35fe8f072
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Mon Sep 12 17:55:07 2016 -0300
9623: Removed fixtures additions meant for Container reuse tests because some of them made other integration tests to fail.
diff --git a/services/api/test/fixtures/container_requests.yml b/services/api/test/fixtures/container_requests.yml
index aa0a125..433aff2 100644
--- a/services/api/test/fixtures/container_requests.yml
+++ b/services/api/test/fixtures/container_requests.yml
@@ -16,59 +16,6 @@ queued:
runtime_constraints:
vcpus: 1
ram: 123
- mounts:
- test:
- kind: json
- environment:
- var: queued
-
-queued_higher_priority:
- uuid: zzzzz-xvhdp-cr4queuedcontnrhigher
- owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- name: queued_hp
- state: Committed
- priority: 2
- created_at: 2016-01-11 11:11:11.111111111 Z
- updated_at: 2016-01-11 11:11:11.111111111 Z
- modified_at: 2016-01-11 11:11:11.111111111 Z
- modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- container_image: test
- cwd: test
- output_path: test
- command: ["echo", "hello"]
- container_uuid: zzzzz-dz642-queuedcontainerhigher
- runtime_constraints:
- vcpus: 1
- ram: 123
- mounts:
- test:
- kind: json
- environment:
- var: queued
-
-locked_vs_queued_loser:
- uuid: zzzzz-xvhdp-cr4lockedvsqueuedloser
- owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- name: lockedvqueuedloser
- state: Committed
- priority: 2
- created_at: 2016-01-11 11:11:11.111111111 Z
- updated_at: 2016-01-11 11:11:11.111111111 Z
- modified_at: 2016-01-11 11:11:11.111111111 Z
- modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- container_image: test
- cwd: test
- output_path: test
- command: ["echo", "hello"]
- container_uuid: zzzzz-dz642-lvqloser
- runtime_constraints:
- vcpus: 1
- ram: 123
- mounts:
- test:
- kind: json
- environment:
- var: locked_vs_queued
running:
uuid: zzzzz-xvhdp-cr4runningcntnr
diff --git a/services/api/test/fixtures/containers.yml b/services/api/test/fixtures/containers.yml
index 65323f5..1492dcc 100644
--- a/services/api/test/fixtures/containers.yml
+++ b/services/api/test/fixtures/containers.yml
@@ -12,31 +12,6 @@ queued:
runtime_constraints:
ram: 12000000000
vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: queued
-
-queued_higher_priority:
- uuid: zzzzz-dz642-queuedcontainerhigher
- owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- state: Queued
- priority: 2
- created_at: 2016-01-11 11:11:11.111111111 Z
- updated_at: 2016-01-11 11:11:11.111111111 Z
- container_image: test
- cwd: test
- output_path: test
- command: ["echo", "hello"]
- runtime_constraints:
- ram: 12000000000
- vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: queued
running:
uuid: zzzzz-dz642-runningcontainr
@@ -54,11 +29,6 @@ running:
runtime_constraints:
ram: 12000000000
vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: running
auth_uuid: zzzzz-gj3su-077z32aux8dg2s1
running_older:
@@ -77,11 +47,6 @@ running_older:
runtime_constraints:
ram: 12000000000
vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: running
locked:
uuid: zzzzz-dz642-lockedcontainer
@@ -97,11 +62,6 @@ locked:
runtime_constraints:
ram: 12000000000
vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: locked
locked_higher_priority:
uuid: zzzzz-dz642-lockedcontainerhigher
@@ -117,11 +77,6 @@ locked_higher_priority:
runtime_constraints:
ram: 12000000000
vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: locked
completed:
uuid: zzzzz-dz642-compltcontainer
@@ -139,11 +94,6 @@ completed:
output: zzzzz-4zz18-znfnqtbbv4spc3w
output_path: test
command: ["echo", "hello"]
- mounts:
- test:
- kind: json
- environment:
- var: completed
runtime_constraints:
ram: 12000000000
vcpus: 4
@@ -164,11 +114,6 @@ completed_older:
log: test
output_path: test
command: ["echo", "hello"]
- mounts:
- test:
- kind: json
- environment:
- var: completed
runtime_constraints:
ram: 12000000000
vcpus: 4
@@ -225,131 +170,3 @@ failed_container:
runtime_constraints:
ram: 12000000000
vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: failed
-
-completed_vs_running_winner:
- uuid: zzzzz-dz642-cvrwinner
- owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- exit_code: 0
- output: test
- log: test
- state: Complete
- priority: 1
- created_at: 2016-01-11 11:11:11.111111111 Z
- updated_at: 2016-01-11 11:11:11.111111111 Z
- container_image: test
- cwd: test
- output_path: test
- command: ["echo", "hello"]
- runtime_constraints:
- ram: 12000000000
- vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: completed_vs_running
-
-completed_vs_running_loser:
- uuid: zzzzz-dz642-cvrloser
- owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- state: Running
- priority: 1
- created_at: 2016-01-11 11:11:11.111111111 Z
- updated_at: 2016-01-11 11:11:11.111111111 Z
- container_image: test
- cwd: test
- output_path: test
- command: ["echo", "hello"]
- runtime_constraints:
- ram: 12000000000
- vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: completed_vs_running
-
-running_vs_locked_winner:
- uuid: zzzzz-dz642-rvlwinner
- owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- state: Running
- priority: 1
- created_at: 2016-01-11 11:11:11.111111111 Z
- updated_at: 2016-01-11 11:11:11.111111111 Z
- container_image: test
- cwd: test
- output_path: test
- command: ["echo", "hello"]
- runtime_constraints:
- ram: 12000000000
- vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: running_vs_locked
-
-running_vs_locked_loser:
- uuid: zzzzz-dz642-rvlloser
- owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- state: Locked
- priority: 1
- created_at: 2016-01-11 11:11:11.111111111 Z
- updated_at: 2016-01-11 11:11:11.111111111 Z
- container_image: test
- cwd: test
- output_path: test
- command: ["echo", "hello"]
- runtime_constraints:
- ram: 12000000000
- vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: running_vs_locked
-
-locked_vs_queued_winner:
- uuid: zzzzz-dz642-lvqwinner
- owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- state: Locked
- priority: 1
- created_at: 2016-01-11 11:11:11.111111111 Z
- updated_at: 2016-01-11 11:11:11.111111111 Z
- container_image: test
- cwd: test
- output_path: test
- command: ["echo", "hello"]
- runtime_constraints:
- ram: 12000000000
- vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: locked_vs_queued
-
-locked_vs_queued_loser:
- uuid: zzzzz-dz642-lvqloser
- owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- state: Queued
- priority: 1
- created_at: 2016-01-11 11:11:11.111111111 Z
- updated_at: 2016-01-11 11:11:11.111111111 Z
- container_image: test
- cwd: test
- output_path: test
- command: ["echo", "hello"]
- runtime_constraints:
- ram: 12000000000
- vcpus: 4
- mounts:
- test:
- kind: json
- environment:
- var: locked_vs_queued
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list