[raft/memstore] Add scd memstore - #1542
Conversation
04a7568 to
ee03a27
Compare
7ea03cd to
e55c786
Compare
9a30121 to
00ce64a
Compare
b703298 to
8ad6994
Compare
| return true | ||
| } | ||
|
|
||
| func clonePtr[T any](v *T) *T { |
There was a problem hiding this comment.
question: we should probably move common function to a utils package right? Or should every memstore kept it owns helpers ?
There was a problem hiding this comment.
Agreed, it could simply be in pkg/memstore
|
@mickmis That one should be ready for a review |
mickmis
left a comment
There was a problem hiding this comment.
LGTM modulo minor comments
| require.NoError(t, err) | ||
| require.Equal(t, manager, got.Uss) | ||
| require.Equal(t, scdmodels.UssAvailabilityStateNormal, got.Availability) | ||
| require.NotEmpty(t, got.Version) |
There was a problem hiding this comment.
Check actual value? Hardcoding expectation here is fine IMO
There was a problem hiding this comment.
I changed, but it's a bit weak (changing computation mean changing it, witch is not great)
There was a problem hiding this comment.
I think it's a good thing actually? IMO it is very acceptable, desirable even, to have to change the value here if we change how we compute the OVN, because it is part of the behavior of the function we are unit testing.
There was a problem hiding this comment.
Depend on what you want to test. I'm more to test "something is returned" and "it's the same thing that is returned later", not "the value is generated the way I expected because I froze time/random", that not really IMO the goal of the test. The requirement is to return a value with some characteristics, not a value we choose and enforce because of it's characteristics.
Should the version be slightly different and the function implementing change, changing all tests to conform to the new value (and probably by taking the test message to get the new one) don't add much.
(But IMO/nits ^^')
| return true | ||
| } | ||
|
|
||
| func clonePtr[T any](v *T) *T { |
There was a problem hiding this comment.
Agreed, it could simply be in pkg/memstore
| func (r *repo) UpsertConstraint(_ context.Context, constraint *scdmodels.Constraint) (*scdmodels.Constraint, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "UpsertConstraint not implemented for memstore") | ||
| func (r *repo) UpsertConstraint(ctx context.Context, s *scdmodels.Constraint) (*scdmodels.Constraint, error) { | ||
| if _, err := dsssql.CellUnionToCellIdsWithValidation(s.Cells); err != nil { |
There was a problem hiding this comment.
Just validate with geo.ValidateCell then?
There was a problem hiding this comment.
It's a small helper on the loop + convert, is it worth it to change it back?
There was a problem hiding this comment.
nit: I'd factor away the loop in utils.go and use it here. But is it worth it? Meh up to you.
5a425af to
e607151
Compare
| require.NoError(t, err) | ||
| require.Equal(t, manager, got.Uss) | ||
| require.Equal(t, scdmodels.UssAvailabilityStateNormal, got.Availability) | ||
| require.NotEmpty(t, got.Version) |
There was a problem hiding this comment.
I think it's a good thing actually? IMO it is very acceptable, desirable even, to have to change the value here if we change how we compute the OVN, because it is part of the behavior of the function we are unit testing.
| func (r *repo) UpsertConstraint(_ context.Context, constraint *scdmodels.Constraint) (*scdmodels.Constraint, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "UpsertConstraint not implemented for memstore") | ||
| func (r *repo) UpsertConstraint(ctx context.Context, s *scdmodels.Constraint) (*scdmodels.Constraint, error) { | ||
| if _, err := dsssql.CellUnionToCellIdsWithValidation(s.Cells); err != nil { |
There was a problem hiding this comment.
nit: I'd factor away the loop in utils.go and use it here. But is it worth it? Meh up to you.
This PR is part of a new chain, implementing memstore.
#1525 (Generic raftstore) -> #1527 (Base memstore) -> #1529 (Aux memstore) -> #1530 (Snapshots) -> #1534 (Rid memstore) -> #1535 (Correct use of now) -> #1539 (Checkpoint) -> #1542 (Scd memstore) -> #1528 (First PR with raft using memstore)
It adds SCD memstore.
The PR is quite big, as it's the whole SCD memstore. However, individual files can be checked separately.
There were no existing tests compared to RID, except for expired operational intents / subscriptions. Those two have been copied, and the rest is new.