Revert "WIP single context in test-data"

This reverts commit af2b67b2ee.
This commit is contained in:
Michael Hoennig 2024-08-29 12:18:35 +02:00
parent af2b67b2ee
commit b36d4ce949
15 changed files with 76 additions and 42 deletions

View File

@ -11,6 +11,7 @@ create or replace procedure createdomainTestData( packageName varchar, domainCou
declare declare
pac record; pac record;
pacAdmin varchar; pacAdmin varchar;
currentTask varchar;
begin begin
select p.uuid, p.name, c.prefix as custPrefix select p.uuid, p.name, c.prefix as custPrefix
from test_package p from test_package p
@ -20,8 +21,10 @@ begin
for t in 0..(domainCount-1) for t in 0..(domainCount-1)
loop loop
currentTask = 'creating RBAC test domain #' || t || ' for package ' || pac.name || ' #' || pac.uuid;
raise notice 'task: %', currentTask;
pacAdmin = 'pac-admin-' || pac.name || '@' || pac.custPrefix || '.example.com'; pacAdmin = 'pac-admin-' || pac.name || '@' || pac.custPrefix || '.example.com';
call defineContext('creating RBAC test domain', null, pacAdmin, null); call defineContext(currentTask, null, pacAdmin, null);
insert insert
into test_domain (name, packageUuid) into test_domain (name, packageUuid)

View File

@ -11,13 +11,17 @@
create or replace procedure createHsOfficeContactTestData(contCaption varchar) create or replace procedure createHsOfficeContactTestData(contCaption varchar)
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar;
postalAddr varchar; postalAddr varchar;
emailAddr varchar; emailAddr varchar;
begin begin
currentTask = 'creating contact test-data ' || contCaption;
execute format('set local hsadminng.currentTask to %L', currentTask);
emailAddr = 'contact-admin@' || cleanIdentifier(contCaption) || '.example.com'; emailAddr = 'contact-admin@' || cleanIdentifier(contCaption) || '.example.com';
call defineContext('creating contact test-data'); call defineContext(currentTask);
perform createRbacUser(emailAddr); perform createRbacUser(emailAddr);
call defineContext('creating contact test-data', null, emailAddr); call defineContext(currentTask, null, emailAddr);
postalAddr := E'Vorname Nachname\nStraße Hnr\nPLZ Stadt'; postalAddr := E'Vorname Nachname\nStraße Hnr\nPLZ Stadt';

View File

@ -17,13 +17,15 @@ create or replace procedure createHsOfficePersonTestData(
language plpgsql as $$ language plpgsql as $$
declare declare
fullName varchar; fullName varchar;
currentTask varchar;
emailAddr varchar; emailAddr varchar;
begin begin
fullName := concat_ws(', ', newTradeName, newFamilyName, newGivenName); fullName := concat_ws(', ', newTradeName, newFamilyName, newGivenName);
currentTask = 'creating person test-data ' || fullName;
emailAddr = 'person-' || left(cleanIdentifier(fullName), 32) || '@example.com'; emailAddr = 'person-' || left(cleanIdentifier(fullName), 32) || '@example.com';
call defineContext('creating person test-data'); call defineContext(currentTask);
perform createRbacUser(emailAddr); perform createRbacUser(emailAddr);
call defineContext('creating person test-data', null, emailAddr); call defineContext(currentTask, null, emailAddr);
execute format('set local hsadminng.currentTask to %L', currentTask); execute format('set local hsadminng.currentTask to %L', currentTask);
raise notice 'creating test person: % by %', fullName, emailAddr; raise notice 'creating test person: % by %', fullName, emailAddr;

View File

@ -12,9 +12,11 @@ create or replace procedure createHsOfficeRelationTestData(
holderPersonName varchar, holderPersonName varchar,
relationType HsOfficeRelationType, relationType HsOfficeRelationType,
anchorPersonName varchar, anchorPersonName varchar,
contactCaption varchar) contactCaption varchar,
mark varchar default null)
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar;
idName varchar; idName varchar;
anchorPerson hs_office_person; anchorPerson hs_office_person;
holderPerson hs_office_person; holderPerson hs_office_person;
@ -22,6 +24,9 @@ declare
begin begin
idName := cleanIdentifier( anchorPersonName || '-' || holderPersonName); idName := cleanIdentifier( anchorPersonName || '-' || holderPersonName);
currentTask := 'creating relation test-data ' || idName;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
execute format('set local hsadminng.currentTask to %L', currentTask);
select p.* select p.*
into anchorPerson into anchorPerson
@ -84,8 +89,6 @@ end; $$;
do language plpgsql $$ do language plpgsql $$
begin begin
call defineContext('creating relation test-data', null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
call createHsOfficeRelationTestData('First GmbH', 'PARTNER', 'Hostsharing eG', 'first contact'); call createHsOfficeRelationTestData('First GmbH', 'PARTNER', 'Hostsharing eG', 'first contact');
call createHsOfficeRelationTestData('Firby', 'REPRESENTATIVE', 'First GmbH', 'first contact'); call createHsOfficeRelationTestData('Firby', 'REPRESENTATIVE', 'First GmbH', 'first contact');
call createHsOfficeRelationTestData('First GmbH', 'DEBITOR', 'First GmbH', 'first contact'); call createHsOfficeRelationTestData('First GmbH', 'DEBITOR', 'First GmbH', 'first contact');

View File

@ -15,6 +15,7 @@ create or replace procedure createHsOfficePartnerTestData(
contactCaption varchar ) contactCaption varchar )
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar;
idName varchar; idName varchar;
mandantPerson hs_office_person; mandantPerson hs_office_person;
partnerRel hs_office_relation; partnerRel hs_office_relation;
@ -22,6 +23,9 @@ declare
relatedDetailsUuid uuid; relatedDetailsUuid uuid;
begin begin
idName := cleanIdentifier( partnerPersonName|| '-' || contactCaption); idName := cleanIdentifier( partnerPersonName|| '-' || contactCaption);
currentTask := 'creating partner test-data ' || idName;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
execute format('set local hsadminng.currentTask to %L', currentTask);
select p.* from hs_office_person p select p.* from hs_office_person p
where p.tradeName = mandantTradeName where p.tradeName = mandantTradeName
@ -65,14 +69,13 @@ end; $$;
--// --//
-- ============================================================================ -- ============================================================================
--changeset hs-office-partner-TEST-DATA-GENERATION:1 context=dev,tc endDelimiter:--// --changeset hs-office-partner-TEST-DATA-GENERATION:1 context=dev,tc endDelimiter:--//
-- ---------------------------------------------------------------------------- -- ----------------------------------------------------------------------------
do language plpgsql $$ do language plpgsql $$
begin begin
call defineContext('creating partner test-data ', null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
call createHsOfficePartnerTestData('Hostsharing eG', 10001, 'First GmbH', 'first contact'); call createHsOfficePartnerTestData('Hostsharing eG', 10001, 'First GmbH', 'first contact');
call createHsOfficePartnerTestData('Hostsharing eG', 10002, 'Second e.K.', 'second contact'); call createHsOfficePartnerTestData('Hostsharing eG', 10002, 'Second e.K.', 'second contact');
call createHsOfficePartnerTestData('Hostsharing eG', 10003, 'Third OHG', 'third contact'); call createHsOfficePartnerTestData('Hostsharing eG', 10003, 'Third OHG', 'third contact');

View File

@ -11,11 +11,16 @@
create or replace procedure createHsOfficeBankAccountTestData(givenHolder varchar, givenIBAN varchar, givenBIC varchar) create or replace procedure createHsOfficeBankAccountTestData(givenHolder varchar, givenIBAN varchar, givenBIC varchar)
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar;
emailAddr varchar; emailAddr varchar;
begin begin
currentTask = 'creating bankaccount test-data ' || givenHolder;
execute format('set local hsadminng.currentTask to %L', currentTask);
emailAddr = 'bankaccount-admin@' || cleanIdentifier(givenHolder) || '.example.com'; emailAddr = 'bankaccount-admin@' || cleanIdentifier(givenHolder) || '.example.com';
call defineContext(currentTask);
perform createRbacUser(emailAddr); perform createRbacUser(emailAddr);
call defineContext('creating bankaccount test-data', null, emailAddr); call defineContext(currentTask, null, emailAddr);
raise notice 'creating test bankaccount: %', givenHolder; raise notice 'creating test bankaccount: %', givenHolder;
insert insert
@ -31,8 +36,6 @@ end; $$;
do language plpgsql $$ do language plpgsql $$
begin begin
call defineContext('creating bankaccount test-data');
-- IBANs+BICs taken from https://ibanvalidieren.de/beispiele.html -- IBANs+BICs taken from https://ibanvalidieren.de/beispiele.html
call createHsOfficeBankAccountTestData('First GmbH', 'DE02120300000000202051', 'BYLADEM1001'); call createHsOfficeBankAccountTestData('First GmbH', 'DE02120300000000202051', 'BYLADEM1001');
call createHsOfficeBankAccountTestData('Peter Smith', 'DE02500105170137075030', 'INGDDEFF'); call createHsOfficeBankAccountTestData('Peter Smith', 'DE02500105170137075030', 'INGDDEFF');

View File

@ -16,11 +16,15 @@ create or replace procedure createHsOfficeDebitorTestData(
) )
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar;
idName varchar; idName varchar;
relatedDebitorRelUuid uuid; relatedDebitorRelUuid uuid;
relatedBankAccountUuid uuid; relatedBankAccountUuid uuid;
begin begin
idName := cleanIdentifier( forPartnerPersonName|| '-' || forBillingContactCaption); idName := cleanIdentifier( forPartnerPersonName|| '-' || forBillingContactCaption);
currentTask := 'creating debitor test-data ' || idName;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
execute format('set local hsadminng.currentTask to %L', currentTask);
select debitorRel.uuid select debitorRel.uuid
into relatedDebitorRelUuid into relatedDebitorRelUuid
@ -50,8 +54,6 @@ end; $$;
do language plpgsql $$ do language plpgsql $$
begin begin
call defineContext('creating debitor test-data', null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
call createHsOfficeDebitorTestData(11, 'First GmbH', 'first contact', 'fir'); call createHsOfficeDebitorTestData(11, 'First GmbH', 'first contact', 'fir');
call createHsOfficeDebitorTestData(12, 'Second e.K.', 'second contact', 'sec'); call createHsOfficeDebitorTestData(12, 'Second e.K.', 'second contact', 'sec');
call createHsOfficeDebitorTestData(13, 'Third OHG', 'third contact', 'thi'); call createHsOfficeDebitorTestData(13, 'Third OHG', 'third contact', 'thi');

View File

@ -15,9 +15,14 @@ create or replace procedure createHsOfficeSepaMandateTestData(
withReference varchar) withReference varchar)
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar;
relatedDebitor hs_office_debitor; relatedDebitor hs_office_debitor;
relatedBankAccount hs_office_bankAccount; relatedBankAccount hs_office_bankAccount;
begin begin
currentTask := 'creating SEPA-mandate test-data ' || forPartnerNumber::text || forDebitorSuffix::text;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
execute format('set local hsadminng.currentTask to %L', currentTask);
select debitor.* into relatedDebitor select debitor.* into relatedDebitor
from hs_office_debitor debitor from hs_office_debitor debitor
join hs_office_relation debitorRel on debitorRel.uuid = debitor.debitorRelUuid join hs_office_relation debitorRel on debitorRel.uuid = debitor.debitorRelUuid
@ -43,8 +48,6 @@ end; $$;
do language plpgsql $$ do language plpgsql $$
begin begin
call defineContext('creating SEPA-mandate test-data', null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
call createHsOfficeSepaMandateTestData(10001, '11', 'DE02120300000000202051', 'ref-10001-11'); call createHsOfficeSepaMandateTestData(10001, '11', 'DE02120300000000202051', 'ref-10001-11');
call createHsOfficeSepaMandateTestData(10002, '12', 'DE02100500000054540402', 'ref-10002-12'); call createHsOfficeSepaMandateTestData(10002, '12', 'DE02100500000054540402', 'ref-10002-12');
call createHsOfficeSepaMandateTestData(10003, '13', 'DE02300209000106531065', 'ref-10003-13'); call createHsOfficeSepaMandateTestData(10003, '13', 'DE02300209000106531065', 'ref-10003-13');

View File

@ -13,8 +13,15 @@ create or replace procedure createHsOfficeMembershipTestData(
newMemberNumberSuffix char(2) ) newMemberNumberSuffix char(2) )
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar;
relatedPartner hs_office_partner; relatedPartner hs_office_partner;
begin begin
currentTask := 'creating Membership test-data ' ||
'P-' || forPartnerNumber::text ||
'M-...' || newMemberNumberSuffix;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
execute format('set local hsadminng.currentTask to %L', currentTask);
select partner.* from hs_office_partner partner select partner.* from hs_office_partner partner
where partner.partnerNumber = forPartnerNumber into relatedPartner; where partner.partnerNumber = forPartnerNumber into relatedPartner;
@ -33,8 +40,6 @@ end; $$;
do language plpgsql $$ do language plpgsql $$
begin begin
call defineContext('creating Membership test-data', null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
call createHsOfficeMembershipTestData(10001, '01'); call createHsOfficeMembershipTestData(10001, '01');
call createHsOfficeMembershipTestData(10002, '02'); call createHsOfficeMembershipTestData(10002, '02');
call createHsOfficeMembershipTestData(10003, '03'); call createHsOfficeMembershipTestData(10003, '03');

View File

@ -14,9 +14,15 @@ create or replace procedure createHsOfficeCoopSharesTransactionTestData(
) )
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar;
membership hs_office_membership; membership hs_office_membership;
subscriptionEntryUuid uuid; subscriptionEntryUuid uuid;
begin begin
currentTask = 'creating coopSharesTransaction test-data ' || givenPartnerNumber::text || givenMemberNumberSuffix;
execute format('set local hsadminng.currentTask to %L', currentTask);
SET CONSTRAINTS ALL DEFERRED;
call defineContext(currentTask);
select m.uuid select m.uuid
from hs_office_membership m from hs_office_membership m
join hs_office_partner p on p.uuid = m.partneruuid join hs_office_partner p on p.uuid = m.partneruuid
@ -43,9 +49,6 @@ end; $$;
do language plpgsql $$ do language plpgsql $$
begin begin
call defineContext('creating coopSharesTransaction test-data');
SET CONSTRAINTS ALL DEFERRED;
call createHsOfficeCoopSharesTransactionTestData(10001, '01'); call createHsOfficeCoopSharesTransactionTestData(10001, '01');
call createHsOfficeCoopSharesTransactionTestData(10002, '02'); call createHsOfficeCoopSharesTransactionTestData(10002, '02');
call createHsOfficeCoopSharesTransactionTestData(10003, '03'); call createHsOfficeCoopSharesTransactionTestData(10003, '03');

View File

@ -14,9 +14,15 @@ create or replace procedure createHsOfficeCoopAssetsTransactionTestData(
) )
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar;
membership hs_office_membership; membership hs_office_membership;
lossEntryUuid uuid; lossEntryUuid uuid;
begin begin
currentTask = 'creating coopAssetsTransaction test-data ' || givenPartnerNumber || givenMemberNumberSuffix;
execute format('set local hsadminng.currentTask to %L', currentTask);
SET CONSTRAINTS ALL DEFERRED;
call defineContext(currentTask);
select m.uuid select m.uuid
from hs_office_membership m from hs_office_membership m
join hs_office_partner p on p.uuid = m.partneruuid join hs_office_partner p on p.uuid = m.partneruuid
@ -43,9 +49,6 @@ end; $$;
do language plpgsql $$ do language plpgsql $$
begin begin
call defineContext('creating coopAssetsTransaction test-data');
SET CONSTRAINTS ALL DEFERRED;
call createHsOfficeCoopAssetsTransactionTestData(10001, '01'); call createHsOfficeCoopAssetsTransactionTestData(10001, '01');
call createHsOfficeCoopAssetsTransactionTestData(10002, '02'); call createHsOfficeCoopAssetsTransactionTestData(10002, '02');
call createHsOfficeCoopAssetsTransactionTestData(10003, '03'); call createHsOfficeCoopAssetsTransactionTestData(10003, '03');

View File

@ -14,8 +14,12 @@ create or replace procedure createHsBookingProjectTransactionTestData(
) )
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar;
relatedDebitor hs_office_debitor; relatedDebitor hs_office_debitor;
begin begin
currentTask := 'creating booking-project test-data ' || givenPartnerNumber::text || givenDebitorSuffix;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
execute format('set local hsadminng.currentTask to %L', currentTask);
select debitor.* into relatedDebitor select debitor.* into relatedDebitor
from hs_office_debitor debitor from hs_office_debitor debitor
@ -39,8 +43,6 @@ end; $$;
do language plpgsql $$ do language plpgsql $$
begin begin
call defineContext('creating booking-project test-data', null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
call createHsBookingProjectTransactionTestData(10001, '11'); call createHsBookingProjectTransactionTestData(10001, '11');
call createHsBookingProjectTransactionTestData(10002, '12'); call createHsBookingProjectTransactionTestData(10002, '12');
call createHsBookingProjectTransactionTestData(10003, '13'); call createHsBookingProjectTransactionTestData(10003, '13');

View File

@ -14,10 +14,15 @@ create or replace procedure createHsBookingItemTransactionTestData(
) )
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar;
relatedProject hs_booking_project; relatedProject hs_booking_project;
privateCloudUuid uuid; privateCloudUuid uuid;
managedServerUuid uuid; managedServerUuid uuid;
begin begin
currentTask := 'creating booking-item test-data ' || givenPartnerNumber::text || givenDebitorSuffix;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
execute format('set local hsadminng.currentTask to %L', currentTask);
select project.* into relatedProject select project.* into relatedProject
from hs_booking_project project from hs_booking_project project
where project.caption = 'D-' || givenPartnerNumber || givenDebitorSuffix || ' default project'; where project.caption = 'D-' || givenPartnerNumber || givenDebitorSuffix || ' default project';
@ -44,11 +49,7 @@ end; $$;
-- ---------------------------------------------------------------------------- -- ----------------------------------------------------------------------------
do language plpgsql $$ do language plpgsql $$
declare
currentTask text;
begin begin
call defineContext('creating booking-item test-data', null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
call createHsBookingItemTransactionTestData(10001, '11'); call createHsBookingItemTransactionTestData(10001, '11');
call createHsBookingItemTransactionTestData(10002, '12'); call createHsBookingItemTransactionTestData(10002, '12');
call createHsBookingItemTransactionTestData(10003, '13'); call createHsBookingItemTransactionTestData(10003, '13');

View File

@ -11,6 +11,7 @@
create or replace procedure createHsHostingAssetTestData(givenProjectCaption varchar) create or replace procedure createHsHostingAssetTestData(givenProjectCaption varchar)
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar;
relatedProject hs_booking_project; relatedProject hs_booking_project;
relatedDebitor hs_office_debitor; relatedDebitor hs_office_debitor;
privateCloudBI hs_booking_item; privateCloudBI hs_booking_item;
@ -30,7 +31,9 @@ declare
pgSqlInstanceUuid uuid; pgSqlInstanceUuid uuid;
PgSqlUserUuid uuid; PgSqlUserUuid uuid;
begin begin
call defineContext('creating hosting-asset test-data', null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN'); currentTask := 'creating hosting-asset test-data ' || givenProjectCaption;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
execute format('set local hsadminng.currentTask to %L', currentTask);
select project.* into relatedProject select project.* into relatedProject
from hs_booking_project project from hs_booking_project project
@ -110,8 +113,6 @@ end; $$;
do language plpgsql $$ do language plpgsql $$
begin begin
call defineContext('creating hosting-asset test-data', null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
call createHsHostingAssetTestData('D-1000111 default project'); call createHsHostingAssetTestData('D-1000111 default project');
call createHsHostingAssetTestData('D-1000212 default project'); call createHsHostingAssetTestData('D-1000212 default project');
call createHsHostingAssetTestData('D-1000313 default project'); call createHsHostingAssetTestData('D-1000313 default project');

View File

@ -68,7 +68,7 @@ class HsBookingItemRepositoryIntegrationTest extends ContextBasedTestWithCleanup
public void auditJournalLogIsAvailable() { public void auditJournalLogIsAvailable() {
// given // given
final var query = em.createNativeQuery(""" final var query = em.createNativeQuery("""
select currentTask, targetTable, targetOp, targetdelta->>'caption' select currentTask, targetTable, targetOp
from tx_journal_v from tx_journal_v
where targettable = 'hs_booking_item'; where targettable = 'hs_booking_item';
"""); """);
@ -78,13 +78,9 @@ class HsBookingItemRepositoryIntegrationTest extends ContextBasedTestWithCleanup
// then // then
assertThat(customerLogEntries).map(Arrays::toString).contains( assertThat(customerLogEntries).map(Arrays::toString).contains(
"[creating booking-item test-data, hs_booking_item, INSERT, prod CloudServer]", "[creating booking-item test-data 1000111, hs_booking_item, INSERT]",
"[creating booking-item test-data, hs_booking_item, INSERT, separate ManagedServer]", "[creating booking-item test-data 1000212, hs_booking_item, INSERT]",
"[creating booking-item test-data, hs_booking_item, INSERT, separate ManagedWebspace]", "[creating booking-item test-data 1000313, hs_booking_item, INSERT]");
"[creating booking-item test-data, hs_booking_item, INSERT, some ManagedServer]",
"[creating booking-item test-data, hs_booking_item, INSERT, some ManagedWebspace]",
"[creating booking-item test-data, hs_booking_item, INSERT, some PrivateCloud]",
"[creating booking-item test-data, hs_booking_item, INSERT, test CloudServer]");
} }
@Test @Test