Skip to content

Commit

Permalink
Write tests for cassandra/shard.go (#5839)
Browse files Browse the repository at this point in the history
  • Loading branch information
taylanisikdemir authored Apr 2, 2024
1 parent 9e8cb8b commit bbb7772
Show file tree
Hide file tree
Showing 4 changed files with 589 additions and 3 deletions.
4 changes: 2 additions & 2 deletions common/persistence/nosql/nosqlplugin/cassandra/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
// InsertShard creates a new shard, return error is there is any.
// Return ShardOperationConditionFailure if the condition doesn't meet
func (db *cdb) InsertShard(ctx context.Context, row *nosqlplugin.ShardRow) error {
cqlNowTimestamp := persistence.UnixNanoToDBTimestamp(time.Now().UnixNano())
cqlNowTimestamp := persistence.UnixNanoToDBTimestamp(db.timeSrc.Now().UnixNano())
markerData, markerEncoding := persistence.FromDataBlob(row.PendingFailoverMarkers)
transferPQS, transferPQSEncoding := persistence.FromDataBlob(row.TransferProcessingQueueStates)
crossClusterPQS, crossClusterPQSEncoding := persistence.FromDataBlob(row.CrossClusterProcessingQueueStates)
Expand Down Expand Up @@ -247,7 +247,7 @@ func (db *cdb) UpdateRangeID(ctx context.Context, shardID int, rangeID int64, pr
// UpdateShard updates a shard, return error is there is any.
// Return ShardOperationConditionFailure if the condition doesn't meet
func (db *cdb) UpdateShard(ctx context.Context, row *nosqlplugin.ShardRow, previousRangeID int64) error {
cqlNowTimestamp := persistence.UnixNanoToDBTimestamp(time.Now().UnixNano())
cqlNowTimestamp := persistence.UnixNanoToDBTimestamp(db.timeSrc.Now().UnixNano())
markerData, markerEncoding := persistence.FromDataBlob(row.PendingFailoverMarkers)
transferPQS, transferPQSEncoding := persistence.FromDataBlob(row.TransferProcessingQueueStates)
crossClusterPQS, crossClusterPQSEncoding := persistence.FromDataBlob(row.CrossClusterProcessingQueueStates)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const (
`}`

templateCreateShardQuery = `INSERT INTO executions (` +
`shard_id, type, domain_id, workflow_id, run_id, visibility_ts, task_id, shard, range_id)` +
`shard_id, type, domain_id, workflow_id, run_id, visibility_ts, task_id, shard, range_id) ` +
`VALUES(?, ?, ?, ?, ?, ?, ?, ` + templateShardType + `, ?) IF NOT EXISTS`

templateGetShardQuery = `SELECT shard, range_id ` +
Expand Down
Loading

0 comments on commit bbb7772

Please sign in to comment.