diff --git a/src/test/resources/.gitignore b/src/test/resources/.gitignore new file mode 100644 index 0000000..8f712ff --- /dev/null +++ b/src/test/resources/.gitignore @@ -0,0 +1,4 @@ +/token.properties +/devNext.gcubekey +/devsec.gcubekey +/gcube.gcubekey diff --git a/src/test/resources/JobUsageRecordTable.sql b/src/test/resources/JobUsageRecordTable.sql new file mode 100644 index 0000000..39c24ea --- /dev/null +++ b/src/test/resources/JobUsageRecordTable.sql @@ -0,0 +1,20 @@ +-- CREATE TYPE operation_result AS ENUM ('SUCCESS', 'FAILED'); +CREATE TABLE "jobusagerecord"( + id UUID NOT NULL PRIMARY KEY, + consumer_id TEXT NOT NULL, + creation_time TIMESTAMP WITH TIME ZONE NOT NULL, + scope TEXT NOT NULL, + operation_result operation_result NOT NULL, + caller_qualifier TEXT NOT NULL DEFAULT 'TOKEN', + host TEXT NOT NULL, + service_class TEXT NOT NULL, + service_name TEXT NOT NULL, + job_name TEXT NOT NULL, + duration NUMERIC NOT NULL, + max_invocation_time NUMERIC NOT NULL, + min_invocation_time NUMERIC NOT NULL, + operation_count INTEGER NOT NULL DEFAULT 1, + aggregated BOOLEAN NOT NULL DEFAULT true, + start_time TIMESTAMP WITH TIME ZONE NOT NULL, + end_time TIMESTAMP WITH TIME ZONE NOT NULL +); \ No newline at end of file diff --git a/src/test/resources/PortletUsageRecordTable.sql b/src/test/resources/PortletUsageRecordTable.sql new file mode 100644 index 0000000..7a06331 --- /dev/null +++ b/src/test/resources/PortletUsageRecordTable.sql @@ -0,0 +1,15 @@ +-- CREATE TYPE operation_result AS ENUM ('SUCCESS', 'FAILED'); +CREATE TABLE "portletusagerecord"( + id UUID NOT NULL PRIMARY KEY, + consumer_id TEXT NOT NULL, + creation_time TIMESTAMP WITH TIME ZONE NOT NULL, + scope TEXT NOT NULL, + operation_result operation_result NOT NULL, + caller_qualifier TEXT NOT NULL DEFAULT 'TOKEN', + portlet_id TEXT NOT NULL, + operation_id TEXT NOT NULL, + operation_count INTEGER NOT NULL DEFAULT 1, + aggregated BOOLEAN NOT NULL DEFAULT true, + start_time TIMESTAMP WITH TIME ZONE NOT NULL, + end_time TIMESTAMP WITH TIME ZONE NOT NULL +); \ No newline at end of file diff --git a/src/test/resources/ServiceUsageRecordTable.sql b/src/test/resources/ServiceUsageRecordTable.sql new file mode 100644 index 0000000..f0a9169 --- /dev/null +++ b/src/test/resources/ServiceUsageRecordTable.sql @@ -0,0 +1,21 @@ +CREATE TYPE operation_result AS ENUM ('SUCCESS', 'FAILED'); +CREATE TABLE "serviceusagerecord"( + id UUID NOT NULL PRIMARY KEY, + consumer_id TEXT NOT NULL, + creation_time TIMESTAMP WITH TIME ZONE NOT NULL, + scope TEXT NOT NULL, + operation_result operation_result NOT NULL, + caller_qualifier TEXT NOT NULL DEFAULT 'TOKEN', + caller_host TEXT NOT NULL, + host TEXT NOT NULL, + service_class TEXT NOT NULL, + service_name TEXT NOT NULL, + called_method TEXT NOT NULL, + duration NUMERIC NOT NULL, + max_invocation_time NUMERIC NOT NULL, + min_invocation_time NUMERIC NOT NULL, + operation_count INTEGER NOT NULL DEFAULT 1, + aggregated BOOLEAN NOT NULL DEFAULT true, + start_time TIMESTAMP WITH TIME ZONE NOT NULL, + end_time TIMESTAMP WITH TIME ZONE NOT NULL +); \ No newline at end of file diff --git a/src/test/resources/StorageStatusRecordTable.sql b/src/test/resources/StorageStatusRecordTable.sql new file mode 100644 index 0000000..db51a0d --- /dev/null +++ b/src/test/resources/StorageStatusRecordTable.sql @@ -0,0 +1,20 @@ +-- CREATE TYPE operation_result AS ENUM ('SUCCESS', 'FAILED'); +-- CREATE TYPE data_type AS ENUM ('STORAGE', 'TREE', 'GEO', 'DATABASE', 'LOCAL', 'OTHER'); +CREATE TABLE "storagestatusrecord"( + id UUID NOT NULL PRIMARY KEY, + consumer_id TEXT NOT NULL, + creation_time TIMESTAMP WITH TIME ZONE NOT NULL, + scope TEXT NOT NULL, + operation_result operation_result NOT NULL, + data_type data_type NOT NULL, + data_volume NUMERIC NOT NULL, + data_count NUMERIC NOT NULL, + data_service_class TEXT NOT NULL, + data_service_name TEXT NOT NULL, + data_service_id TEXT NOT NULL, + provider_id TEXT NOT NULL, + operation_count INTEGER NOT NULL DEFAULT 1, + aggregated BOOLEAN NOT NULL DEFAULT true, + start_time TIMESTAMP WITH TIME ZONE NOT NULL, + end_time TIMESTAMP WITH TIME ZONE NOT NULL +); \ No newline at end of file diff --git a/src/test/resources/StorageUsageRecordTable.sql b/src/test/resources/StorageUsageRecordTable.sql new file mode 100644 index 0000000..d306526 --- /dev/null +++ b/src/test/resources/StorageUsageRecordTable.sql @@ -0,0 +1,21 @@ +-- CREATE TYPE operation_result AS ENUM ('SUCCESS', 'FAILED'); +CREATE TYPE operation_type AS ENUM ('CREATE', 'READ', 'UPDATE', 'DELETE'); +CREATE TYPE data_type AS ENUM ('STORAGE', 'TREE', 'GEO', 'DATABASE', 'LOCAL', 'OTHER'); +CREATE TABLE "storageusagerecord"( + id UUID NOT NULL PRIMARY KEY, + consumer_id TEXT NOT NULL, + creation_time TIMESTAMP WITH TIME ZONE NOT NULL, + scope TEXT NOT NULL, + operation_result operation_result NOT NULL, + resource_owner TEXT NOT NULL, + resource_scope TEXT NOT NULL, + resource_uri TEXT NOT NULL, + provider_uri TEXT NOT NULL, + operation_type operation_type NOT NULL, + data_type data_type NOT NULL, + data_volume NUMERIC NOT NULL, + operation_count INTEGER NOT NULL DEFAULT 1, + aggregated BOOLEAN NOT NULL DEFAULT true, + start_time TIMESTAMP WITH TIME ZONE NOT NULL, + end_time TIMESTAMP WITH TIME ZONE NOT NULL +); \ No newline at end of file diff --git a/src/test/resources/insert-usagerecord-example.sql b/src/test/resources/insert-usagerecord-example.sql new file mode 100644 index 0000000..c8bb65c --- /dev/null +++ b/src/test/resources/insert-usagerecord-example.sql @@ -0,0 +1,64 @@ +INSERT INTO jobusagerecord +(aggregated,caller_qualifier,consumer_id,creation_time, +duration,end_time,host,id, +job_name,max_invocation_time,min_invocation_time,operation_count, +operation_result,scope,service_class,service_name, +start_time) +VALUES +('true','TestCallerQualifier','name.surname','2021-03-15 12:20:32.705 +0100', +295,'2021-03-15 12:20:32.704 +0100','localhost','17abc69a-491e-47ed-994b-9e1db0cf05fd', +'TestJobName',295,295,1, +'SUCCESS','/gcube/devNext','TestServiceClass','TestServiceName', +'2021-03-15 12:20:32.704 +0100'); + +---------------------------------------------------------------------------------------- + +INSERT INTO portletusagerecord +(aggregated,consumer_id,creation_time,end_time, +id,operation_count,operation_id,operation_result, +portlet_id,scope,start_time) +VALUES +('true','name.surname','2021-03-15 12:20:32.706 +0100','2021-03-15 12:20:32.705 +0100', +'724aee1c-3f7c-40b9-bb27-40211a7b10ca',1,'TestPortletOperationID','SUCCESS', +'TestPortlet','/gcube/devNext','2021-03-15 12:20:32.705 +0100'); + +---------------------------------------------------------------------------------------- + +INSERT INTO serviceusagerecord +(aggregated,called_method,caller_host,caller_qualifier, +consumer_id,creation_time,duration,end_time, +host,id,max_invocation_time,min_invocation_time,operation_count, +operation_result,scope,service_class,service_name, +start_time) +VALUES +('true','TestCalledMethod','remotehost','TestCallerQualifier', +'name.surname','2021-03-15 12:20:32.987 +0100',361,'2021-03-15 12:20:32.706 +0100', +'localhost','c386cf48-b955-4683-a3da-372216e34eb3',361,361, +1,'SUCCESS','/gcube/devNext','TestServiceClass', +'TestServiceName','2021-03-15 12:20:32.706 +0100'); + +---------------------------------------------------------------------------------------- + +INSERT INTO storagestatusrecord +(aggregated,consumer_id,creation_time,data_count, +data_service_class,data_service_id,data_service_name,data_type, +data_volume,end_time,id,operation_count, +operation_result,provider_id,scope,start_time) +VALUES ('true','name.surname','2021-03-15 12:20:32.988 +0100',8117, +'dataServiceClass','dataServiceId','dataServiceName','STORAGE', +8086,'2021-03-15 12:20:32.988 +0100','21d68adf-b17f-4a19-85ac-c50ba854cf72',1, +'SUCCESS','testprotocol://providerURI','/gcube/devNext','2021-03-15 12:20:32.988 +0100'); + +---------------------------------------------------------------------------------------- + +INSERT INTO storageusagerecord +(aggregated,consumer_id,creation_time,data_type, +data_volume,end_time,id,operation_count, +operation_result,operation_type,provider_uri,resource_owner, +resource_scope,resource_uri,scope,start_time) +VALUES +('true','name.surname','2021-03-15 12:20:32.990 +0100','STORAGE', +9177,'2021-03-15 12:20:32.989 +0100','11c0f9bb-e04f-4035-a230-50160dad737e',1, +'SUCCESS','READ','testprotocol://providerURI','resource.owner', +'/infrastructure/vo','testprotocol://objectURI','/gcube/devNext','2021-03-15 12:20:32.989 +0100'); + diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml new file mode 100644 index 0000000..6351ec4 --- /dev/null +++ b/src/test/resources/logback-test.xml @@ -0,0 +1,19 @@ + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n + + + + + + + + + + + + \ No newline at end of file