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
Deployment and Operations
Backup Service
Commits
c9b053c4
Commit
c9b053c4
authored
Feb 05, 2021
by
Rustam Lotsmanenko (EPAM)
Browse files
GONRG-1610 Rewrite integration tests for BackupService
parent
61b3f418
Changes
20
Hide whitespace changes
Inline
Side-by-side
backup-core/src/main/java/org/opengroup/osdu/backup/api/BackupCollectionApi.java
View file @
c9b053c4
...
...
@@ -47,7 +47,7 @@ import org.springframework.web.context.annotation.RequestScope;
@RequestMapping
(
value
=
"/collection"
)
@RequestScope
@RequiredArgsConstructor
@PreAuthorize
(
"@authorizationFilter.hasPermission('"
+
BackupRole
.
BACKUP
+
"')"
)
@PreAuthorize
(
"@authorizationFilter.hasPermission('"
+
BackupRole
.
ADMIN
+
"')"
)
@Validated
public
class
BackupCollectionApi
{
...
...
@@ -65,7 +65,7 @@ public class BackupCollectionApi {
@PathVariable
String
collectionName
,
@Validated
(
UpdateCollection
.
class
)
@RequestBody
BackupCollection
collection
)
{
BackupCollection
backupCollection
=
collectionService
.
update
(
collection
,
collectionName
);
return
new
ResponseEntity
<>(
backupCollection
,
HttpStatus
.
CREA
TED
);
return
new
ResponseEntity
<>(
backupCollection
,
HttpStatus
.
ACCEP
TED
);
}
@GetMapping
(
"/{collectionName}"
)
...
...
@@ -96,7 +96,7 @@ public class BackupCollectionApi {
@PatchMapping
(
"/restore/{stateId}"
)
public
ResponseEntity
<
CollectionState
>
restoreCollection
(
@PathVariable
String
stateId
)
{
CollectionState
collectionState
=
collectionService
.
restoreCollection
(
stateId
);
return
new
ResponseEntity
<>(
collectionState
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
collectionState
,
HttpStatus
.
ACCEPTED
);
}
...
...
backup-core/src/main/java/org/opengroup/osdu/backup/exception/AppExceptionHandler.java
View file @
c9b053c4
...
...
@@ -38,9 +38,8 @@ public class AppExceptionHandler {
return
this
.
getErrorResponse
(
e
);
}
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
@ExceptionHandler
(
MethodArgumentNotValidException
.
class
)
public
Map
<
String
,
String
>
handleValidationExceptions
(
public
ResponseEntity
<
Map
<
String
,
String
>
>
handleValidationExceptions
(
MethodArgumentNotValidException
ex
)
{
Map
<
String
,
String
>
errors
=
new
HashMap
<>();
ex
.
getBindingResult
().
getAllErrors
().
forEach
((
error
)
->
{
...
...
@@ -48,7 +47,7 @@ public class AppExceptionHandler {
String
errorMessage
=
error
.
getDefaultMessage
();
errors
.
put
(
fieldName
,
errorMessage
);
});
return
errors
;
return
new
ResponseEntity
<>(
errors
,
HttpStatus
.
BAD_REQUEST
)
;
}
private
ResponseEntity
<
Object
>
getErrorResponse
(
AppException
e
)
{
...
...
backup-core/src/main/java/org/opengroup/osdu/backup/model/BackupRole.java
View file @
c9b053c4
...
...
@@ -18,7 +18,7 @@ package org.opengroup.osdu.backup.model;
public
class
BackupRole
{
public
static
final
String
BACKUP
=
"service.backup"
;
public
static
final
String
ADMIN
=
"service.backup
.admin
"
;
private
BackupRole
()
{
}
...
...
provider/backup-gcp/src/main/resources/application.properties
View file @
c9b053c4
...
...
@@ -19,6 +19,7 @@ gcp.project-id=osdu-cicd-epam
LOG_PREFIX
=
${log.prefix}
spring.cloud.gcp.datastore.namespace
=
opendes
spring.cloud.gcp.sql.databaseName
=
postgres
spring.cloud.gcp.sql.instanceConnectionName
=
osdu-cicd-epam:us-central1:test-postgre
...
...
testing/backup-test-core/pom.xml
View file @
c9b053c4
...
...
@@ -35,12 +35,6 @@
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.junit.jupiter
</groupId>
<artifactId>
junit-jupiter
</artifactId>
<version>
5.5.2
</version>
</dependency>
</dependencies>
</project>
testing/backup-test-core/src/main/java/org/opengroup/osdu/backup/Config.java
View file @
c9b053c4
...
...
@@ -2,14 +2,14 @@ package org.opengroup.osdu.backup;
public
class
Config
{
public
static
final
String
BACKUP_SERVICE_
HOST
=
""
;
public
static
final
String
BACKUP_SERVICE_
BASE_URL
=
""
;
public
static
final
String
INTEGRATION_TESTER
=
""
;
private
static
final
String
NO_DATA_ACCESS_TESTER
=
""
;
public
static
final
String
DATA_PARTITION_ID
=
""
;
public
static
String
getBackupService
Host
()
{
return
getEnvironmentVariableOrDefaultValue
(
"BACKUP_SERVICE_
HOST
"
,
BACKUP_SERVICE_
HOST
);
public
static
String
getBackupService
BaseUrl
()
{
return
getEnvironmentVariableOrDefaultValue
(
"BACKUP_SERVICE_
BASE_URL
"
,
BACKUP_SERVICE_
BASE_URL
);
}
public
static
String
getIntegrationTester
()
{
...
...
testing/backup-test-core/src/main/java/org/opengroup/osdu/backup/HttpClient.java
View file @
c9b053c4
...
...
@@ -19,6 +19,7 @@ import com.sun.jersey.api.client.Client;
import
com.sun.jersey.api.client.ClientResponse
;
import
com.sun.jersey.api.client.WebResource
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.net.URL
;
import
java.security.SecureRandom
;
import
java.security.cert.X509Certificate
;
...
...
@@ -39,13 +40,24 @@ public abstract class HttpClient {
public
abstract
String
getNoDataAccessToken
()
throws
IOException
;
public
ClientResponse
send
(
String
path
,
String
httpMethod
,
Map
<
String
,
String
>
headers
)
throws
Exception
{
return
send
(
path
,
httpMethod
,
headers
,
""
);
}
public
ClientResponse
send
(
String
httpMethod
,
Map
<
String
,
String
>
headers
,
String
requestBody
)
throws
Exception
{
return
send
(
""
,
httpMethod
,
headers
,
requestBody
);
}
public
ClientResponse
send
(
String
path
,
String
httpMethod
,
Map
<
String
,
String
>
headers
,
String
requestBody
)
throws
Exception
{
Client
client
=
this
.
getClient
();
String
mergedURL
=
new
URL
(
Config
.
getBackupService
Host
()
+
path
).
toString
();
String
mergedURL
=
URI
.
create
(
Config
.
getBackupService
BaseUrl
()
+
path
).
normalize
().
toString
();
System
.
out
.
println
(
String
.
format
(
"calling %s API:%s"
,
httpMethod
,
mergedURL
));
System
.
out
.
println
(
String
.
format
(
"request body:%s"
,
requestBody
));
...
...
testing/backup-test-core/src/main/java/org/opengroup/osdu/backup/TestBase.java
View file @
c9b053c4
...
...
@@ -12,7 +12,7 @@ public class TestBase {
protected
static
AssetUtil
assetUtil
;
public
static
Map
<
String
,
String
>
get
Comm
onHeader
()
throws
IOException
{
public
static
Map
<
String
,
String
>
get
ValidAuthorizati
onHeader
s
()
throws
IOException
{
return
getHeaders
(
Config
.
getDataPartitionId
(),
client
.
getAccessToken
());
}
...
...
testing/backup-test-core/src/main/java/org/opengroup/osdu/backup/apitest/Backup.java
deleted
100644 → 0
View file @
61b3f418
package
org.opengroup.osdu.backup.apitest
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.sun.jersey.api.client.ClientResponse
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.UUID
;
import
javax.ws.rs.HttpMethod
;
import
org.apache.http.HttpStatus
;
import
org.junit.jupiter.api.Test
;
import
org.opengroup.osdu.backup.Config
;
import
org.opengroup.osdu.backup.TestBase
;
import
org.opengroup.osdu.backup.locator.Asset
;
import
org.opengroup.osdu.backup.model.BackupImportRequest
;
import
org.opengroup.osdu.backup.model.BackupSchedule
;
public
class
Backup
extends
TestBase
{
static
final
String
SCHEDULE
=
"/schedule"
;
static
final
String
SCHEDULE_LIST
=
"/list_schedules"
;
static
final
String
BACKUP_IMPORT
=
"/backup_import"
;
static
final
String
BACKUP_LIST
=
"/list_backups"
;
static
final
String
GET_ID
=
"?id="
;
protected
static
ObjectMapper
mapper
=
new
ObjectMapper
();
protected
static
List
<
String
>
scheduleIds
=
new
ArrayList
<>();
@Test
public
void
shouldCreateBackupSchedule
()
throws
Exception
{
BackupSchedule
schedule
=
submitBackupSchedule
();
cancelSchedule
(
schedule
);
}
@Test
public
void
shouldUpdateSchedule
()
throws
Exception
{
BackupSchedule
schedule
=
submitBackupSchedule
();
schedule
.
setActive
(
false
);
schedule
.
setBackupPeriod
(
10
);
schedule
.
setLifetime
(
10
);
String
updateScheduleRequest
=
mapper
.
writerFor
(
BackupSchedule
.
class
).
writeValueAsString
(
schedule
);
ClientResponse
updateScheduleResponse
=
client
.
send
(
SCHEDULE
,
HttpMethod
.
PUT
,
getCommonHeader
(),
updateScheduleRequest
);
assertEquals
(
HttpStatus
.
SC_ACCEPTED
,
updateScheduleResponse
.
getStatus
());
BackupSchedule
updatedSchedule
=
mapper
.
readValue
(
updateScheduleResponse
.
getEntity
(
String
.
class
),
BackupSchedule
.
class
);
assertFalse
(
updatedSchedule
.
isActive
());
assertTrue
(
schedule
.
getBackupPeriod
()
==
updatedSchedule
.
getBackupPeriod
()
&&
schedule
.
getLifetime
()
==
updatedSchedule
.
getLifetime
());
}
@Test
public
void
shouldReturnCreatedScheduleById
()
throws
Exception
{
BackupSchedule
createdBackupSchedule
=
submitBackupSchedule
();
ClientResponse
scheduleByIdResponse
=
client
.
send
(
SCHEDULE
+
GET_ID
+
createdBackupSchedule
.
getScheduleId
(),
HttpMethod
.
GET
,
getCommonHeader
(),
""
);
BackupSchedule
scheduleById
=
mapper
.
readValue
(
scheduleByIdResponse
.
getEntity
(
String
.
class
),
BackupSchedule
.
class
);
assertEquals
(
HttpStatus
.
SC_OK
,
scheduleByIdResponse
.
getStatus
());
assertEquals
(
createdBackupSchedule
,
scheduleById
);
cancelSchedule
(
scheduleById
);
}
@Test
public
void
getSchedulesShouldReturnSchedulesWithCreatedSchedule
()
throws
Exception
{
BackupSchedule
createdBackupSchedule
=
submitBackupSchedule
();
ClientResponse
listSchedulesResponse
=
client
.
send
(
SCHEDULE_LIST
,
HttpMethod
.
GET
,
getCommonHeader
(),
""
);
List
<
BackupSchedule
>
scheduleList
=
Arrays
.
asList
(
mapper
.
readValue
(
listSchedulesResponse
.
getEntity
(
String
.
class
),
BackupSchedule
[].
class
));
assertEquals
(
HttpStatus
.
SC_OK
,
listSchedulesResponse
.
getStatus
());
assertTrue
(
scheduleList
.
contains
(
createdBackupSchedule
));
cancelSchedule
(
createdBackupSchedule
);
}
@Test
public
void
shouldReturnConflictWhenCreateScheduleWithExistingAssetContext
()
throws
Exception
{
BackupSchedule
createdBackupSchedule
=
submitBackupSchedule
();
ClientResponse
conflictResponse
=
client
.
send
(
SCHEDULE
,
HttpMethod
.
POST
,
getCommonHeader
(),
mapper
.
writerFor
(
BackupSchedule
.
class
).
writeValueAsString
(
createdBackupSchedule
));
assertEquals
(
HttpStatus
.
SC_CONFLICT
,
conflictResponse
.
getStatus
());
cancelSchedule
(
createdBackupSchedule
);
}
@Test
public
void
shouldReturnNotFoundForNotExistingSchedule
()
throws
Exception
{
String
randomString
=
UUID
.
randomUUID
().
toString
();
ClientResponse
scheduleByIdResponse
=
client
.
send
(
SCHEDULE
+
GET_ID
+
randomString
,
HttpMethod
.
GET
,
getCommonHeader
(),
""
);
assertEquals
(
HttpStatus
.
SC_NOT_FOUND
,
scheduleByIdResponse
.
getStatus
());
}
@Test
public
void
shouldReturnNotFoundWhenImportNotExistingBackup
()
throws
Exception
{
BackupImportRequest
backupImportRequest
=
BackupImportRequest
.
builder
()
.
backupStampId
(
UUID
.
randomUUID
().
toString
())
.
asset
(
Asset
.
DATASTORE
).
build
();
String
request
=
mapper
.
writerFor
(
BackupImportRequest
.
class
).
writeValueAsString
(
backupImportRequest
);
ClientResponse
send
=
client
.
send
(
BACKUP_IMPORT
,
HttpMethod
.
POST
,
getCommonHeader
(),
request
);
assertEquals
(
HttpStatus
.
SC_NOT_FOUND
,
send
.
getStatus
());
}
@Test
public
void
shouldReturnOkWhenListAvailableBackups
()
throws
Exception
{
ClientResponse
send
=
client
.
send
(
BACKUP_LIST
,
HttpMethod
.
GET
,
getCommonHeader
(),
""
);
assertEquals
(
HttpStatus
.
SC_OK
,
send
.
getStatus
());
}
@Test
public
void
shouldReturnNotAuthorizedWhenGivenAnonymous
()
throws
Exception
{
ClientResponse
send
=
client
.
send
(
BACKUP_LIST
,
HttpMethod
.
GET
,
getHeaders
(
Config
.
getDataPartitionId
(),
""
),
""
);
assertEquals
(
HttpStatus
.
SC_UNAUTHORIZED
,
send
.
getStatus
());
}
@Test
public
void
shouldReturnNotAuthorizedWhenGivenNoAccess
()
throws
Exception
{
ClientResponse
send
=
client
.
send
(
BACKUP_LIST
,
HttpMethod
.
GET
,
getHeaders
(
Config
.
getDataPartitionId
(),
client
.
getNoDataAccessToken
()),
""
);
assertEquals
(
HttpStatus
.
SC_UNAUTHORIZED
,
send
.
getStatus
());
}
private
BackupSchedule
submitBackupSchedule
()
throws
Exception
{
ClientResponse
createBackupScheduleResponse
=
client
.
send
(
SCHEDULE
,
HttpMethod
.
POST
,
getCommonHeader
(),
assetUtil
.
getBackupScheduleRequest
());
BackupSchedule
createdBackupSchedule
=
mapper
.
readValue
(
createBackupScheduleResponse
.
getEntity
(
String
.
class
),
BackupSchedule
.
class
);
assertEquals
(
HttpStatus
.
SC_CREATED
,
createBackupScheduleResponse
.
getStatus
());
assertFalse
(
Objects
.
isNull
(
createdBackupSchedule
.
getScheduleId
())
||
createdBackupSchedule
.
getScheduleId
().
isEmpty
());
scheduleIds
.
add
(
createdBackupSchedule
.
getScheduleId
());
return
createdBackupSchedule
;
}
private
void
cancelSchedule
(
BackupSchedule
schedule
)
throws
Exception
{
schedule
.
setActive
(
false
);
String
canceledSchedule
=
mapper
.
writerFor
(
BackupSchedule
.
class
).
writeValueAsString
(
schedule
);
ClientResponse
send
=
client
.
send
(
SCHEDULE
,
HttpMethod
.
PUT
,
getCommonHeader
(),
canceledSchedule
);
BackupSchedule
schedule1
=
mapper
.
readValue
(
send
.
getEntity
(
String
.
class
),
BackupSchedule
.
class
);
assertEquals
(
HttpStatus
.
SC_ACCEPTED
,
send
.
getStatus
());
assertFalse
(
schedule1
.
isActive
());
}
}
testing/backup-test-core/src/main/java/org/opengroup/osdu/backup/apitest/BackupCollectionTest.java
0 → 100644
View file @
c9b053c4
package
org.opengroup.osdu.backup.apitest
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.sun.jersey.api.client.ClientResponse
;
import
java.util.Arrays
;
import
java.util.List
;
import
javax.ws.rs.HttpMethod
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.HttpStatus
;
import
org.junit.Test
;
import
org.opengroup.osdu.backup.Config
;
import
org.opengroup.osdu.backup.TestBase
;
import
org.opengroup.osdu.backup.model.BackupCollection
;
public
class
BackupCollectionTest
extends
TestBase
{
private
final
String
API
=
"/api/backup/v1/collection"
;
protected
static
ObjectMapper
mapper
=
new
ObjectMapper
();
@Test
public
void
testShouldCreateBackupCollection
()
throws
Exception
{
BackupCollection
collection
=
assetUtil
.
getValidCreateBackupCollection
();
BackupCollection
submittedCollection
=
submitBackupCollection
(
collection
);
deleteCollection
(
submittedCollection
);
}
@Test
public
void
testShouldGetByNameCreatedCollection
()
throws
Exception
{
BackupCollection
collection
=
assetUtil
.
getValidCreateBackupCollection
();
BackupCollection
submittedCollection
=
submitBackupCollection
(
collection
);
ClientResponse
getCollectionResponse
=
client
.
send
(
API
+
"/"
+
submittedCollection
.
getCollectionName
(),
HttpMethod
.
GET
,
getValidAuthorizationHeaders
()
);
assertEquals
(
HttpStatus
.
SC_OK
,
getCollectionResponse
.
getStatus
());
BackupCollection
getCollection
=
mapper
.
readValue
(
getCollectionResponse
.
getEntity
(
String
.
class
),
BackupCollection
.
class
);
assertEquals
(
submittedCollection
,
getCollection
);
deleteCollection
(
submittedCollection
);
}
@Test
public
void
testShouldUpdateCreatedCollection
()
throws
Exception
{
BackupCollection
collection
=
assetUtil
.
getValidCreateBackupCollection
();
BackupCollection
submittedCollection
=
submitBackupCollection
(
collection
);
BackupCollection
collectionToUpdate
=
assetUtil
.
getValidUpdateBackupCollection
(
submittedCollection
);
ClientResponse
updateResponce
=
client
.
send
(
API
+
"/"
+
collection
.
getCollectionName
(),
HttpMethod
.
PUT
,
getValidAuthorizationHeaders
(),
mapper
.
writeValueAsString
(
collectionToUpdate
)
);
assertEquals
(
HttpStatus
.
SC_ACCEPTED
,
updateResponce
.
getStatus
());
BackupCollection
updatedCollection
=
mapper
.
readValue
(
updateResponce
.
getEntity
(
String
.
class
),
BackupCollection
.
class
);
assertEquals
(
collectionToUpdate
.
getCollectionName
(),
updatedCollection
.
getCollectionName
());
assertEquals
(
collectionToUpdate
.
getInterval
(),
updatedCollection
.
getInterval
());
assertEquals
(
collectionToUpdate
.
getLifetime
(),
updatedCollection
.
getLifetime
());
assertEquals
(
collectionToUpdate
.
isActive
(),
updatedCollection
.
isActive
());
deleteCollection
(
updatedCollection
);
}
@Test
public
void
testShouldRespondBadRequestWhenSubmittingMalformedCollection
()
throws
Exception
{
BackupCollection
malformedCollection
=
assetUtil
.
getMalformedBackupCollection
();
ClientResponse
malformedCollectionResponse
=
client
.
send
(
API
,
HttpMethod
.
POST
,
getValidAuthorizationHeaders
(),
mapper
.
writeValueAsString
(
malformedCollection
)
);
assertEquals
(
HttpStatus
.
SC_BAD_REQUEST
,
malformedCollectionResponse
.
getStatus
());
}
@Test
public
void
testShouldRespondBadRequestWhenSubmittingMalformedUpdateCollection
()
throws
Exception
{
BackupCollection
collection
=
assetUtil
.
getValidCreateBackupCollection
();
BackupCollection
submittedCollection
=
submitBackupCollection
(
collection
);
BackupCollection
collectionToUpdate
=
assetUtil
.
getNotValidUpdateBackupCollection
(
submittedCollection
);
ClientResponse
updateResponse
=
client
.
send
(
API
+
"/"
+
collection
.
getCollectionName
(),
HttpMethod
.
PUT
,
getValidAuthorizationHeaders
(),
mapper
.
writeValueAsString
(
collectionToUpdate
)
);
assertEquals
(
HttpStatus
.
SC_BAD_REQUEST
,
updateResponse
.
getStatus
());
deleteCollection
(
submittedCollection
);
}
@Test
public
void
testShouldReturnListCollectionsWithSubmittedCollection
()
throws
Exception
{
BackupCollection
collection
=
assetUtil
.
getValidCreateBackupCollection
();
BackupCollection
submittedCollection
=
submitBackupCollection
(
collection
);
ClientResponse
listResponse
=
client
.
send
(
API
+
"/list"
,
HttpMethod
.
GET
,
getValidAuthorizationHeaders
()
);
assertEquals
(
HttpStatus
.
SC_OK
,
listResponse
.
getStatus
());
List
<
BackupCollection
>
collectionList
=
Arrays
.
asList
(
mapper
.
readValue
(
listResponse
.
getEntity
(
String
.
class
),
BackupCollection
[].
class
));
assertTrue
(
collectionList
.
contains
(
submittedCollection
));
deleteCollection
(
submittedCollection
);
}
@Test
public
void
testShouldReturnNotAuthorizedWhenNoTokenProvided
()
throws
Exception
{
ClientResponse
listResponse
=
client
.
send
(
API
+
"/list"
,
HttpMethod
.
GET
,
getHeaders
(
Config
.
getDataPartitionId
(),
""
)
);
assertEquals
(
HttpStatus
.
SC_UNAUTHORIZED
,
listResponse
.
getStatus
());
}
@Test
public
void
testShouldReturnNotAuthorizedWhenNoPartitionProvided
()
throws
Exception
{
ClientResponse
listResponse
=
client
.
send
(
API
+
"/list"
,
HttpMethod
.
GET
,
getHeaders
(
""
,
client
.
getAccessToken
())
);
assertEquals
(
HttpStatus
.
SC_UNAUTHORIZED
,
listResponse
.
getStatus
());
}
protected
BackupCollection
submitBackupCollection
(
BackupCollection
collection
)
throws
Exception
{
ClientResponse
createBackupCollectionResponse
=
client
.
send
(
API
,
HttpMethod
.
POST
,
getValidAuthorizationHeaders
(),
mapper
.
writeValueAsString
(
collection
)
);
BackupCollection
createdCollection
=
mapper
.
readValue
(
createBackupCollectionResponse
.
getEntity
(
String
.
class
),
BackupCollection
.
class
);
assertEquals
(
HttpStatus
.
SC_CREATED
,
createBackupCollectionResponse
.
getStatus
());
assertTrue
(
StringUtils
.
isNotBlank
(
createdCollection
.
getCollectionId
()));
return
createdCollection
;
}
private
void
deleteCollection
(
BackupCollection
collection
)
throws
Exception
{
ClientResponse
response
=
client
.
send
(
API
+
"/"
+
collection
.
getCollectionName
(),
HttpMethod
.
DELETE
,
getValidAuthorizationHeaders
()
);
assertEquals
(
HttpStatus
.
SC_NO_CONTENT
,
response
.
getStatus
());
}
}
testing/backup-test-core/src/main/java/org/opengroup/osdu/backup/util/AssetUtil.java
View file @
c9b053c4
package
org.opengroup.osdu.backup.util
;
import
com.fasterxml.jackson.core.JsonProcessingExcep
tion
;
import
org.opengroup.osdu.backup.model.BackupCollec
tion
;
public
abstract
class
AssetUtil
{
public
abstract
String
getBackupScheduleRequest
()
throws
JsonProcessingExcep
tion
;
public
abstract
BackupCollection
getValidCreateBackupCollec
tion
()
;
public
abstract
BackupCollection
getValidUpdateBackupCollection
(
BackupCollection
collection
);
public
abstract
BackupCollection
getNotValidUpdateBackupCollection
(
BackupCollection
collection
);
public
abstract
BackupCollection
getMalformedBackupCollection
();
}
testing/backup-test-gcp/pom.xml
View file @
c9b053c4
...
...
@@ -28,16 +28,6 @@
<artifactId>
backup-test-core
</artifactId>
<version>
0.0.1
</version>
</dependency>
<dependency>
<groupId>
com.google.cloud
</groupId>
<artifactId>
google-cloud-datastore
</artifactId>
<version>
1.105.0
</version>
</dependency>
<dependency>
<groupId>
com.google.cloud
</groupId>
<artifactId>
google-cloud-storage
</artifactId>
<version>
1.108.0
</version>
</dependency>
<dependency>
<groupId>
com.google.auth
</groupId>
<artifactId>
google-auth-library-oauth2-http
</artifactId>
...
...
testing/backup-test-gcp/src/main/test/org/opengroup/osdu/backup/TestBackup.java
deleted
100644 → 0
View file @
61b3f418
package
org.opengroup.osdu.backup
;
import
org.junit.jupiter.api.AfterAll
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.opengroup.osdu.backup.apitest.Backup
;
import
org.opengroup.osdu.backup.util.AssetUtilGCP
;
import
org.opengroup.osdu.backup.util.DatastoreUtil
;
public
class
TestBackup
extends
Backup
{
private
static
DatastoreUtil
datastoreUtil
;
@BeforeAll
static
void
setUp
()
{
client
=
new
HttpClientGCP
();
assetUtil
=
new
AssetUtilGCP
();
datastoreUtil
=
new
DatastoreUtil
();
}
@AfterAll
static
void
tearDown
()
throws
Exception
{
DatastoreUtil
datastoreUtil1
=
datastoreUtil
;
for
(
String
scheduleId
:
scheduleIds
)
{
datastoreUtil1
.
deleteSchedule
(
scheduleId
);
}
}
}
testing/backup-test-gcp/src/main/test/org/opengroup/osdu/backup/util/AssetUtilGCP.java
deleted
100644 → 0
View file @
61b3f418
package
org.opengroup.osdu.backup.util
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.common.collect.ImmutableMap
;
import
java.util.UUID
;
import
org.opengroup.osdu.backup.Config
;
import
org.opengroup.osdu.backup.locator.Asset
;
import
org.opengroup.osdu.backup.model.BackupSchedule
;