Skip to content

Commit

Permalink
Address partial comments
Browse files Browse the repository at this point in the history
Signed-off-by: bowenlan-amzn <[email protected]>
  • Loading branch information
bowenlan-amzn committed Jun 16, 2022
1 parent 312c8e8 commit 4ef0f2b
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ fun validateSMPolicyName(policyName: String) {
val errorMessages: MutableList<String> = mutableListOf()
if (policyName.isEmpty()) {
errorMessages.add("Policy name cannot be empty.")
throw IllegalArgumentException()
}
if (policyName.contains(" ")) {
errorMessages.add("Policy name must not contain whitespace.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.opensearch.snapshots.SnapshotState
import java.time.Instant

object CreationFinishedState : State {

override val continuous = true

override suspend fun execute(context: SMStateMachine): SMResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.opensearch.indexmanagement.snapshotmanagement.model.SMMetadata

object CreationStartState : State {

override val continuous: Boolean = false
override val continuous: Boolean = true

override suspend fun execute(context: SMStateMachine): SMResult {
val metadataToSave = SMMetadata.Builder(context.metadata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.time.Instant.now

object DeletingState : State {

override val continuous: Boolean = true
override val continuous: Boolean = false

override suspend fun execute(context: SMStateMachine): SMResult {
val client = context.client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.opensearch.indexmanagement.snapshotmanagement.tryUpdatingNextExecutio
import java.time.Instant

object DeletionFinishedState : State {

override val continuous = true

override suspend fun execute(context: SMStateMachine): SMResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.opensearch.indexmanagement.snapshotmanagement.model.SMMetadata

object DeletionStartState : State {

override val continuous: Boolean = false
override val continuous: Boolean = true

override suspend fun execute(context: SMStateMachine): SMResult {
val metadataToSave = SMMetadata.Builder(context.metadata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.opensearch.indexmanagement.ClientMockTestCase
import org.opensearch.indexmanagement.snapshotmanagement.engine.states.SMState
import org.opensearch.indexmanagement.snapshotmanagement.engine.states.creationTransitions
import org.opensearch.indexmanagement.snapshotmanagement.engine.states.deletionTransitions
import org.opensearch.indexmanagement.snapshotmanagement.mockCreateSnapshotResponse
import org.opensearch.indexmanagement.snapshotmanagement.mockGetSnapshotResponse
import org.opensearch.indexmanagement.snapshotmanagement.mockSnapshotInfo
import org.opensearch.indexmanagement.snapshotmanagement.model.SMMetadata
Expand All @@ -26,8 +27,11 @@ import java.time.Instant.now
class SMStateMachineTests : ClientMockTestCase() {

fun `test sm result Next save the current state`() = runBlocking {
val currentState = SMState.CREATION_FINISHED
val currentState = SMState.CREATION_CONDITION_MET
val nextStates = creationTransitions[currentState]
mockGetSnapshotsCall(response = mockGetSnapshotResponse(0))
mockCreateSnapshotCall(response = mockCreateSnapshotResponse())

val metadata = randomSMMetadata(
creationCurrentState = currentState
)
Expand Down

0 comments on commit 4ef0f2b

Please sign in to comment.