Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Indexer
Commits
5e10ac8f
Commit
5e10ac8f
authored
Dec 28, 2020
by
Sviatoslav Nekhaienko
Browse files
introduced generateActualNameWithoutTs method, this decreases number of renamings
parent
b6b8692a
Pipeline
#20196
failed with stage
in 43 seconds
Changes
5
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/CleanupIndiciesSteps.java
View file @
5e10ac8f
...
...
@@ -66,8 +66,8 @@ public class CleanupIndiciesSteps extends TestsBase {
for
(
Setup
input
:
inputList
)
{
TestIndex
testIndex
=
getTextIndex
();
testIndex
.
setHttpClient
(
httpClient
);
testIndex
.
setIndex
(
generateActualName
WithTS
(
input
.
getIndex
(),
timeStamp
));
testIndex
.
setKind
(
generateActualName
WithTS
(
input
.
getKind
(),
timeStamp
));
testIndex
.
setIndex
(
generateActualName
(
input
.
getIndex
(),
timeStamp
));
testIndex
.
setKind
(
generateActualName
(
input
.
getKind
(),
timeStamp
));
testIndex
.
setSchemaFile
(
input
.
getSchemaFile
());
inputIndexMap
.
put
(
testIndex
.
getKind
(),
testIndex
);
}
...
...
@@ -81,16 +81,16 @@ public class CleanupIndiciesSteps extends TestsBase {
}
public
void
iIngestRecordsWithTheforAGiven
(
String
record
,
String
dataGroup
,
String
kind
)
{
String
actualKind
=
generateActualName
WithTS
(
kind
,
timeStamp
);
String
actualKind
=
generateActualName
(
kind
,
timeStamp
);
try
{
String
fileContent
=
FileHandler
.
readFile
(
String
.
format
(
"%s.%s"
,
record
,
"json"
));
records
=
new
Gson
().
fromJson
(
fileContent
,
new
TypeToken
<
List
<
Map
<
String
,
Object
>>>()
{}.
getType
());
for
(
Map
<
String
,
Object
>
testRecord
:
records
)
{
testRecord
.
put
(
"id"
,
generateActualName
WithTS
(
testRecord
.
get
(
"id"
).
toString
(),
timeStamp
));
testRecord
.
put
(
"id"
,
generateActualName
(
testRecord
.
get
(
"id"
).
toString
(),
timeStamp
));
testRecord
.
put
(
"kind"
,
actualKind
);
testRecord
.
put
(
"legal"
,
generateLegalTag
());
String
[]
x_acl
=
{
generateActualName
WithTS
(
dataGroup
,
timeStamp
)+
"."
+
getEntitlementsDomain
()};
String
[]
x_acl
=
{
generateActualName
(
dataGroup
,
timeStamp
)+
"."
+
getEntitlementsDomain
()};
Acl
acl
=
Acl
.
builder
().
viewers
(
x_acl
).
owners
(
x_acl
).
build
();
testRecord
.
put
(
"acl"
,
acl
);
}
...
...
@@ -103,7 +103,7 @@ public class CleanupIndiciesSteps extends TestsBase {
}
public
void
iCheckThatTheIndexForHasBeenCreated
(
String
kind
)
throws
IOException
,
InterruptedException
{
assertTrue
(
isNewIndexCreated
(
generateActualName
WithTS
(
kind
,
timeStamp
)));
assertTrue
(
isNewIndexCreated
(
generateActualName
(
kind
,
timeStamp
)));
}
public
void
iShouldDeleteTheRecordsForICreatedEarlier
()
{
...
...
@@ -124,13 +124,13 @@ public class CleanupIndiciesSteps extends TestsBase {
public
void
iShouldDeleteTheSchemaForICreatedEarlier
(
String
kind
)
{
ClientResponse
response
=
httpClient
.
send
(
HttpMethod
.
DELETE
,
String
.
format
(
"%sschemas%s"
,
getStorageBaseURL
(),
"/"
+
generateActualName
WithTS
(
kind
,
timeStamp
)),
null
,
String
.
format
(
"%sschemas%s"
,
getStorageBaseURL
(),
"/"
+
generateActualName
(
kind
,
timeStamp
)),
null
,
headers
,
httpClient
.
getAccessToken
());
assertEquals
(
HttpStatus
.
SC_NO_CONTENT
,
response
.
getStatus
());
}
public
void
iShouldCheckThetTheIndexforHasNotBeenDeleted
(
String
kind
)
throws
IOException
,
InterruptedException
{
assertTrue
(
isNewIndexExist
(
generateActualName
WithTS
(
kind
,
timeStamp
)));
assertTrue
(
isNewIndexExist
(
generateActualName
(
kind
,
timeStamp
)));
}
public
void
iShouldToRunCleanupOfIndexesForAnd
(
String
kind
,
String
message
)
{
...
...
@@ -143,11 +143,11 @@ public class CleanupIndiciesSteps extends TestsBase {
}
public
void
iShouldCheckThatTheIndexForHasBeenDeleted
(
String
kind
)
throws
IOException
,
InterruptedException
{
assertFalse
(
isNewIndexExist
(
generateActualName
WithTS
(
kind
,
timeStamp
)));
assertFalse
(
isNewIndexExist
(
generateActualName
(
kind
,
timeStamp
)));
}
private
String
convertMessageIntoJson
(
String
kind
,
String
message
)
{
String
actualKind
=
generateActualName
WithTS
(
kind
,
timeStamp
);
String
actualKind
=
generateActualName
(
kind
,
timeStamp
);
RecordChangedMessages
recordChangedMessages
=
(
new
Gson
()).
fromJson
(
String
.
format
(
message
,
actualKind
,
actualKind
,
timeStamp
),
RecordChangedMessages
.
class
);
return
new
Gson
().
toJson
(
recordChangedMessages
);
...
...
testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/RecordSteps.java
View file @
5e10ac8f
...
...
@@ -73,8 +73,8 @@ public class RecordSteps extends TestsBase {
for
(
Setup
input
:
inputList
)
{
TestIndex
testIndex
=
getTextIndex
();
testIndex
.
setHttpClient
(
httpClient
);
testIndex
.
setIndex
(
generateActualName
WithTS
(
input
.
getIndex
(),
timeStamp
));
testIndex
.
setKind
(
generateActualName
WithTS
(
input
.
getKind
(),
timeStamp
));
testIndex
.
setIndex
(
generateActualName
(
input
.
getIndex
(),
timeStamp
));
testIndex
.
setKind
(
generateActualName
(
input
.
getKind
(),
timeStamp
));
testIndex
.
setSchemaFile
(
input
.
getSchemaFile
());
inputIndexMap
.
put
(
testIndex
.
getKind
(),
testIndex
);
}
...
...
@@ -91,7 +91,7 @@ public class RecordSteps extends TestsBase {
public
void
i_ingest_records_with_the_for_a_given
(
String
record
,
String
dataGroup
,
String
kind
)
{
String
actualKind
=
generateActualName
WithTS
(
kind
,
timeStamp
);
String
actualKind
=
generateActualName
(
kind
,
timeStamp
);
try
{
String
fileContent
=
FileHandler
.
readFile
(
String
.
format
(
"%s.%s"
,
record
,
"json"
));
records
=
new
Gson
().
fromJson
(
fileContent
,
new
TypeToken
<
List
<
Map
<
String
,
Object
>>>()
{}.
getType
());
...
...
@@ -100,7 +100,7 @@ public class RecordSteps extends TestsBase {
testRecord
.
put
(
"id"
,
generateRecordId
(
testRecord
));
testRecord
.
put
(
"kind"
,
actualKind
);
testRecord
.
put
(
"legal"
,
generateLegalTag
());
String
[]
x_acl
=
{
generateActualName
WithTS
(
dataGroup
,
timeStamp
)+
"."
+
getEntitlementsDomain
()};
String
[]
x_acl
=
{
generateActualName
(
dataGroup
,
timeStamp
)+
"."
+
getEntitlementsDomain
()};
Acl
acl
=
Acl
.
builder
().
viewers
(
x_acl
).
owners
(
x_acl
).
build
();
testRecord
.
put
(
"acl"
,
acl
);
}
...
...
@@ -114,17 +114,17 @@ public class RecordSteps extends TestsBase {
}
protected
String
generateRecordId
(
Map
<
String
,
Object
>
testRecord
)
{
return
generateActualName
WithTS
(
testRecord
.
get
(
"id"
).
toString
(),
timeStamp
);
return
generateActualName
(
testRecord
.
get
(
"id"
).
toString
(),
timeStamp
);
}
public
void
i_should_get_the_documents_for_the_in_the_Elastic_Search
(
int
expectedCount
,
String
index
)
throws
Throwable
{
index
=
generateActualName
WithTS
(
index
,
timeStamp
);
index
=
generateActualName
(
index
,
timeStamp
);
long
numOfIndexedDocuments
=
createIndex
(
index
);
assertEquals
(
expectedCount
,
numOfIndexedDocuments
);
}
public
void
i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search
(
String
expectedMapping
,
String
type
,
String
index
)
throws
Throwable
{
index
=
generateActualName
WithTS
(
index
,
timeStamp
);
index
=
generateActualName
(
index
,
timeStamp
);
ImmutableOpenMap
<
String
,
MappingMetaData
>
elasticMapping
=
elasticUtils
.
getMapping
(
index
);
assertNotNull
(
elasticMapping
);
...
...
@@ -135,7 +135,7 @@ public class RecordSteps extends TestsBase {
}
public
void
iShouldGetTheNumberDocumentsForTheIndexInTheElasticSearchWithOutSkippedAttribute
(
int
expectedCount
,
String
index
,
String
skippedAttributes
)
throws
Throwable
{
index
=
generateActualName
WithTS
(
index
,
timeStamp
);
index
=
generateActualName
(
index
,
timeStamp
);
long
numOfIndexedDocuments
=
createIndex
(
index
);
long
documentCountByQuery
=
elasticUtils
.
fetchRecordsByExistQuery
(
index
,
skippedAttributes
);
assertEquals
(
expectedCount
,
documentCountByQuery
);
...
...
testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/SchemaServiceRecordSteps.java
View file @
5e10ac8f
...
...
@@ -18,13 +18,13 @@ public class SchemaServiceRecordSteps extends RecordSteps {
public
void
the_schema_is_created_with_the_following_kind
(
DataTable
dataTable
)
{
List
<
Setup
>
inputList
=
dataTable
.
asList
(
Setup
.
class
);
inputList
.
forEach
(
this
::
createSchema
);
inputList
.
forEach
(
s
->
deleteIndex
(
generateActualName
(
s
.
getIndex
())));
inputList
.
forEach
(
s
->
deleteIndex
(
generateActualName
WithoutTs
(
s
.
getIndex
())));
super
.
addShutDownHook
();
}
private
void
createSchema
(
Setup
input
)
{
PersistentSchemaTestIndex
testIndex
=
new
PersistentSchemaTestIndex
(
super
.
elasticUtils
,
super
.
httpClient
,
this
);
testIndex
.
setIndex
(
generateActualName
WithTS
(
input
.
getIndex
(),
super
.
getTimeStamp
()));
testIndex
.
setIndex
(
generateActualName
(
input
.
getIndex
(),
super
.
getTimeStamp
()));
testIndex
.
setSchemaFile
(
input
.
getSchemaFile
());
testIndex
.
setHttpClient
(
super
.
httpClient
);
testIndex
.
setupSchema
();
...
...
@@ -39,7 +39,7 @@ public class SchemaServiceRecordSteps extends RecordSteps {
@Override
protected
String
generateRecordId
(
Map
<
String
,
Object
>
testRecord
)
{
return
generateActualName
(
testRecord
.
get
(
"id"
).
toString
());
return
generateActualName
WithoutTs
(
testRecord
.
get
(
"id"
).
toString
());
}
@Override
...
...
testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/TestsBase.java
View file @
5e10ac8f
...
...
@@ -54,19 +54,19 @@ public abstract class TestsBase {
for
(
Setup
input
:
inputList
)
{
TestIndex
testIndex
=
getTextIndex
();
testIndex
.
setHttpClient
(
httpClient
);
testIndex
.
setIndex
(
generateActualName
WithTS
(
input
.
getIndex
(),
timeStamp
));
testIndex
.
setKind
(
generateActualName
WithTS
(
input
.
getKind
(),
timeStamp
));
testIndex
.
setIndex
(
generateActualName
(
input
.
getIndex
(),
timeStamp
));
testIndex
.
setKind
(
generateActualName
(
input
.
getKind
(),
timeStamp
));
testIndex
.
setMappingFile
(
input
.
getMappingFile
());
testIndex
.
setRecordFile
(
input
.
getRecordFile
());
List
<
String
>
dataGroup
=
new
ArrayList
<>();
String
[]
viewerGroup
=
input
.
getViewerGroup
().
split
(
","
);
for
(
int
i
=
0
;
i
<
viewerGroup
.
length
;
i
++)
{
viewerGroup
[
i
]
=
generateActualName
WithTS
(
viewerGroup
[
i
],
timeStamp
)
+
"."
+
getEntitlementsDomain
();
viewerGroup
[
i
]
=
generateActualName
(
viewerGroup
[
i
],
timeStamp
)
+
"."
+
getEntitlementsDomain
();
dataGroup
.
add
(
viewerGroup
[
i
]);
}
String
[]
ownerGroup
=
input
.
getOwnerGroup
().
split
(
","
);
for
(
int
i
=
0
;
i
<
ownerGroup
.
length
;
i
++)
{
ownerGroup
[
i
]
=
generateActualName
WithTS
(
ownerGroup
[
i
],
timeStamp
)
+
"."
+
getEntitlementsDomain
();
ownerGroup
[
i
]
=
generateActualName
(
ownerGroup
[
i
],
timeStamp
)
+
"."
+
getEntitlementsDomain
();
if
(
dataGroup
.
indexOf
(
ownerGroup
[
i
])
>
0
)
{
dataGroup
.
add
(
ownerGroup
[
i
]);
}
...
...
@@ -123,18 +123,18 @@ public abstract class TestsBase {
log
.
info
(
String
.
format
(
"Scenario Name: %s, Correlation-Id: %s"
,
scenario
.
getId
(),
headers
.
get
(
"correlation-id"
)));
}
p
ublic
String
generateActualName
(
String
rawName
)
{
p
rotected
String
generateActualName
(
String
rawName
,
String
timeStamp
)
{
for
(
Map
.
Entry
<
String
,
String
>
tenant
:
tenantMap
.
entrySet
())
{
rawName
=
rawName
.
replaceAll
(
tenant
.
getKey
(),
tenant
.
getValue
());
}
return
rawName
.
replaceAll
(
"<timestamp>"
,
""
);
return
rawName
.
replaceAll
(
"<timestamp>"
,
timeStamp
);
}
p
rotected
String
generateActualNameWith
TS
(
String
rawName
,
String
timeStamp
)
{
p
ublic
String
generateActualNameWith
outTs
(
String
rawName
)
{
for
(
Map
.
Entry
<
String
,
String
>
tenant
:
tenantMap
.
entrySet
())
{
rawName
=
rawName
.
replaceAll
(
tenant
.
getKey
(),
tenant
.
getValue
());
}
return
rawName
.
replaceAll
(
"<timestamp>"
,
timeStamp
);
return
rawName
.
replaceAll
(
"<timestamp>"
,
""
);
}
protected
Legal
generateLegalTag
()
{
...
...
testing/indexer-test-core/src/main/java/org/opengroup/osdu/models/schema/PersistentSchemaTestIndex.java
View file @
5e10ac8f
...
...
@@ -31,7 +31,7 @@ public class PersistentSchemaTestIndex extends TestIndex {
this
.
schemaModel
=
readSchemaFromJson
();
SchemaIdentity
schemaIdentity
=
schemaModel
.
getSchemaInfo
().
getSchemaIdentity
();
LOGGER
.
log
(
Level
.
INFO
,
"Read the schema={0}"
,
schemaIdentity
);
schemaIdentity
.
setAuthority
(
recordSteps
.
generateActualName
(
schemaIdentity
.
getAuthority
()));
schemaIdentity
.
setAuthority
(
recordSteps
.
generateActualName
WithoutTs
(
schemaIdentity
.
getAuthority
()));
LOGGER
.
log
(
Level
.
INFO
,
"Updated the schema={0}"
,
schemaIdentity
);
schemaServiceClient
.
createIfNotExist
(
schemaModel
);
LOGGER
.
log
(
Level
.
INFO
,
"Finished setting up the schema={0}"
,
schemaIdentity
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment