-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actor Reminders: Default JSON serialization. (dapr#7548)
* Actor Reminders: Default JSON serialization. To support downgrades to 1.12 from 1.13, this PR changes the reminder serialization storage format back to JSON by default. This means a 1.12 actor reminder client can read reminders written by 1.13 actors. 1.13 will continue to understand both JSON and protobuf. Protobuf serialization can be enabled with the `ActorReminderStorageProtobuf` feature gate. The actor "API Level" has been changed back to 10. Adds test to ensure the default serialization is JSON. Signed-off-by: joshvanl <me@joshvanl.dev> * Remove ActorReminderStorageProtobuf feature gate in favour of using API level Signed-off-by: joshvanl <me@joshvanl.dev> * Fix api level tests Signed-off-by: joshvanl <me@joshvanl.dev> --------- Signed-off-by: joshvanl <me@joshvanl.dev> Co-authored-by: Yaron Schneider <schneider.yaron@live.com>
- Loading branch information
Showing
13 changed files
with
115 additions
and
23 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
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
92 changes: 92 additions & 0 deletions
92
tests/integration/suite/actors/reminders/serialization/default.go
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,92 @@ | ||
/* | ||
Copyright 2023 The Dapr Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package serialization | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"runtime" | ||
"strconv" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/dapr/dapr/tests/integration/framework" | ||
"github.com/dapr/dapr/tests/integration/framework/process/daprd" | ||
prochttp "github.com/dapr/dapr/tests/integration/framework/process/http" | ||
"github.com/dapr/dapr/tests/integration/framework/process/placement" | ||
"github.com/dapr/dapr/tests/integration/framework/process/sqlite" | ||
"github.com/dapr/dapr/tests/integration/framework/util" | ||
"github.com/dapr/dapr/tests/integration/suite" | ||
) | ||
|
||
func init() { | ||
suite.Register(new(defaultS)) | ||
} | ||
|
||
// defaultS ensures that reminders are stored as JSON by default. | ||
type defaultS struct { | ||
daprd *daprd.Daprd | ||
srv *prochttp.HTTP | ||
handler *httpServer | ||
place *placement.Placement | ||
db *sqlite.SQLite | ||
} | ||
|
||
func (d *defaultS) Setup(t *testing.T) []framework.Option { | ||
if runtime.GOOS == "windows" { | ||
t.Skip("Skipping test on Windows due to SQLite limitations") | ||
} | ||
|
||
d.place = placement.New(t) | ||
|
||
d.db = sqlite.New(t, sqlite.WithActorStateStore(true)) | ||
|
||
d.handler = new(httpServer) | ||
d.srv = prochttp.New(t, prochttp.WithHandler(d.handler.NewHandler())) | ||
d.daprd = daprd.New(t, | ||
daprd.WithResourceFiles(d.db.GetComponent(t)), | ||
daprd.WithPlacementAddresses("127.0.0.1:"+strconv.Itoa(d.place.Port())), | ||
daprd.WithAppPort(d.srv.Port()), | ||
) | ||
|
||
return []framework.Option{ | ||
framework.WithProcesses(d.db, d.place, d.srv, d.daprd), | ||
} | ||
} | ||
|
||
func (d *defaultS) Run(t *testing.T, ctx context.Context) { | ||
d.place.WaitUntilRunning(t, ctx) | ||
d.daprd.WaitUntilRunning(t, ctx) | ||
require.NoError(t, d.handler.WaitForActorsReady(ctx)) | ||
|
||
client := util.HTTPClient(t) | ||
baseURL := fmt.Sprintf("http://localhost:%d/v1.0/actors/myactortype/myactorid", d.daprd.HTTPPort()) | ||
|
||
invokeActor(t, ctx, baseURL, client) | ||
|
||
storeReminder(t, ctx, baseURL, client) | ||
|
||
// Check the data in the SQLite database | ||
// The value must begin with `[{`, which indicates it was serialized as JSON | ||
storedVal := loadRemindersFromDB(t, ctx, d.db.GetConnection(t)) | ||
assert.Truef(t, strings.HasPrefix(storedVal, "[{"), "Prefix not found in value: '%v'", storedVal) | ||
|
||
assert.Eventually(t, func() bool { | ||
return d.handler.remindersInvokeCount.Load() > 0 | ||
}, 5*time.Second, 10*time.Millisecond, "Reminder was not invoked at least once") | ||
} |
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