Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
6f94f297
Commit
6f94f297
authored
1 year ago
by
piotr.kupczyk@id.ethz.ch
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-13578 : 2PT : Database and V3 Implementation - integration tests
parent
af0d7e7e
No related branches found
No related tags found
1 merge request
!40
SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test-integration/sourceTest/java/ch/ethz/sis/openbis/systemtests/Integration2PCTest.java
+80
-6
80 additions, 6 deletions
...a/ch/ethz/sis/openbis/systemtests/Integration2PCTest.java
with
80 additions
and
6 deletions
test-integration/sourceTest/java/ch/ethz/sis/openbis/systemtests/Integration2PCTest.java
+
80
−
6
View file @
6f94f297
...
...
@@ -202,11 +202,78 @@ public class Integration2PCTest extends AbstractIntegrationTest
}
}
@Test
public
void
testBeginFailsAtAS
()
{
// make begin fail at AS
setApplicationServerProxyInterceptor
((
method
,
defaultAction
)
->
{
if
(
method
!=
null
&&
method
.
equals
(
"beginTransaction"
))
{
throw
new
RuntimeException
(
"Test begin exception"
);
}
else
{
defaultAction
.
call
();
}
});
OpenBIS
openBIS
=
createOpenBIS
();
openBIS
.
setInteractiveSessionKey
(
TEST_INTERACTIVE_SESSION_KEY
);
openBIS
.
login
(
USER
,
PASSWORD
);
openBIS
.
beginTransaction
();
String
owner
=
OWNER_PREFIX
+
UUID
.
randomUUID
();
String
source
=
SOURCE_PREFIX
+
UUID
.
randomUUID
();
byte
[]
bytesToWrite
=
CONTENT
.
getBytes
(
StandardCharsets
.
UTF_8
);
openBIS
.
getAfsServerFacade
().
write
(
owner
,
source
,
0L
,
bytesToWrite
,
calculateMD5
(
bytesToWrite
));
assertTransactions
(
coordinatorApi
.
getTransactionMap
(),
new
TestTransaction
(
openBIS
.
getTransactionId
(),
TransactionStatus
.
BEGIN_FINISHED
));
SpaceCreation
spaceCreation
=
new
SpaceCreation
();
spaceCreation
.
setCode
(
CODE_PREFIX
+
UUID
.
randomUUID
());
try
{
// first attempt
openBIS
.
createSpaces
(
List
.
of
(
spaceCreation
));
fail
();
}
catch
(
Exception
e
)
{
assertEquals
(
e
.
getMessage
(),
"Transaction '"
+
openBIS
.
getTransactionId
()
+
"' execute operation 'createSpaces' for participant 'application-server' failed."
);
assertEquals
(
e
.
getCause
().
getMessage
(),
"Begin transaction '"
+
openBIS
.
getTransactionId
()
+
"' failed for participant 'application-server'."
);
}
assertTransactions
(
coordinatorApi
.
getTransactionMap
(),
new
TestTransaction
(
openBIS
.
getTransactionId
(),
TransactionStatus
.
BEGIN_FINISHED
));
// make begin succeed at AS
setApplicationServerProxyInterceptor
((
method
,
defaultAction
)
->
defaultAction
.
call
());
// second attempt
SpacePermId
spaceId
=
openBIS
.
createSpaces
(
List
.
of
(
spaceCreation
)).
get
(
0
);
openBIS
.
commitTransaction
();
assertTransactions
(
coordinatorApi
.
getTransactionMap
());
// check committed data
OpenBIS
openBISNoTr
=
createOpenBIS
();
openBISNoTr
.
login
(
USER
,
PASSWORD
);
Space
createdSpace
=
openBISNoTr
.
getSpaces
(
List
.
of
(
spaceId
),
new
SpaceFetchOptions
()).
get
(
spaceId
);
assertNotNull
(
createdSpace
);
byte
[]
bytesRead
=
openBISNoTr
.
getAfsServerFacade
().
read
(
owner
,
source
,
0L
,
bytesToWrite
.
length
);
assertEquals
(
new
String
(
bytesRead
,
StandardCharsets
.
UTF_8
),
CONTENT
);
}
@Test
public
void
testBeginFailsAtAFS
()
{
// make begin fail at AFS
setAfsServerProxyInterceptor
((
method
,
parameters
,
defaultAction
)
->
setAfsServerProxyInterceptor
((
method
,
defaultAction
)
->
{
if
(
method
!=
null
&&
method
.
equals
(
"begin"
))
{
...
...
@@ -226,7 +293,7 @@ public class Integration2PCTest extends AbstractIntegrationTest
SpaceCreation
spaceCreation
=
new
SpaceCreation
();
spaceCreation
.
setCode
(
CODE_PREFIX
+
UUID
.
randomUUID
());
openBIS
.
createSpaces
(
List
.
of
(
spaceCreation
));
SpacePermId
spaceId
=
openBIS
.
createSpaces
(
List
.
of
(
spaceCreation
))
.
get
(
0
)
;
String
owner
=
OWNER_PREFIX
+
UUID
.
randomUUID
();
String
source
=
SOURCE_PREFIX
+
UUID
.
randomUUID
();
...
...
@@ -249,10 +316,7 @@ public class Integration2PCTest extends AbstractIntegrationTest
assertTransactions
(
coordinatorApi
.
getTransactionMap
(),
new
TestTransaction
(
openBIS
.
getTransactionId
(),
TransactionStatus
.
BEGIN_FINISHED
));
// make begin succeed at AFS
setAfsServerProxyInterceptor
((
method
,
parameters
,
defaultAction
)
->
{
defaultAction
.
call
();
});
setAfsServerProxyInterceptor
((
method
,
defaultAction
)
->
defaultAction
.
call
());
// second attempt
openBIS
.
getAfsServerFacade
().
write
(
owner
,
source
,
0L
,
bytesToWrite
,
calculateMD5
(
bytesToWrite
));
...
...
@@ -260,6 +324,16 @@ public class Integration2PCTest extends AbstractIntegrationTest
openBIS
.
commitTransaction
();
assertTransactions
(
coordinatorApi
.
getTransactionMap
());
// check committed data
OpenBIS
openBISNoTr
=
createOpenBIS
();
openBISNoTr
.
login
(
USER
,
PASSWORD
);
Space
createdSpace
=
openBISNoTr
.
getSpaces
(
List
.
of
(
spaceId
),
new
SpaceFetchOptions
()).
get
(
spaceId
);
assertNotNull
(
createdSpace
);
byte
[]
bytesRead
=
openBISNoTr
.
getAfsServerFacade
().
read
(
owner
,
source
,
0L
,
bytesToWrite
.
length
);
assertEquals
(
new
String
(
bytesRead
,
StandardCharsets
.
UTF_8
),
CONTENT
);
}
private
void
rollbackPreparedDatabaseTransactions
()
throws
Exception
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment