-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32637 from vespa-engine/mpolden/snapshot-history
Record time of each snapshot event
- Loading branch information
Showing
10 changed files
with
185 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
node-repository/src/test/java/com/yahoo/vespa/hosted/provision/backup/SnapshotTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.yahoo.vespa.hosted.provision.backup; | ||
|
||
import com.yahoo.config.provision.ApplicationId; | ||
import com.yahoo.config.provision.ClusterSpec; | ||
import com.yahoo.config.provision.HostName; | ||
import com.yahoo.vespa.hosted.provision.node.ClusterId; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.Instant; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertSame; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
|
||
/** | ||
* @author mpolden | ||
*/ | ||
class SnapshotTest { | ||
|
||
@Test | ||
void state_changes() { | ||
assertAllowed(Snapshot.State.creating, Snapshot.State.created); | ||
assertAllowed(Snapshot.State.created, Snapshot.State.restoring); | ||
assertAllowed(Snapshot.State.restoring, Snapshot.State.restored); | ||
assertAllowed(Snapshot.State.restored, Snapshot.State.restoring); | ||
|
||
assertDisallowed(Snapshot.State.created, Snapshot.State.creating); | ||
assertDisallowed(Snapshot.State.creating, Snapshot.State.restoring); | ||
assertDisallowed(Snapshot.State.creating, Snapshot.State.restored); | ||
assertDisallowed(Snapshot.State.restored, Snapshot.State.created); | ||
assertDisallowed(Snapshot.State.restored, Snapshot.State.created); | ||
} | ||
|
||
private static void assertAllowed(Snapshot.State from, Snapshot.State to) { | ||
Snapshot snapshot = snapshot(from); | ||
assertSame(to, snapshot.with(to, Instant.ofEpochMilli(123)).state()); | ||
} | ||
|
||
private static void assertDisallowed(Snapshot.State from, Snapshot.State to) { | ||
Snapshot snapshot = snapshot(from); | ||
try { | ||
snapshot.with(to, Instant.ofEpochMilli(123)); | ||
fail("Changing state " + from + " -> " + to + " should fail"); | ||
} catch (IllegalArgumentException ignored) {} | ||
} | ||
|
||
private static Snapshot snapshot(Snapshot.State state) { | ||
return new Snapshot(Snapshot.generateId(), HostName.of("h1.example.com"), state, | ||
Snapshot.History.of(state, Instant.ofEpochMilli(123)), new ClusterId(ApplicationId.defaultId(), ClusterSpec.Id.from("c1")), | ||
0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
...ory/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/snapshot/single.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
{ | ||
"cluster": "id3", | ||
"clusterIndex": 0, | ||
"createdAt": 123, | ||
"hostname": "host4.yahoo.com", | ||
"id": "(ignore)", | ||
"instance": "tenant3:application3:instance3", | ||
"state": "creating" | ||
"state": "creating", | ||
"history": [ | ||
{ | ||
"at": 123, | ||
"event": "creating" | ||
} | ||
] | ||
} |