diff options
| author | Dante Niewenhuis <d.niewenhuis@hotmail.com> | 2024-03-05 13:23:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-05 13:23:57 +0100 |
| commit | 5864cbcbfe2eb8c36ca05c3a39c7e5916aeecaec (patch) | |
| tree | 5b2773b8dc21c2e1b526fb70f829c376dd80532a /opendc-web/opendc-web-server/src/main/resources | |
| parent | d28002a3c151d198298574312f32f1cb43f3a660 (diff) | |
Updated package versions, updated web server tests. (#207)
* Updated all package versions including kotlin. Updated all web-server tests to run.
* Changed the java version of the tests. OpenDC now only supports java 19.
* small update
* test update
* new update
* updated docker version to 19
* updated docker version to 19
Diffstat (limited to 'opendc-web/opendc-web-server/src/main/resources')
4 files changed, 128 insertions, 184 deletions
diff --git a/opendc-web/opendc-web-server/src/main/resources/application-test.properties b/opendc-web/opendc-web-server/src/main/resources/application-test.properties index bee17221..4e3063e4 100644 --- a/opendc-web/opendc-web-server/src/main/resources/application-test.properties +++ b/opendc-web/opendc-web-server/src/main/resources/application-test.properties @@ -37,3 +37,7 @@ quarkus.swagger-ui.enable=false # Disable OpenDC web UI and runner quarkus.opendc-ui.include=false quarkus.opendc-runner.include=false + +# Create new tables and fill them +quarkus.hibernate-orm.database.generation=drop-and-create +quarkus.hibernate-orm.sql-load-script=load_data.sql diff --git a/opendc-web/opendc-web-server/src/main/resources/db/migration/V3.0__core.sql b/opendc-web/opendc-web-server/src/main/resources/db/migration/V3.0__core.sql deleted file mode 100644 index 40654b6b..00000000 --- a/opendc-web/opendc-web-server/src/main/resources/db/migration/V3.0__core.sql +++ /dev/null @@ -1,160 +0,0 @@ --- Hibernate sequence for unique identifiers -create sequence hibernate_sequence start with 1 increment by 1; - --- Projects -create table projects -( - id bigint not null, - created_at timestamp not null, - name varchar(255) not null, - portfolios_created integer not null default 0, - scenarios_created integer not null default 0, - topologies_created integer not null default 0, - updated_at timestamp not null, - primary key (id) -); - -create type project_role as enum ('OWNER', 'EDITOR', 'VIEWER'); - --- Project authorizations authorize users specific permissions to a project. -create table project_authorizations -( - project_id bigint not null, - user_id varchar(255) not null, - role project_role not null, - primary key (project_id, user_id) -); - --- Topologies represent the datacenter designs created by users. -create table topologies -( - id bigint not null, - created_at timestamp not null, - name varchar(255) not null, - number integer not null, - rooms jsonb not null, - updated_at timestamp not null, - project_id bigint not null, - primary key (id) -); - --- Portfolios -create table portfolios -( - id bigint not null, - name varchar(255) not null, - number integer not null, - targets jsonb not null, - project_id bigint not null, - primary key (id) -); - -create table scenarios -( - id bigint not null, - name varchar(255) not null, - number integer not null, - phenomena jsonb not null, - scheduler_name varchar(255) not null, - sampling_fraction double precision not null, - portfolio_id bigint not null, - project_id bigint not null, - topology_id bigint not null, - trace_id varchar(255) not null, - primary key (id) -); - -create type job_state as enum ('PENDING', 'CLAIMED', 'RUNNING', 'FINISHED', 'FAILED'); - -create table jobs -( - id bigint not null, - created_by varchar(255) not null, - created_at timestamp not null, - repeats integer not null, - results jsonb, - state job_state not null default 'PENDING', - runtime integer not null default 0, - updated_at timestamp not null, - scenario_id bigint not null, - primary key (id) -); - --- User accounting -create table user_accounting -( - user_id varchar(255) not null, - period_end date not null, - simulation_time integer not null, - simulation_time_budget integer not null, - primary key (user_id) -); - --- Workload traces available to the user. -create table traces -( - id varchar(255) not null, - name varchar(255) not null, - type varchar(255) not null, - primary key (id) -); - --- Relations -alter table project_authorizations - add constraint fk_project_authorizations - foreign key (project_id) - references projects; - -create index ux_topologies_number on topologies (project_id, number); - -alter table topologies - add constraint uk_topologies_number unique (project_id, number); - -alter table topologies - add constraint fk_topologies_project - foreign key (project_id) - references projects; - -create index ux_portfolios_number on portfolios (project_id, number); - -alter table portfolios - add constraint fk_portfolios_project - foreign key (project_id) - references projects; - -alter table portfolios - add constraint uk_portfolios_number unique (project_id, number); - -create index ux_scenarios_number on scenarios (project_id, number); - -alter table scenarios - add constraint uk_scenarios_number unique (project_id, number); - -alter table scenarios - add constraint fk_scenarios_project - foreign key (project_id) - references projects; - -alter table scenarios - add constraint fk_scenarios_topology - foreign key (topology_id) - references topologies; - -alter table scenarios - add constraint fk_scenarios_portfolio - foreign key (portfolio_id) - references portfolios; - -alter table scenarios - add constraint fk_scenarios_trace - foreign key (trace_id) - references traces; - -alter table jobs - add constraint fk_scenarios_job - foreign key (scenario_id) - references scenarios; - --- Initial data -insert into traces (id, name, type) -values ('bitbrains-small', 'Bitbrains Small', 'vm'); diff --git a/opendc-web/opendc-web-server/src/main/resources/db/testing/V3.0.1__entities.sql b/opendc-web/opendc-web-server/src/main/resources/db/testing/V3.0.1__entities.sql deleted file mode 100644 index 1b702f4e..00000000 --- a/opendc-web/opendc-web-server/src/main/resources/db/testing/V3.0.1__entities.sql +++ /dev/null @@ -1,24 +0,0 @@ --- Test entities - -alter sequence hibernate_sequence restart with 500; - -insert into projects (id, created_at, name, portfolios_created, scenarios_created, topologies_created, updated_at) -values (1, current_timestamp(), 'Test Project', 1, 2, 1, current_timestamp()); -insert into project_authorizations (project_id, user_id, role) -values (1, 'owner', 'OWNER'), - (1, 'editor', 'EDITOR'), - (1, 'viewer', 'VIEWER'); - -insert into portfolios (id, name, number, targets, project_id) -values (1, 'Test Portfolio', 1, '{ "metrics": [] }' format json, 1); - -insert into topologies (id, created_at, name, number, rooms, updated_at, project_id) -values (1, current_timestamp(), 'Test Topology', 1, '[]' format json, current_timestamp(), 1); - -insert into scenarios (id, name, number, phenomena, scheduler_name, sampling_fraction, portfolio_id, project_id, topology_id, trace_id) -values (1, 'Test Scenario', 1, '{ "failures": false, "interference": false }' format json, 'mem', 1.0, 1, 1, 1, 'bitbrains-small'), - (2, 'Test Scenario', 2, '{ "failures": false, "interference": false }' format json, 'mem', 1.0, 1, 1, 1, 'bitbrains-small'); - -insert into jobs (id, created_by, created_at, repeats, updated_at, scenario_id) -values (1, 'owner', current_timestamp(), 1, current_timestamp(), 1), - (2, 'owner', current_timestamp(), 1, current_timestamp(), 2); diff --git a/opendc-web/opendc-web-server/src/main/resources/load_data.sql b/opendc-web/opendc-web-server/src/main/resources/load_data.sql new file mode 100644 index 00000000..72396cef --- /dev/null +++ b/opendc-web/opendc-web-server/src/main/resources/load_data.sql @@ -0,0 +1,124 @@ + +-- Insert data + +INSERT INTO PROJECT (created_at, name, portfolios_created, scenarios_created, topologies_created, updated_at, id) + VALUES ('2024-03-01T15:31:41.579969Z', 'Test Project 1', 0, 0, 0, '2024-03-01T15:31:41.579969Z', 1); + +INSERT INTO PROJECTAUTHORIZATION (role, project_id, user_name) +VALUES ('OWNER', 1, 'test_user_1'); + +-- Add test user 2 as a viewer for project 1 + +INSERT INTO PROJECTAUTHORIZATION (role, project_id, user_name) +VALUES ('VIEWER', 1, 'test_user_2'); + +-- Add test user 3 as an editor for project 1 + +INSERT INTO PROJECTAUTHORIZATION (role, project_id, user_name) +VALUES ('EDITOR', 1, 'test_user_3'); + +-- Create a project for test user 2 + +INSERT INTO PROJECT (created_at, name, portfolios_created, scenarios_created, topologies_created, updated_at, id) +VALUES ('2024-03-01T15:31:41.579969Z', 'Test Project 2', 0, 0, 0, '2024-03-01T15:31:41.579969Z', 2); + +INSERT INTO PROJECTAUTHORIZATION (role, project_id, user_name) +VALUES ('OWNER', 2, 'test_user_2'); + +-- Create three projects for test user 3. User 3 has multiple projects to test getAll + +INSERT INTO PROJECT (created_at, name, portfolios_created, scenarios_created, topologies_created, updated_at, id) +VALUES ('2024-03-01T15:31:41.579969Z', 'Test Project 3', 0, 0, 0, '2024-03-01T15:31:41.579969Z', 3); + +INSERT INTO PROJECTAUTHORIZATION (role, project_id, user_name) +VALUES ('OWNER', 3, 'test_user_3'); + +INSERT INTO PROJECT (created_at, name, portfolios_created, scenarios_created, topologies_created, updated_at, id) +VALUES ('2024-03-01T15:31:41.579969Z', 'Test Project 4', 0, 0, 0, '2024-03-01T15:31:41.579969Z', 4); + +INSERT INTO PROJECTAUTHORIZATION (role, project_id, user_name) +VALUES ('OWNER', 4, 'test_user_3'); + +INSERT INTO PROJECT (created_at, name, portfolios_created, scenarios_created, topologies_created, updated_at, id) +VALUES ('2024-03-01T15:31:41.579969Z', 'Test Project 5', 0, 0, 0, '2024-03-01T15:31:41.579969Z', 5); + +INSERT INTO PROJECTAUTHORIZATION (role, project_id, user_name) +VALUES ('OWNER', 5, 'test_user_3'); + +-- Project to delete + +INSERT INTO PROJECT (created_at, name, portfolios_created, scenarios_created, topologies_created, updated_at, id) +VALUES ('2024-03-01T15:31:41.579969Z', 'Test Project Delete', 0, 0, 0, '2024-03-01T15:31:41.579969Z', 6); + +INSERT INTO PROJECTAUTHORIZATION (role, project_id, user_name) +VALUES ('OWNER', 6, 'test_user_1'); + +-- -------------------------------------------------------------------------------- +-- PortFolios +-- -------------------------------------------------------------------------------- + +-- Add Portfolio to project 1 +INSERT INTO PORTFOLIO (name, number, project_id, targets, id) +VALUES ('Test PortFolio Base', 1, 1, '{"metrics": [], "repeats":1}' FORMAT JSON, 1); + +INSERT INTO PORTFOLIO (name, number, project_id, targets, id) +VALUES ('Test PortFolio Delete', 2, 1, '{"metrics": [], "repeats":1}' FORMAT JSON, 2); + +INSERT INTO PORTFOLIO (name, number, project_id, targets, id) +VALUES ('Test PortFolio DeleteEditor', 3, 1, '{"metrics": [], "repeats":1}' FORMAT JSON, 3); + +UPDATE Project p +SET p.portfolios_created = 3, p.updated_at = '2024-03-01T15:31:41.579969Z' +WHERE p.id = 1; + +-- -------------------------------------------------------------------------------- +-- Topologies +-- -------------------------------------------------------------------------------- + +INSERT INTO TOPOLOGY (created_at, name, number, project_id, rooms, updated_at, id) +VALUES ('2024-03-01T15:31:41.579969Z', 'Test Topology testUpdate', 1, 1, '[]' FORMAT JSON, '2024-03-01T15:31:41.579969Z', 1); + +INSERT INTO TOPOLOGY (created_at, name, number, project_id, rooms, updated_at, id) +VALUES ('2024-03-01T15:31:41.579969Z', 'Test Topology testDeleteAsEditor', 2, 1, '[]' FORMAT JSON, '2024-03-01T15:31:41.579969Z', 2); + +INSERT INTO TOPOLOGY (created_at, name, number, project_id, rooms, updated_at, id) +VALUES ('2024-03-01T15:31:41.579969Z', 'Test Topology testDelete', 3, 1, '[]' FORMAT JSON, '2024-03-01T15:31:41.579969Z', 3); + +INSERT INTO TOPOLOGY (created_at, name, number, project_id, rooms, updated_at, id) +VALUES ('2024-03-01T15:31:41.579969Z', 'Test Topology testDeleteUsed', 4, 1, '[]' FORMAT JSON, '2024-03-01T15:31:41.579969Z', 4); + +UPDATE Project p +SET p.topologies_created = 4, p.updated_at = '2024-03-01T15:31:41.579969Z' +WHERE p.id = 1; + +-- -------------------------------------------------------------------------------- +-- Traces +-- -------------------------------------------------------------------------------- + +INSERT INTO TRACE (id, name, type) +VALUES ('bitbrains-small', 'Bitbrains Small', 'small'); + +-- -------------------------------------------------------------------------------- +-- Scenario +-- -------------------------------------------------------------------------------- + +INSERT INTO SCENARIO (name, number, phenomena, portfolio_id, project_id, scheduler_name, topology_id, sampling_fraction, trace_id, id) +VALUES ('Test Scenario testDelete', 1, '{"failures": false, "interference": false}' FORMAT JSON, 1, 1, 'test', 1, 1.0, 'bitbrains-small', 1); + +INSERT INTO SCENARIO (name, number, phenomena, portfolio_id, project_id, scheduler_name, topology_id, sampling_fraction, trace_id, id) +VALUES ('Test Scenario testDeleteUsed', 2, '{"failures": false, "interference": false}' FORMAT JSON, 1, 1, 'test', 4, 1.0, 'bitbrains-small', 2); + + +UPDATE Project p +SET p.scenarios_created = 2, p.updated_at = '2024-03-01T15:31:41.579969Z' +WHERE p.id = 1; + +-- -------------------------------------------------------------------------------- +-- Job +-- -------------------------------------------------------------------------------- + +INSERT INTO JOB (scenario_id, created_by, created_at, repeats, updated_at, state, runtime, results, id) +VALUES (1, 'test_user_1', '2024-03-01T15:31:41.579969Z', 1, '2024-03-01T15:31:41.579969Z', 'PENDING', 1, '{}' FORMAT JSON, 1); + +INSERT INTO JOB (scenario_id, created_by, created_at, repeats, updated_at, state, runtime, results, id) +VALUES (1, 'test_user_1', '2024-03-01T15:31:41.579969Z', 1, '2024-03-01T15:31:41.579969Z', 'PENDING', 1, '{}' FORMAT JSON, 2); |
