# SPDX-License-Identifier: AGPL-3.0
class AddOutputProperties < ActiveRecord::Migration[5.2]
- def change
+ def trgm_indexes
+ {
+ "container_requests" => "container_requests_trgm_text_search_idx",
+ }
+ end
+
+ def up
add_column :container_requests, :output_properties, :jsonb, default: {}
add_column :containers, :output_properties, :jsonb, default: {}
+
+ trgm_indexes.each do |model, indx|
+ execute "DROP INDEX IF EXISTS #{indx}"
+ execute "CREATE INDEX #{indx} ON #{model} USING gin((#{model.classify.constantize.full_text_trgm}) gin_trgm_ops)"
+ end
+ end
+
+ def down
+ remove_column :container_requests, :output_properties
+ remove_column :containers, :output_properties
+
+ trgm_indexes.each do |model, indx|
+ execute "DROP INDEX IF EXISTS #{indx}"
+ execute "CREATE INDEX #{indx} ON #{model} USING gin((#{model.classify.constantize.full_text_trgm}) gin_trgm_ops)"
+ end
end
end
output_ttl integer DEFAULT 0 NOT NULL,
secret_mounts jsonb DEFAULT '{}'::jsonb,
runtime_token text,
- output_storage_classes jsonb DEFAULT '["default"]'::jsonb
+ output_storage_classes jsonb DEFAULT '["default"]'::jsonb,
+ output_properties jsonb DEFAULT '{}'::jsonb
);
lock_count integer DEFAULT 0 NOT NULL,
gateway_address character varying,
interactive_session_started boolean DEFAULT false NOT NULL,
- output_storage_classes jsonb DEFAULT '["default"]'::jsonb
+ output_storage_classes jsonb DEFAULT '["default"]'::jsonb,
+ output_properties jsonb DEFAULT '{}'::jsonb
);
-- Name: container_requests_trgm_text_search_idx; Type: INDEX; Schema: public; Owner: -
--
-CREATE INDEX container_requests_trgm_text_search_idx ON public.container_requests USING gin (((((((((((((((((((((((((((((((((((((((((((COALESCE(uuid, ''::character varying))::text || ' '::text) || (COALESCE(owner_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(modified_by_client_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(modified_by_user_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(name, ''::character varying))::text) || ' '::text) || COALESCE(description, ''::text)) || ' '::text) || COALESCE((properties)::text, ''::text)) || ' '::text) || (COALESCE(state, ''::character varying))::text) || ' '::text) || (COALESCE(requesting_container_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(container_uuid, ''::character varying))::text) || ' '::text) || COALESCE(runtime_constraints, ''::text)) || ' '::text) || (COALESCE(container_image, ''::character varying))::text) || ' '::text) || COALESCE(environment, ''::text)) || ' '::text) || (COALESCE(cwd, ''::character varying))::text) || ' '::text) || COALESCE(command, ''::text)) || ' '::text) || (COALESCE(output_path, ''::character varying))::text) || ' '::text) || COALESCE(filters, ''::text)) || ' '::text) || COALESCE(scheduling_parameters, ''::text)) || ' '::text) || (COALESCE(output_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(log_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(output_name, ''::character varying))::text)) public.gin_trgm_ops);
+CREATE INDEX container_requests_trgm_text_search_idx ON public.container_requests USING gin (((((((((((((((((((((((((((((((((((((((((((((COALESCE(uuid, ''::character varying))::text || ' '::text) || (COALESCE(owner_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(modified_by_client_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(modified_by_user_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(name, ''::character varying))::text) || ' '::text) || COALESCE(description, ''::text)) || ' '::text) || COALESCE((properties)::text, ''::text)) || ' '::text) || (COALESCE(state, ''::character varying))::text) || ' '::text) || (COALESCE(requesting_container_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(container_uuid, ''::character varying))::text) || ' '::text) || COALESCE(runtime_constraints, ''::text)) || ' '::text) || (COALESCE(container_image, ''::character varying))::text) || ' '::text) || COALESCE(environment, ''::text)) || ' '::text) || (COALESCE(cwd, ''::character varying))::text) || ' '::text) || COALESCE(command, ''::text)) || ' '::text) || (COALESCE(output_path, ''::character varying))::text) || ' '::text) || COALESCE(filters, ''::text)) || ' '::text) || COALESCE(scheduling_parameters, ''::text)) || ' '::text) || (COALESCE(output_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(log_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(output_name, ''::character varying))::text) || ' '::text) || COALESCE((output_properties)::text, ''::text))) public.gin_trgm_ops);
--
('20220224203102'),
('20220301155729'),
('20220303204419'),
-('20220401153101');
+('20220401153101'),
+('20220505112900');
assert_equal ["foo_storage_class"], output1.storage_classes_desired
assert_equal ["bar_storage_class"], output2.storage_classes_desired
end
+
+ [
+ [{}, {}, {"type": "output"}],
+ [{"a1": "b1"}, {}, {"type": "output", "a1": "b1"}],
+ [{}, {"a1": "b1"}, {"type": "output", "a1": "b1"}],
+ [{"a1": "b1"}, {"a1": "c1"}, {"type": "output", "a1": "b1"}],
+ [{"a1": "b1"}, {"a2": "c2"}, {"type": "output", "a1": "b1", "a2": "c2"}],
+ [{"type": "blah"}, {}, {"type": "output"}],
+ ].each do |cr_prop, container_prop, expect_prop|
+ test "setting output_properties #{cr_prop} #{container_prop} on current container" do
+ act_as_user users(:active) do
+ cr = create_minimal_req!(priority: 1,
+ state: ContainerRequest::Committed,
+ output_name: 'foo',
+ output_properties: cr_prop)
+
+ act_as_system_user do
+ logc = Collection.new(owner_uuid: system_user_uuid,
+ manifest_text: ". ef772b2f28e2c8ca84de45466ed19ee9+7815 0:0:arv-mount.txt\n")
+ logc.save!
+
+ c = Container.find_by_uuid(cr.container_uuid)
+ c.update_attributes!(state: Container::Locked)
+ c.update_attributes!(state: Container::Running)
+
+ c.update_attributes!(output_properties: container_prop)
+
+ c.update_attributes!(state: Container::Complete,
+ exit_code: 0,
+ output: '1f4b0bc7583c2a7f9102c395f4ffc5e3+45',
+ log: logc.portable_data_hash)
+ logc.destroy
+ end
+
+ cr.reload
+ expect_prop["container_request"] = cr.uuid
+ output = Collection.find_by_uuid(cr.output_uuid)
+ assert_equal expect_prop.symbolize_keys, output.properties.symbolize_keys
+ end
+ end
+ end
+
end