Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
Notification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSDU
OSDU Data Platform
System
Notification
Commits
5c05a2eb
Commit
5c05a2eb
authored
1 year ago
by
Yash Dholakia
Browse files
Options
Downloads
Patches
Plain Diff
Modify tests
parent
f2ee427c
No related branches found
No related tags found
1 merge request
!417
AWS sync dev to master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
testing/notification-test-aws/src/test/java/org/opengroup/osdu/notification/subscriptions/TestNotificationsEndpoint.java
+3
-74
3 additions, 74 deletions
...notification/subscriptions/TestNotificationsEndpoint.java
with
3 additions
and
74 deletions
testing/notification-test-aws/src/test/java/org/opengroup/osdu/notification/subscriptions/TestNotificationsEndpoint.java
+
3
−
74
View file @
5c05a2eb
...
...
@@ -24,21 +24,17 @@ import static org.junit.Assert.assertEquals;
public
class
TestNotificationsEndpoint
extends
TestBase
{
private
String
subscriptionId_TestPartition
;
private
String
subscriptionId
;
private
ISubscriptionService
awssubscriptionService
;
private
TestUtils
testUtils
;
private
static
SubscriptionFactory
awsfactory
;
private
static
final
long
NOW
=
System
.
currentTimeMillis
();
private
static
final
String
RECORD_ID_PREFIX
=
TenantUtils
.
getTenantName
(
false
)
+
":query:"
;
private
static
final
String
RECORD_ID_PREFIX_TEST
=
TenantUtils
.
getTenantName
(
true
)
+
":query:"
;
private
static
final
String
KIND
=
TenantUtils
.
getTenantName
(
false
)
+
":ds:query:1.0."
+
NOW
;
private
static
final
String
KIND_TEST
=
TenantUtils
.
getTenantName
(
true
)
+
":ds:query:1.0."
+
NOW
;
private
static
final
String
LEGAL_TAG
=
TenantUtils
.
getTenantName
(
false
)
+
"-storage-"
+
System
.
currentTimeMillis
();
private
static
final
String
LEGAL_TAG_TEST
=
TenantUtils
.
getTenantName
(
true
)
+
"-storage-"
+
System
.
currentTimeMillis
();
protected
static
final
String
PARTITION_TEST
=
"pe
rformance-t
es
t
"
;
protected
static
final
String
PARTITION_TEST
=
"
o
pe
nd
es"
;
protected
static
final
String
PERSISTABLE_REFERENCE
=
"%7B%22LB_CRS%22%3A%22%257B%2522WKT%2522%253A%2522PROJCS%255B%255C%2522British_National_Grid%255C%2522%252CGEOGCS%255B%255C%2522GCS_OSGB_1936%255C%2522%252CDATUM%255B%255C%2522D_OSGB_1936%255C%2522%252CSPHEROID%255B%255C%2522Airy_1830%255C%2522%252C6377563.396%252C299.3249646%255D%255D%252CPRIMEM%255B%255C%2522Greenwich%255C%2522%252C0.0%255D%252CUNIT%255B%255C%2522Degree%255C%2522%252C0.0174532925199433%255D%255D%252CPROJECTION%255B%255C%2522Transverse_Mercator%255C%2522%255D%252CPARAMETER%255B%255C%2522False_Easting%255C%2522%252C400000.0%255D%252CPARAMETER%255B%255C%2522False_Northing%255C%2522%252C-100000.0%255D%252CPARAMETER%255B%255C%2522Central_Meridian%255C%2522%252C-2.0%255D%252CPARAMETER%255B%255C%2522Scale_Factor%255C%2522%252C0.9996012717%255D%252CPARAMETER%255B%255C%2522Latitude_Of_Origin%255C%2522%252C49.0%255D%252CUNIT%255B%255C%2522Meter%255C%2522%252C1.0%255D%252CAUTHORITY%255B%255C%2522EPSG%255C%2522%252C27700%255D%255D%2522%252C%2522Type%2522%253A%2522LBCRS%2522%252C%2522EngineVersion%2522%253A%2522PE_10_3_1%2522%252C%2522AuthorityCode%2522%253A%257B%2522Authority%2522%253A%2522EPSG%2522%252C%2522Code%2522%253A%252227700%2522%257D%252C%2522Name%2522%253A%2522British_National_Grid%2522%257D%22%2C%22TRF%22%3A%22%257B%2522WKT%2522%253A%2522GEOGTRAN%255B%255C%2522OSGB_1936_To_WGS_1984_Petroleum%255C%2522%252CGEOGCS%255B%255C%2522GCS_OSGB_1936%255C%2522%252CDATUM%255B%255C%2522D_OSGB_1936%255C%2522%252CSPHEROID%255B%255C%2522Airy_1830%255C%2522%252C6377563.396%252C299.3249646%255D%255D%252CPRIMEM%255B%255C%2522Greenwich%255C%2522%252C0.0%255D%252CUNIT%255B%255C%2522Degree%255C%2522%252C0.0174532925199433%255D%255D%252CGEOGCS%255B%255C%2522GCS_WGS_1984%255C%2522%252CDATUM%255B%255C%2522D_WGS_1984%255C%2522%252CSPHEROID%255B%255C%2522WGS_1984%255C%2522%252C6378137.0%252C298.257223563%255D%255D%252CPRIMEM%255B%255C%2522Greenwich%255C%2522%252C0.0%255D%252CUNIT%255B%255C%2522Degree%255C%2522%252C0.0174532925199433%255D%255D%252CMETHOD%255B%255C%2522Position_Vector%255C%2522%255D%252CPARAMETER%255B%255C%2522X_Axis_Translation%255C%2522%252C446.448%255D%252CPARAMETER%255B%255C%2522Y_Axis_Translation%255C%2522%252C-125.157%255D%252CPARAMETER%255B%255C%2522Z_Axis_Translation%255C%2522%252C542.06%255D%252CPARAMETER%255B%255C%2522X_Axis_Rotation%255C%2522%252C0.15%255D%252CPARAMETER%255B%255C%2522Y_Axis_Rotation%255C%2522%252C0.247%255D%252CPARAMETER%255B%255C%2522Z_Axis_Rotation%255C%2522%252C0.842%255D%252CPARAMETER%255B%255C%2522Scale_Difference%255C%2522%252C-20.489%255D%252CAUTHORITY%255B%255C%2522EPSG%255C%2522%252C1314%255D%255D%2522%252C%2522Type%2522%253A%2522STRF%2522%252C%2522EngineVersion%2522%253A%2522PE_10_3_1%2522%252C%2522AuthorityCode%2522%253A%257B%2522Authority%2522%253A%2522EPSG%2522%252C%2522Code%2522%253A%25221314%2522%257D%252C%2522Name%2522%253A%2522OSGB_1936_To_WGS_1984_Petroleum%2522%257D%22%2C%22Type%22%3A%22EBCRS%22%2C%22EngineVersion%22%3A%22PE_10_3_1%22%2C%22Name%22%3A%22OSGB+1936+*+UKOOA-Pet+%2F+British+National+Grid+%5B27700%2C1314%5D%22%2C%22AuthorityCode%22%3A%7B%22Authority%22%3A%22MyCompany%22%2C%22Code%22%3A%2227700006%22%7D%7D"
;
@BeforeClass
...
...
@@ -97,49 +93,6 @@ public class TestNotificationsEndpoint extends TestBase {
}
}
private
void
createResource
()
throws
Exception
{
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
DpsHeaders
.
DATA_PARTITION_ID
,
TestUtils
.
getOsduTenant
());
headers
.
put
(
DpsHeaders
.
AUTHORIZATION
,
testUtils
.
getOpsToken
());
//hardcoding user here for 200 response tests. This is just initializing the subscription creation
headers
.
put
(
"x-user-id"
,
AwsConfig
.
getAWSCognitoUser
());
DpsHeaders
dpsHeaders
=
DpsHeaders
.
createFromMap
(
headers
);
awssubscriptionService
=
awsfactory
.
create
(
dpsHeaders
);
Map
<
String
,
String
>
h
=
dpsHeaders
.
getHeaders
();
System
.
out
.
println
(
h
);
//Create a new subscription to pub/sub
Subscription
subscription
=
new
Subscription
();
subscription
.
setName
(
"Subscription-test-for-notification"
);
subscription
.
setDescription
(
"Subscription for fetching notifications"
);
subscription
.
setTopic
(
Config
.
Instance
().
Topic
);
//This seems to be a bug. Don't need to add the string
//subscription.setPushEndpoint(Config.Instance().HMACPushUrl + "hmac-integration-test");
subscription
.
setPushEndpoint
(
Config
.
Instance
().
HMACPushUrl
);
HmacSecret
secret
=
new
HmacSecret
();
secret
.
setValue
(
Config
.
Instance
().
hmacSecretValue
);
subscription
.
setSecret
(
secret
);
try
{
Subscription
subscriptionCreated
=
awssubscriptionService
.
create
(
subscription
);
System
.
out
.
println
(
"Subscription created successfully"
);
String
notificationId
=
subscriptionCreated
.
getNotificationId
();
subscriptionId
=
subscriptionCreated
.
getId
();
Config
.
Instance
().
NotificationId
=
notificationId
;
}
catch
(
SubscriptionException
e
){
System
.
out
.
println
(
"Subscription exception inner response : "
+
e
.
getHttpResponse
());
throw
e
;
}
}
private
ClientResponse
createStorageRecord
(
final
String
correlationId
)
throws
Exception
{
String
recordId
=
RECORD_ID_PREFIX
+
UUID
.
randomUUID
().
toString
();
String
jsonInput
=
RecordUtils
.
createJsonRecordWithReference
(
1
,
recordId
,
KIND
,
LEGAL_TAG
,
PERSISTABLE_REFERENCE
,
"CRS"
,
false
);
return
StorageTestUtils
.
send
(
"records"
,
"PUT"
,
StorageTestUtils
.
getHeaders
(
TenantUtils
.
getTenantName
(
false
),
testUtils
.
getAdminToken
(),
correlationId
,
false
),
jsonInput
,
""
);
}
private
ClientResponse
createStorageRecordForTestPartition
(
final
String
correlationId
)
throws
Exception
{
String
recordId
=
RECORD_ID_PREFIX_TEST
+
UUID
.
randomUUID
().
toString
();
String
jsonInput
=
RecordUtils
.
createJsonRecordWithReference
(
1
,
recordId
,
KIND_TEST
,
LEGAL_TAG_TEST
,
PERSISTABLE_REFERENCE
,
"CRS"
,
true
);
...
...
@@ -147,7 +100,7 @@ public class TestNotificationsEndpoint extends TestBase {
}
@Test
public
void
testVerifyNotificationReceived
WhenDataPartitionIdIsDifferent
()
throws
Exception
{
public
void
testVerifyNotificationReceived
()
throws
Exception
{
try
{
LegalTagUtils
.
create
(
LEGAL_TAG_TEST
,
testUtils
.
getOpsToken
(),
true
);
createResourceForTestParition
();
...
...
@@ -157,30 +110,6 @@ public class TestNotificationsEndpoint extends TestBase {
//Executing notifications response to endpoints takes an upper bound of 120s.
Thread
.
sleep
(
120000
);
//Run Bash File to fetch logs from register endpoint and verify that notification was received
String
bashFileToExecute
=
"src/test/java/org/opengroup/osdu/notification/subscriptions/verify_register-logs.sh "
+
correlationId
;
Process
process
=
Runtime
.
getRuntime
().
exec
(
bashFileToExecute
);
process
.
waitFor
();
int
exitValue
=
process
.
exitValue
();
assertEquals
(
exitValue
,
1
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Error while verifying notification service. Error = "
+
e
.
getMessage
()
+
" Stack Trace = "
+
Arrays
.
toString
(
e
.
getStackTrace
()));
}
finally
{
awssubscriptionService
.
delete
(
subscriptionId_TestPartition
);
}
}
@Test
public
void
testVerifyNotificationReceivedWhenDataPartitionIdIsSame
()
throws
Exception
{
try
{
LegalTagUtils
.
create
(
LEGAL_TAG
,
testUtils
.
getOpsToken
(),
false
);
createResource
();
final
String
correlationId
=
UUID
.
randomUUID
().
toString
();
ClientResponse
response
=
createStorageRecord
(
correlationId
);
assertEquals
(
201
,
response
.
getStatus
());
//Executing notifications response to endpoints takes an upper bound of 120s.
Thread
.
sleep
(
120000
);
//Run Bash File to fetch logs from register endpoint and verify that notification was received
String
bashFileToExecute
=
"src/test/java/org/opengroup/osdu/notification/subscriptions/verify_register-logs.sh "
+
correlationId
;
Process
process
=
Runtime
.
getRuntime
().
exec
(
bashFileToExecute
);
...
...
@@ -190,7 +119,7 @@ public class TestNotificationsEndpoint extends TestBase {
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Error while verifying notification service. Error = "
+
e
.
getMessage
()
+
" Stack Trace = "
+
Arrays
.
toString
(
e
.
getStackTrace
()));
}
finally
{
awssubscriptionService
.
delete
(
subscriptionId
);
awssubscriptionService
.
delete
(
subscriptionId
_TestPartition
);
}
}
}
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