2023-08-31 23:52:52 +03:00
|
|
|
# nim-raft
|
|
|
|
# Copyright (c) 2023 Status Research & Development GmbH
|
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
|
|
# at your option.
|
|
|
|
# This file may not be copied, modified, or distributed except according to
|
|
|
|
# those terms.
|
|
|
|
|
|
|
|
import unittest2
|
|
|
|
import basic_cluster
|
2023-09-04 12:47:27 +03:00
|
|
|
import std/times
|
2023-08-31 23:52:52 +03:00
|
|
|
|
|
|
|
proc basicClusterMain*() =
|
|
|
|
var
|
|
|
|
cluster: BasicRaftCluster
|
|
|
|
nodesIds = newSeq[RaftNodeId](5)
|
|
|
|
|
|
|
|
suite "Basic Raft Cluster Tests":
|
|
|
|
|
2023-09-01 02:14:45 +03:00
|
|
|
test "Basic Raft Cluster Init (5 nodes)":
|
2023-08-31 23:52:52 +03:00
|
|
|
for i in 0..4:
|
|
|
|
nodesIds[i] = genUUID()
|
|
|
|
|
|
|
|
cluster = BasicRaftClusterInit(nodesIds)
|
2023-09-03 20:52:35 +03:00
|
|
|
# check size(cluster.nodes) == 5
|
2023-09-01 02:14:45 +03:00
|
|
|
|
|
|
|
test "Generate Random Client SmCommands Queue":
|
|
|
|
discard
|
|
|
|
|
|
|
|
test "Start Basic Raft Cluster And wait it to converge (Elect a Leader)":
|
2023-09-01 02:56:15 +03:00
|
|
|
BasicRaftClusterStart(cluster)
|
2023-09-04 12:47:27 +03:00
|
|
|
var
|
|
|
|
dur: times.Duration
|
|
|
|
dur = initDuration(seconds = 5, milliseconds = 100)
|
|
|
|
waitFor sleepAsync(5000)
|
2023-09-01 02:14:45 +03:00
|
|
|
|
|
|
|
test "Simulate Basic Raft Cluster Client SmCommands Execution / Log Replication":
|
|
|
|
discard
|
|
|
|
|
|
|
|
test "Evaluate results":
|
|
|
|
discard
|
2023-08-31 23:52:52 +03:00
|
|
|
|
|
|
|
if isMainModule:
|
|
|
|
basicClusterMain()
|