Skip to content

Commit

Permalink
Pivotal ID # 188156440}: re submission when INVALID state (#871)
Browse files Browse the repository at this point in the history
https://www.pivotaltracker.com/story/show/188156440
- added invalid as a processing state
  • Loading branch information
Juan-EBI authored Aug 23, 2024
1 parent 5005ae6 commit b09f82a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ enum class RequestStatus {
;

companion object {
/**
* List of status consider as the system is processing or owns the submission.
*/
val PROCESSING: Set<RequestStatus> =
setOf(
REQUESTED,
Expand All @@ -25,6 +28,7 @@ enum class RequestStatus {
FILES_COPIED,
CHECK_RELEASED,
PERSISTED,
INVALID,
)
}
}
15 changes: 8 additions & 7 deletions submission/submission-webapp/src/itest/itestsInventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ Contains test related to submission

Contains test related to resubmission

| Class | Test No | Test name |
|---------------------|---------|----------------------------------------|
| ResubmissionApiTest | 5-1 | Resubmit study updating a file content |
| ResubmissionApiTest | 5-2 | Resubmit study with the same files |
| ResubmissionApiTest | 5-3 | Resubmit study with rootPath |
| ResubmissionApiTest | 5-4 | Resubmit study updating only metadata |
| ResubmissionApiTest | 5-5 | Resubmit study adding new files |
| Class | Test No | Test name |
|---------------------|---------|------------------------------------------------|
| ResubmissionApiTest | 5-1 | Resubmit study updating a file content |
| ResubmissionApiTest | 5-2 | Resubmit study with the same files |
| ResubmissionApiTest | 5-3 | Resubmit study with rootPath |
| ResubmissionApiTest | 5-4 | Resubmit study updating only metadata |
| ResubmissionApiTest | 5-5 | Resubmit study adding new files |
| ResubmissionApiTest | 5-6 | Resubmit study currenlty being flag as invalid |

| Class | Test No | Test name | Description |
|---------------------------------|---------|----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ac.uk.ebi.biostd.itest.test.submission.submit

import ac.uk.ebi.biostd.client.exception.WebClientException
import ac.uk.ebi.biostd.client.integration.commons.SubmissionFormat.TSV
import ac.uk.ebi.biostd.client.integration.web.BioWebClient
import ac.uk.ebi.biostd.itest.common.SecurityTestService
Expand All @@ -13,10 +14,13 @@ import ac.uk.ebi.biostd.persistence.common.service.SubmissionPersistenceQuerySer
import ac.uk.ebi.biostd.persistence.common.service.SubmissionRequestPersistenceService
import ac.uk.ebi.biostd.submission.config.FilePersistenceConfig
import ebi.ac.uk.asserts.assertThat
import ebi.ac.uk.asserts.assertThrows
import ebi.ac.uk.coroutines.waitUntil
import ebi.ac.uk.dsl.tsv.line
import ebi.ac.uk.dsl.tsv.tsv
import ebi.ac.uk.io.ext.createFile
import ebi.ac.uk.io.ext.createOrReplaceFile
import ebi.ac.uk.model.RequestStatus
import ebi.ac.uk.util.date.toStringDate
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -351,4 +355,58 @@ class ResubmissionApiTest(
assertThat(section.files[0]).hasLeftValueSatisfying { assertThat(it.fileName).isEqualTo("file_5-5-1.txt") }
assertThat(section.files[1]).hasLeftValueSatisfying { assertThat(it.fileName).isEqualTo("file_5-5-2.txt") }
}

@Test
fun `5-6 Resubmit study currenlty being flag as invalid`() =
runTest {
val version1 =
tsv {
line("Submission", "S-ACCNO56")
line("ReleaseDate", OffsetDateTime.now().toStringDate())
line()
line("Study")
line()
line("File", "file_5_6_1.txt")
line()
}.toString()

webClient.uploadFile(tempFolder.createFile("file_5_6_1.txt", "5-6-1 file content"))
assertThat(webClient.submit(version1, TSV)).isSuccessful()

val version2 =
tsv {
line("Submission", "S-ACCNO56")
line("ReleaseDate", OffsetDateTime.now().toStringDate())
line()
line("Study")
line()
line("File", "file_5_6_2.txt")
line()
}.toString()

webClient.uploadFile(tempFolder.createFile("file_5_6_2.txt", "5-6-2 file content"))

val (accNo, version) = webClient.submitAsync(version2, TSV)

waitUntil(
timeout = java.time.Duration.ofSeconds(10),
) { requestRepository.getRequestStatus(accNo, version) == RequestStatus.INVALID }

val exception =
assertThrows<WebClientException> {
webClient.submit(version2, TSV)
}
assertThat(exception).hasMessage(
"""
{
"log": {
"level": "ERROR",
"message": "Submission request can't be accepted. Version '2' of 'S-ACCNO56' is currently being processed.",
"subnodes": []
},
"status": "FAIL"
}
""".trimIndent(),
)
}
}

0 comments on commit b09f82a

Please sign in to comment.