This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
raft_fsm: version 3 introducing async snapshot
- Loading branch information
Mathieu Borderé
committed
Jun 29, 2022
1 parent
9e12b06
commit b98e31b
Showing
10 changed files
with
370 additions
and
32 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include "../../include/raft.h" | ||
#include "../lib/runner.h" | ||
|
||
/****************************************************************************** | ||
* | ||
* raft_init | ||
* | ||
*****************************************************************************/ | ||
|
||
SUITE(raft_init) | ||
|
||
/* Incompatible raft->io and raft->fsm wrt async snapshots. */ | ||
TEST(raft_init, incompatIoFsmAsyncSnapshotNotNull, NULL, NULL, 0, NULL) | ||
{ | ||
/* Set incompatible io and fsm versions and non-NULL snapshot_async fn */ | ||
struct raft r = {0}; | ||
struct raft_io io = {0}; | ||
struct raft_fsm fsm = {0}; | ||
io.version = 1; /* Too low */ | ||
io.async_work = (int (*)(struct raft_io *, struct raft_io_async_work *, | ||
raft_io_async_work_cb))(uintptr_t)0xDEADBEEF; | ||
fsm.version = 3; | ||
fsm.snapshot_async = (int (*)(struct raft_fsm *, | ||
struct raft_buffer **, unsigned int *))(uintptr_t)0xDEADBEEF; | ||
|
||
int rc; | ||
rc = raft_init(&r, &io, &fsm, 1, "1"); | ||
munit_assert_int(rc, ==, -1); | ||
munit_assert_string_equal(r.errmsg, "async snapshot requires io->version > 1 and async_work method."); | ||
return MUNIT_OK; | ||
} | ||
|
||
/* Incompatible raft->io and raft->fsm wrt async snapshots. */ | ||
TEST(raft_init, incompatIoFsmAsyncSnapshotNull, NULL, NULL, 0, NULL) | ||
{ | ||
/* Set incompatible io and fsm versions and NULL snapshot_async fn */ | ||
struct raft r = {0}; | ||
struct raft_io io = {0}; | ||
struct raft_fsm fsm = {0}; | ||
io.version = 2; | ||
io.async_work = NULL; | ||
fsm.version = 3; | ||
fsm.snapshot_async = (int (*)(struct raft_fsm *, | ||
struct raft_buffer **, unsigned int *))(uintptr_t)0xDEADBEEF; | ||
|
||
int rc; | ||
rc = raft_init(&r, &io, &fsm, 1, "1"); | ||
munit_assert_int(rc, ==, -1); | ||
munit_assert_string_equal(r.errmsg, "async snapshot requires io->version > 1 and async_work method."); | ||
return MUNIT_OK; | ||
} | ||
|
Oops, something went wrong.