From 678bff04cc4ead82355ddaed53cc346078847f1d Mon Sep 17 00:00:00 2001 From: Yaron Schneider Date: Wed, 6 Mar 2024 03:56:56 -0800 Subject: [PATCH] Revert "Update master with `release-1.13` branch (#7595)" (#7598) This reverts commit 142106959e6724c4b99d28e9d3a1c37e8bc83cac. --- .../0003-remote-content-length-test.patch | 43 -- .github/workflows/dapr-perf-components.yml | 4 +- .github/workflows/dapr-perf.yml | 4 +- .../workflows/dapr-standalone-validation.yml | 2 +- .github/workflows/dapr-test-sdk.yml | 8 +- .github/workflows/dapr-test.yml | 4 +- .github/workflows/dapr.yml | 8 +- .github/workflows/kind-e2e.yaml | 2 +- .github/workflows/version-skew.yaml | 4 +- charts/dapr/README.md | 9 +- charts/dapr/charts/dapr_placement/values.yaml | 2 +- .../dapr_sidecar_injector_deployment.yaml | 2 - .../charts/dapr_sidecar_injector/values.yaml | 1 - cmd/injector/app/app.go | 6 +- cmd/placement/options/options.go | 2 +- docs/release_notes/v1.13.0.md | 519 ------------------ go.mod | 28 +- go.sum | 68 +-- pkg/actors/actors.go | 6 +- pkg/actors/internal_actor_test.go | 4 +- pkg/actors/placement/client.go | 3 - pkg/actors/placement/client_test.go | 12 - pkg/actors/placement/placement.go | 11 +- pkg/actors/placement/placement_test.go | 25 +- pkg/api/grpc/grpc.go | 14 +- pkg/api/http/http.go | 11 +- pkg/components/components_loader.go | 2 +- pkg/components/kubernetes_loader.go | 2 +- pkg/components/kubernetes_loader_test.go | 2 +- pkg/components/local_loader.go | 46 +- pkg/components/local_loader_test.go | 6 +- pkg/config/configuration.go | 3 +- pkg/injector/consts/consts.go | 1 - pkg/injector/patcher/sidecar.go | 23 +- pkg/injector/patcher/sidecar_container.go | 69 +-- .../patcher/sidecar_container_test.go | 48 +- pkg/injector/sentry/sentry.go | 33 +- pkg/injector/service/config.go | 7 - pkg/injector/service/pod_patch.go | 1 - pkg/messaging/v1/util.go | 4 +- pkg/placement/membership.go | 81 +-- pkg/placement/membership_test.go | 59 +- pkg/placement/placement.go | 48 +- pkg/placement/raft/fsm.go | 5 +- pkg/placement/raft/fsm_test.go | 25 +- pkg/runtime/hotreload/hotreload.go | 35 +- pkg/runtime/hotreload/loader/disk/disk.go | 84 ++- pkg/runtime/hotreload/loader/disk/resource.go | 116 ++-- .../hotreload/loader/disk/resource_test.go | 86 +-- pkg/runtime/hotreload/loader/fake/fake.go | 19 +- pkg/runtime/hotreload/loader/loader.go | 3 +- .../hotreload/loader/operator/operator.go | 5 +- .../hotreload/reconciler/reconciler.go | 27 +- .../hotreload/reconciler/reconciler_test.go | 18 +- pkg/runtime/processor/pubsub/pubsub.go | 2 +- pkg/runtime/processor/secret/secret.go | 3 + pkg/runtime/processor/state/state.go | 7 +- pkg/runtime/runtime.go | 62 ++- tests/apps/resiliencyapp/go.mod | 6 +- tests/apps/resiliencyapp/go.sum | 12 +- tests/apps/resiliencyapp_grpc/go.mod | 6 +- tests/apps/resiliencyapp_grpc/go.sum | 12 +- .../go.mod | 6 +- .../go.sum | 12 +- tests/e2e/pubsub/pubsub_test.go | 11 +- .../framework/process/daprd/daprd.go | 39 +- .../framework/process/daprd/options.go | 20 +- .../process/grpc/subscriber/options.go | 17 - .../process/grpc/subscriber/subscriber.go | 119 ---- .../framework/process/http/app/app.go | 80 --- .../framework/process/http/app/options.go | 51 -- .../process/http/subscriber/options.go | 44 -- .../process/http/subscriber/subscriber.go | 166 ------ .../framework/process/logline/logline.go | 2 +- .../framework/process/operator/operator.go | 2 +- .../framework/process/placement/options.go | 8 +- .../framework/process/placement/placement.go | 30 +- .../framework/process/sentry/sentry.go | 2 +- .../process/statestore/statestore.go | 2 +- tests/integration/suite/actors/grpc/ttl.go | 4 +- .../healthz/deactivate-on-placement-fail.go | 2 +- .../actors/healthz/endpoint/allenabled.go | 2 +- .../suite/actors/healthz/endpoint/noapp.go | 2 +- .../actors/healthz/endpoint/noappentities.go | 2 +- .../actors/healthz/endpoint/noentities.go | 2 +- .../suite/actors/healthz/endpoint/path.go | 2 +- tests/integration/suite/actors/http/ttl.go | 4 +- .../suite/actors/metadata/client.go | 2 +- .../suite/actors/metadata/disabled.go | 2 +- .../integration/suite/actors/metadata/host.go | 2 +- .../suite/actors/metadata/host_noplacement.go | 2 +- .../suite/actors/reminders/basic.go | 6 +- .../suite/actors/reminders/rebalancing.go | 4 +- .../actors/reminders/serialization/common.go | 2 +- .../actors/reminders/serialization/default.go | 92 ---- .../actors/reminders/serialization/json.go | 2 + .../reminders/serialization/protobuf.go | 4 +- .../suite/daprd/binding/binding.go | 1 - .../suite/daprd/binding/input/appready.go | 12 +- .../suite/daprd/binding/output/errors.go | 100 ---- .../hotreload/operator/binding/input/grpc.go | 12 +- .../hotreload/operator/binding/input/http.go | 10 +- .../hotreload/operator/binding/output.go | 12 +- .../suite/daprd/hotreload/operator/crypto.go | 14 +- .../daprd/hotreload/operator/informer.go | 6 +- .../middleware/http/app/routeralias.go | 2 +- .../operator/middleware/http/app/uppercase.go | 10 +- .../middleware/http/server/routeralias.go | 2 +- .../middleware/http/server/uppercase.go | 10 +- .../daprd/hotreload/operator/pubsub/grpc.go | 12 +- .../daprd/hotreload/operator/pubsub/http.go | 12 +- .../suite/daprd/hotreload/operator/secret.go | 16 +- .../suite/daprd/hotreload/operator/state.go | 16 +- .../selfhosted/binding/input/grpc.go | 10 +- .../selfhosted/binding/input/http.go | 10 +- .../hotreload/selfhosted/binding/output.go | 12 +- .../daprd/hotreload/selfhosted/crypto.go | 14 +- .../middleware/http/app/routeralias.go | 2 +- .../middleware/http/app/uppercase.go | 10 +- .../middleware/http/server/routeralias.go | 2 +- .../middleware/http/server/uppercase.go | 10 +- .../hotreload/selfhosted/namespace/set.go | 215 -------- .../hotreload/selfhosted/namespace/unset.go | 208 ------- .../daprd/hotreload/selfhosted/pubsub/grpc.go | 12 +- .../daprd/hotreload/selfhosted/pubsub/http.go | 12 +- .../daprd/hotreload/selfhosted/secret.go | 16 +- .../{selfhosted.go => selfhostest.go} | 1 - .../suite/daprd/hotreload/selfhosted/state.go | 16 +- .../suite/daprd/httpserver/httpserver.go | 4 +- .../suite/daprd/mtls/kubernetes/disable.go | 2 +- .../suite/daprd/mtls/standalone/disable.go | 2 +- .../suite/daprd/outbox/grpc/basic.go | 2 +- .../suite/daprd/outbox/http/basic.go | 2 +- .../suite/daprd/pluggable/basic.go | 2 +- .../suite/daprd/pubsub/grpc/appready.go | 14 +- .../suite/daprd/pubsub/grpc/emptymatch.go | 84 --- .../suite/daprd/pubsub/http/emptymatch.go | 82 --- .../{namespace/unset/name.go => namespace.go} | 78 +-- .../daprd/resources/namespace/namespace.go | 19 - .../daprd/resources/namespace/set/name.go | 98 ---- .../daprd/resources/namespace/set/unique.go | 106 ---- .../daprd/resources/namespace/unset/unique.go | 107 ---- .../suite/daprd/resources/resource.go | 18 - .../suite/daprd/resources/uniquename.go | 4 +- .../suite/daprd/secret/http/fuzz.go | 2 +- .../serviceinvocation/grpc/slowappstartup.go | 2 +- .../serviceinvocation/http/httpendpoints.go | 2 +- .../suite/daprd/shutdown/block/app/healthy.go | 6 +- .../daprd/shutdown/block/app/unhealthy.go | 2 +- .../suite/daprd/state/grpc/fuzz.go | 2 +- .../integration/suite/daprd/state/grpc/ttl.go | 2 +- .../suite/daprd/state/http/encryption.go | 134 ----- .../suite/daprd/state/http/fuzz.go | 2 +- .../integration/suite/daprd/state/http/ttl.go | 2 +- .../integration/suite/daprd/workflow/basic.go | 2 +- tests/integration/suite/healthz/app.go | 4 +- tests/integration/suite/healthz/daprd.go | 2 +- tests/integration/suite/healthz/operator.go | 2 +- tests/integration/suite/healthz/placement.go | 2 +- tests/integration/suite/healthz/sentry.go | 2 +- .../suite/operator/api/listcomponents.go | 2 +- .../suite/placement/apilevel/no_max.go | 9 +- .../suite/placement/apilevel/with_max.go | 6 +- .../suite/placement/apilevel/with_min.go | 9 +- .../integration/suite/placement/authz/mtls.go | 4 +- .../suite/placement/quorum/insecure.go | 4 +- .../suite/placement/quorum/jwks.go | 4 +- .../suite/placement/quorum/notls.go | 4 +- .../suite/placement/vnodes/level10.go | 76 +++ .../suite/placement/vnodes/level20.go | 76 +++ .../suite/placement/vnodes/upgrade.go | 132 +++++ .../suite/placement/vnodes/vnodes.go | 166 ------ tests/integration/suite/ports/daprd.go | 2 +- tests/integration/suite/ports/operator.go | 6 +- tests/integration/suite/ports/placement.go | 2 +- tests/integration/suite/ports/sentry.go | 2 +- 176 files changed, 1090 insertions(+), 3524 deletions(-) delete mode 100644 .github/scripts/version-skew-test-patches/e2e/release-1.12/dapr-sidecar-master/0003-remote-content-length-test.patch delete mode 100644 docs/release_notes/v1.13.0.md delete mode 100644 tests/integration/framework/process/grpc/subscriber/options.go delete mode 100644 tests/integration/framework/process/grpc/subscriber/subscriber.go delete mode 100644 tests/integration/framework/process/http/app/app.go delete mode 100644 tests/integration/framework/process/http/app/options.go delete mode 100644 tests/integration/framework/process/http/subscriber/options.go delete mode 100644 tests/integration/framework/process/http/subscriber/subscriber.go delete mode 100644 tests/integration/suite/actors/reminders/serialization/default.go delete mode 100644 tests/integration/suite/daprd/binding/output/errors.go delete mode 100644 tests/integration/suite/daprd/hotreload/selfhosted/namespace/set.go delete mode 100644 tests/integration/suite/daprd/hotreload/selfhosted/namespace/unset.go rename tests/integration/suite/daprd/hotreload/selfhosted/{selfhosted.go => selfhostest.go} (90%) delete mode 100644 tests/integration/suite/daprd/pubsub/grpc/emptymatch.go delete mode 100644 tests/integration/suite/daprd/pubsub/http/emptymatch.go rename tests/integration/suite/daprd/resources/{namespace/unset/name.go => namespace.go} (55%) delete mode 100644 tests/integration/suite/daprd/resources/namespace/namespace.go delete mode 100644 tests/integration/suite/daprd/resources/namespace/set/name.go delete mode 100644 tests/integration/suite/daprd/resources/namespace/set/unique.go delete mode 100644 tests/integration/suite/daprd/resources/namespace/unset/unique.go delete mode 100644 tests/integration/suite/daprd/resources/resource.go delete mode 100644 tests/integration/suite/daprd/state/http/encryption.go create mode 100644 tests/integration/suite/placement/vnodes/level10.go create mode 100644 tests/integration/suite/placement/vnodes/level20.go create mode 100644 tests/integration/suite/placement/vnodes/upgrade.go delete mode 100644 tests/integration/suite/placement/vnodes/vnodes.go diff --git a/.github/scripts/version-skew-test-patches/e2e/release-1.12/dapr-sidecar-master/0003-remote-content-length-test.patch b/.github/scripts/version-skew-test-patches/e2e/release-1.12/dapr-sidecar-master/0003-remote-content-length-test.patch deleted file mode 100644 index 20b5ed1325d..00000000000 --- a/.github/scripts/version-skew-test-patches/e2e/release-1.12/dapr-sidecar-master/0003-remote-content-length-test.patch +++ /dev/null @@ -1,43 +0,0 @@ -commit 6dea5b910e90647ad3bffc1458a24fceb94a6044 -Author: Yaron Schneider -Date: Wed Feb 14 10:43:04 2024 -0800 - - * update tests - - Signed-off-by: yaron2 - - --------- - - Signed-off-by: yaron2 - -diff --git a/tests/e2e/pubsub/pubsub_test.go b/tests/e2e/pubsub/pubsub_test.go -index c9b548143..dedd528c3 100644 ---- a/tests/e2e/pubsub/pubsub_test.go -+++ b/tests/e2e/pubsub/pubsub_test.go -@@ -278,12 +278,7 @@ func testPublish(t *testing.T, publisherExternalURL string, protocol string) rec - require.NoError(t, err) - offset += numberOfMessagesToPublish + 1 - -- // Test bug where content-length metadata conflict makes message undeliverable in grpc subscriber. -- // We set an arbitrarily large number that it is unlikely to match the size of the payload daprd delivers. -- metadataContentLengthConflict := map[string]string{ -- "content-length": "9999999", -- } -- sentTopicAMessages, err := sendToPublisher(t, publisherExternalURL, "pubsub-a-topic", protocol, metadataContentLengthConflict, "") -+ sentTopicAMessages, err := sendToPublisher(t, publisherExternalURL, "pubsub-a-topic", protocol, nil, "") - require.NoError(t, err) - offset += numberOfMessagesToPublish + 1 - -@@ -295,10 +290,10 @@ func testPublish(t *testing.T, publisherExternalURL string, protocol string) rec - require.NoError(t, err) - offset += numberOfMessagesToPublish + 1 - -- metadataRawPayload := map[string]string{ -+ metadata := map[string]string{ - "rawPayload": "true", - } -- sentTopicRawMessages, err := sendToPublisher(t, publisherExternalURL, "pubsub-raw-topic", protocol, metadataRawPayload, "") -+ sentTopicRawMessages, err := sendToPublisher(t, publisherExternalURL, "pubsub-raw-topic", protocol, metadata, "") - require.NoError(t, err) - offset += numberOfMessagesToPublish + 1 - diff --git a/.github/workflows/dapr-perf-components.yml b/.github/workflows/dapr-perf-components.yml index 56cafecf52f..12a367ebd1c 100644 --- a/.github/workflows/dapr-perf-components.yml +++ b/.github/workflows/dapr-perf-components.yml @@ -222,7 +222,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: 'go.mod' - name: Login to Azure if: env.CHECKOUT_REPO != '' uses: azure/login@v1 @@ -367,7 +367,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: 'go.mod' - uses: azure/setup-kubectl@v3 with: version: ${{ env.KUBECTLVER }} diff --git a/.github/workflows/dapr-perf.yml b/.github/workflows/dapr-perf.yml index 818c1077ba5..b42cf4f4e36 100644 --- a/.github/workflows/dapr-perf.yml +++ b/.github/workflows/dapr-perf.yml @@ -244,7 +244,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: 'go.mod' - name: Login to Azure if: env.CHECKOUT_REPO != '' uses: azure/login@v1 @@ -401,7 +401,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: 'go.mod' - uses: azure/setup-kubectl@v3 with: version: ${{ env.KUBECTLVER }} diff --git a/.github/workflows/dapr-standalone-validation.yml b/.github/workflows/dapr-standalone-validation.yml index 8d0760631d3..05ea5962801 100644 --- a/.github/workflows/dapr-standalone-validation.yml +++ b/.github/workflows/dapr-standalone-validation.yml @@ -55,7 +55,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: "go.mod" - name: Build Dapr's sidecar run: | git status diff --git a/.github/workflows/dapr-test-sdk.yml b/.github/workflows/dapr-test-sdk.yml index 87f48e894dc..bc156912834 100644 --- a/.github/workflows/dapr-test-sdk.yml +++ b/.github/workflows/dapr-test-sdk.yml @@ -102,7 +102,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: "go.mod" - name: Checkout python-sdk repo to run tests. uses: actions/checkout@v4 with: @@ -232,7 +232,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: "go.mod" - name: Checkout java-sdk repo to run tests. uses: actions/checkout@v4 with: @@ -404,7 +404,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: "go.mod" - name: Checkout js-sdk repo to run tests. uses: actions/checkout@v4 with: @@ -526,7 +526,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: "go.mod" - name: Set up Python 3.9 uses: actions/setup-python@v4 with: diff --git a/.github/workflows/dapr-test.yml b/.github/workflows/dapr-test.yml index 3221df6494b..957bc041c2a 100644 --- a/.github/workflows/dapr-test.yml +++ b/.github/workflows/dapr-test.yml @@ -278,7 +278,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: "go.mod" - name: Login to Azure if: env.CHECKOUT_REPO != '' uses: azure/login@v1 @@ -448,7 +448,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: "go.mod" - uses: azure/setup-kubectl@v3 with: version: ${{ env.KUBECTLVER }} diff --git a/.github/workflows/dapr.yml b/.github/workflows/dapr.yml index 7a907d8947e..111d961af7f 100644 --- a/.github/workflows/dapr.yml +++ b/.github/workflows/dapr.yml @@ -53,7 +53,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: "go.mod" - name: Check white space in .md files if: github.event_name == 'pull_request' run: | @@ -132,7 +132,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: "go.mod" - name: Run make test env: COVERAGE_OPTS: "-coverprofile=coverage.txt -covermode=atomic" @@ -176,7 +176,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: "go.mod" - name: Build binaries run: make build - name: Override DAPR_HOST_IP for MacOS @@ -268,7 +268,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: "go.mod" - name: Parse release version and set REL_VERSION and LATEST_RELEASE run: python ./.github/scripts/get_release_version.py ${{ github.event_name }} - name: Updates version for sidecar flavor diff --git a/.github/workflows/kind-e2e.yaml b/.github/workflows/kind-e2e.yaml index c66a76e7dd4..a07496ae7bb 100644 --- a/.github/workflows/kind-e2e.yaml +++ b/.github/workflows/kind-e2e.yaml @@ -94,7 +94,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: 'go.mod' - name: Configure KinD # Generate a KinD configuration file that uses: # (a) a couple of worker nodes: this is needed to run both diff --git a/.github/workflows/version-skew.yaml b/.github/workflows/version-skew.yaml index 6b65a05aabb..a39f82e0581 100644 --- a/.github/workflows/version-skew.yaml +++ b/.github/workflows/version-skew.yaml @@ -125,7 +125,7 @@ jobs: id: setup-go uses: actions/setup-go@v4 with: - go-version: '1.21.8' + go-version-file: 'go.mod' - name: Build & download binaries run: | @@ -296,7 +296,7 @@ jobs: id: setup-go uses: actions/setup-go@v5 with: - go-version: '1.21.8' + go-version-file: 'go.mod' - name: Configure KinD run: | cat > kind.yaml <= 0, causes the reported 'api-level' in the cluster to never exceed this value") + fs.IntVar(&opts.MaxAPILevel, "max-api-level", -1, "If set to >= 0, causes the reported 'api-level' in the cluster to never exceed this value") fs.IntVar(&opts.MinAPILevel, "min-api-level", 0, "Enforces a minimum 'api-level' in the cluster") fs.IntVar(&opts.ReplicationFactor, "replicationFactor", defaultReplicationFactor, "sets the replication factor for actor distribution on vnodes") diff --git a/docs/release_notes/v1.13.0.md b/docs/release_notes/v1.13.0.md deleted file mode 100644 index 0b33a8e343e..00000000000 --- a/docs/release_notes/v1.13.0.md +++ /dev/null @@ -1,519 +0,0 @@ -# Dapr 1.13 - -We're happy to announce the release of Dapr 1.13! - -We would like to extend our thanks to all the new and existing contributors who helped make this release happen. - -If you're new to Dapr, visit the [getting started](https://docs.dapr.io/getting-started/) page and familiarize yourself with Dapr. - -Docs have been updated with all the new features and changes of this release. -To get started with new capabilities introduced in this release, go to the [Concepts](https://docs.dapr.io/concepts/) and the [Developing applications](https://docs.dapr.io/developing-applications/). - -> **Note: This release contains a few [breaking changes](#breaking-changes).** - -See [this](#upgrading-to-dapr-1.13) section on upgrading Dapr to version 1.13. - -## Highlights - -These are the v1.13 release highlights: - -### Component hot reloading (preview) - -[Component "Hot Reloading"](https://v1-13.docs.dapr.io/operations/components/component-updates/#hot-reloading-preview-feature) is a new [preview feature](https://v1-13.docs.dapr.io/operations/support/support-preview-features/) that, when enabled, allows component updates to be picked up automatically, without the need for restarting the Dapr process. -The component spec is reconciled and takes effect when running in both Kubernetes and Self-Hosted modes. - -### Go and JavaScript/TypeScript SDK support for workflow - -You can now use Go and JavaScript/TypeScript to write fault-tolerant, workflow-based apps with durable execution. -See the [Go SDK for more details](https://github.com/dapr/go-sdk/tree/main/examples/workflow) and try the [Quickstart](https://github.com/dapr/quickstarts/tree/release-1.13/workflows/go/sdk) or the [examples](https://github.com/dapr/go-sdk/blob/main/examples/workflow/README.md). -See the [Javascript SDK for more details](https://github.com/dapr/js-sdk/tree/main/examples/workflow/authoring) and try the [Quickstart](https://github.com/dapr/quickstarts/tree/release-1.13/workflows/javascript/sdk) or the [examples](https://github.com/dapr/js-sdk/tree/main/examples/workflow) - -### Actor reminders performance improvement - -You can now opt-in to make actor reminders data use protobuf serialization instead of JSON, which increases throughput, reduces latency, and improves stability when multiple Dapr instances are operating on the same reminders. -With this feature enabled, we have observed improvements as high as 40% in Actor Reminders and Workflow benchmarks. -This serialization method will become default in v1.14. - -> **Important:** Once you enable this feature, you should not downgrade the Dapr control plane to an earlier version, as your reminders data may become unreadable. - -To enable protobuf serialization for actor reminders, set the following Helm argument on Kubernetes: `dapr_placement.maxActorApiLevel=20`. -On self-hosted mode, run daprd with the flag: `--max-api-level=20` - -### Low metrics cardinality for HTTP server - -Dapr now includes an optional setting to enable low cardinality for metrics emitted by the HTTP server, which will be enabled by default in Dapr 1.14. - -Currently, the Dapr HTTP server emits metrics for each request path, which has been observed to cause significant memory usage and have other negative performance impact. -When low-cardinality metrics are enabled, the HTTP Dapr server behaves more like the gRPC server and groups requests for each Dapr API together, possibly reducing memory consumption significantly. -See additional info [here](https://v1-13.docs.dapr.io/operations/observability/metrics/metrics-overview/#high-cardinality-metrics). - -### Graceful shutdown - -Dapr now accepts a `dapr.io/block-shutdown-duration` annotation or `--dapr-block-shutdown-duration` CLI flag which delays the full shutdown procedure for this duration or until the app reports as unhealthy- whichever is sooner. -During this period, all Subscriptions and input bindings will be closed. -This is useful for applications that need to use the Dapr APIs as part of their own shutdown procedure. -See additional info [here](https://v1-13.docs.dapr.io/reference/arguments-annotations-overview/). - -### Standardized error codes - -The Dapr PubSub and State APIs now have the appropriate and standardized error codes returned to applications including enriched error details based on gRPC's richer error model. -The remaining APIs are a work in progress, and community contributions towards this effort are greatly appreciated and very impactful. -See additional info on the error codes [here](https://docs.dapr.io/reference/api/error_codes/). -Check the docs for each SDK for per-SDK error code parsing and handling. -See an [example of the Go SDK error parsing and handling here](https://v1-13.docs.dapr.io/developing-applications/sdks/go/go-client/#error-handling). - -### Rust SDK support for actors (alpha) - -You can now use Rust to run Dapr Actors, a programming model for highly scalable stateful applications. -See the [Rust SDK for more details](https://github.com/dapr/rust-sdk/tree/master/examples/actors) - -### Components - -#### Local name resolver based on SQLite - -You can now use a SQLite based name resolver for [service invocation in self-hosted mode](https://docs.dapr.io/developing-applications/building-blocks/service-invocation/service-invocation-overview/). -This is useful for dealing with corporate firewalls and VPNs that filter mDNS. -See additional info [here](https://v1-13.docs.dapr.io/reference/components-reference/supported-name-resolution/nr-sqlite/). - -#### PostgreSQL state store v2 - -PostgreSQL has a new v2 implementation which contains improvements to performance and reliability. -New applications are encouraged to use v2. -The v1 implementation remains supported and is not deprecated. -There is no migration path from v1 to v2. -See additional info [here](https://v1-13.docs.dapr.io/reference/components-reference/supported-state-stores/setup-postgresql-v2/). - -#### Azure Blob Storage state store v2 - -Azure Blob Storage has a new v2 implementation, which is recommended for all new projects as it fixes a backwards-incompatible bug with key prefixes. -The v1 implementation remains supported and is not deprecated. -There is no migration path from v1 to v2. -See additional info [here](https://v1-13.docs.dapr.io/reference/components-reference/supported-state-stores/setup-azure-blobstorage/#versioning). - -## Acknowledgements - -Thanks to everyone who made this release possible! - -@a-elsheikh, @addjuarez, @AishwaryaBalyaya01, @alfred-mikhael, @amimimor, @andreas-eriksson, @andrew-hillier, @arthbalete, @artursouza, @ASHIQUEMD, @avo-sepp, @baransonmez, @berndverst, @bkc, @bmelbourne, @bruth, @burhan, @cgillum, @chaitanyab2311, @cicoyle, @ckcd, @cscetbon, @danielgerlag, @dasanind, @DeepanshuA, @ejba, @elena-kolevska, @emctl, @eunicecompra, @famarting, @farshaddavoudi, @fazledyn-or, @filintod, @frankbuckley, @frodera, @fvandillen, @fyzact, @georgestevens99, @Gonzoe79, @greenie-msft, @gspadotto, @hauju, @henrikkarstrom, @heunghingwan, @hhunter-ms, @ItalyPaleAle, @jamesmcroft, @jancespivo, @jellis18, @jerinthomas1404, @jhberge, @jigargandhi, @jjcollinge, @jorimvanhove, @JoshVanL, @kaibocai, @KarstenWintermann, @KrylixZA, @litan1106, @lrascao, @lucus-sun, @luigirende, @macel94, @marcduiker, @martbln, @mathieu-benoit, @mikeee, @MregXN, @msfussell, @mukundansundar, @nitroin, @olitomlinson, @paianish62, @passuied, @paulyuk, @philliphoff, @pngan, @prashantrewar, @prateek041, @pravinpushkar, @qustavo, @rabollin, @robertojrojas, @RyanLettieri, @sadath-12, @salaboy, @shivamkm07, @shubham1172, @sicoyle, @siebenluke, @skyao, @srilasya02, @srparupu, @stuartleeks, @Taction, @thapasusheel, @tlund101, @tmacam, @toneill818, @TWEESTY, @twinguy, @vermillionsword, @Viktorsubota, @willvelida, @WhitWaldo, @XavierGeerinck, @xiangpingjiang, @yaron2, @yash-nisar, @ytimocin - -## New in this release - -### Dapr Runtime - -- **ADDED** New name-resolver based on SQLite for local development (alternative to mDNS) [3256](https://github.com/dapr/dapr/issues/3256) [7038](https://github.com/dapr/dapr/pull/7038) -- **ADDED** Option to emit metrics from HTTP server with lower cardinality for reduced memory consumption (disabled by default), and include more information in API logs [6723](https://github.com/dapr/dapr/issues/6723) [6919](https://github.com/dapr/dapr/pull/6919) [7429](https://github.com/dapr/dapr/pull/7429) -- **ADDED** Metrics for Dapr Workflow [7109](https://github.com/dapr/dapr/issues/7109) [7152](https://github.com/dapr/dapr/pull/7152) [7370](https://github.com/dapr/dapr/pull/7370) -- **ADDED** Improve Actor Reminders performance by serializing as protobuf (opt-in) [7129](https://github.com/dapr/dapr/pull/7129) [7548](https://github.com/dapr/dapr/pull/7548) [7196](https://github.com/dapr/dapr/pull/7196) -- **UPDATED** Switched default Docker registry to `ghcr.io` in Helm chart [6413](https://github.com/dapr/dapr/issues/6413) [7176](https://github.com/dapr/dapr/pull/7176) -- **UPDATED** Enforce Component names to be unique [7195](https://github.com/dapr/dapr/pull/7195) -- **ADDED** Helm chart option to deploy Placement with zero replicas [7253](https://github.com/dapr/dapr/pull/7253) -- **ADDED** Support for `priorityClass` in Helm charts [7103](https://github.com/dapr/dapr/issues/7103) [7395](https://github.com/dapr/dapr/pull/7395) -- **ADDED** Helm option `dapr_sidecar_injector.enableK8sDownwardAPIs` to improve detection of pod IP in certain Kubernetes environments [7511](https://github.com/dapr/dapr/pull/7511) -- **ADDED** Hot Reloading for components [7239](https://github.com/dapr/dapr/pull/7239) [7260](https://github.com/dapr/dapr/pull/7260) [7286](https://github.com/dapr/dapr/pull/7286) [7433](https://github.com/dapr/dapr/pull/7433) [7441](https://github.com/dapr/dapr/pull/7441) -- **ADDED** Add Helm chart options to configure the Service resources created [7153](https://github.com/dapr/dapr/pull/7153) -- **ADDED** Option `--dapr-block-shutdown-duration` to daprd [7268](https://github.com/dapr/dapr/pull/7268) [4313](https://github.com/dapr/dapr/issues/4313) -- **ADDED** Enhanced logging for Workflow [7065](https://github.com/dapr/dapr/issues/7065) [7460](https://github.com/dapr/dapr/pull/7460) [7222](https://github.com/dapr/dapr/pull/7222) -- **ADDED** Allow specifying control plane service for actors and/or reminders [7318](https://github.com/dapr/dapr/pull/7318) [7203](https://github.com/dapr/dapr/issues/7203) -- **UPDATED** Multiple performance improvements for Actor invocations [7231](https://github.com/dapr/dapr/pull/7231) -- **UPDATED** Tune actor app health check to recover more quickly from failure [7022](https://github.com/dapr/dapr/pull/7022) -- **ADDED** Metadata API: report actor runtime status [7040](https://github.com/dapr/dapr/pull/7040) -- **ADDED** Sentry JWKS validator: add support for passing root CA certs [7366](https://github.com/dapr/dapr/pull/7366) -- **ADDED** Cascading terminate and purge of child workflows [6393](https://github.com/dapr/dapr/issues/6393) [7498](https://github.com/dapr/dapr/pull/7498) [7340](https://github.com/dapr/dapr/pull/7340) -- **ADDED** Option to add extra env vars to control plane pods in Helm charts [7183](https://github.com/dapr/dapr/pull/7183) [7182](https://github.com/dapr/dapr/pull/7182) -- **ADDED** Tracing info to outbox requests [7198](https://github.com/dapr/dapr/pull/7198) [7047](https://github.com/dapr/dapr/issues/7047) -- **ADDED** Register Reflection service on gRPC server [7215](https://github.com/dapr/dapr/pull/7215) -- **ADDED** Support for application/json serialization to outbox [7230](https://github.com/dapr/dapr/pull/7230) -- **FIXED** Dapr Operator should not patch the Subscription CRDs if the conversion webhooks are disabled [7154](https://github.com/dapr/dapr/pull/7154) [7432](https://github.com/dapr/dapr/pull/7432) -- **FIXED** Error immediately when metrics export server fails [7021](https://github.com/dapr/dapr/pull/7021) -- **FIXED** Duplicate HTTP headers on non-successful responses [7403](https://github.com/dapr/dapr/pull/7403) [7371](https://github.com/dapr/dapr/pull/7371) -- **FIXED** Fixed multiple bugs in connection with Placement service [7119](https://github.com/dapr/dapr/pull/7119) -- **FIXED** Removed unused CLI flags for control plane services [6925](https://github.com/dapr/dapr/pull/6925) -- **FIXED** `grpc_server_status` label missing for gRPC server latency metric [7045](https://github.com/dapr/dapr/issues/7045) [7255](https://github.com/dapr/dapr/pull/7255) -- **FIXED** Using `deploymentAnnotations` produces invalid Helm chart [7194](https://github.com/dapr/dapr/pull/7194) -- **FIXED** Send dropped PubSub message to dead-letter if configured [7097](https://github.com/dapr/dapr/pull/7097) [6282](https://github.com/dapr/dapr/pull/6282) -- **FIXED** Concurrency issue when halting all actors [7381](https://github.com/dapr/dapr/pull/7381) [7380](https://github.com/dapr/dapr/pull/7380) -- **FIXED** Change Operator default port to 443 [7083](https://github.com/dapr/dapr/pull/7083) -- **FIXED** Do not write SVID to local file [7214](https://github.com/dapr/dapr/pull/7214) [5756](https://github.com/dapr/dapr/pull/5756) -- **FIXED** Metadata API contains invalid value for PubSub subscription rule when undefined [7049](https://github.com/dapr/dapr/issues/7049) [7067](https://github.com/dapr/dapr/pull/7067) -- **FIXED** Prevent null traceparent from being returned to the caller [7406](https://github.com/dapr/dapr/pull/7406) [7372](https://github.com/dapr/dapr/issues/7372) -- **FIXED** Make Injector resilient to Sentry unavailability [7479](https://github.com/dapr/dapr/issues/7479) [7507](https://github.com/dapr/dapr/pull/7507) [7508](https://github.com/dapr/dapr/pull/7508) -- **FIXED** Missing namespace property in Sentry CA bundle ConfigMap Helm resource [7420](https://github.com/dapr/dapr/pull/7420) -- **FIXED** Grafana dashboards not working [7120](https://github.com/dapr/dapr/issues/7120) [7121](https://github.com/dapr/dapr/pull/7121) -- **UPDATED** Build Dapr using Go 1.21 [7228](https://github.com/dapr/dapr/issues/7228) [7262](https://github.com/dapr/dapr/pull/7262) -- **REMOVED** Remove deprecated `RenameReminder` methods [6711](https://github.com/dapr/dapr/issues/6711) [6945](https://github.com/dapr/dapr/pull/6945) -- **REMOVED** Remove `AppChannelAllowInsecureTLS` feature flag, and require TLS-enabled app channel to use TLS 1.2+ [7292](https://github.com/dapr/dapr/pull/7292) [7149](https://github.com/dapr/dapr/issues/7149) -- **FIXED** Workflow events of the same name are not buffered [6799](https://github.com/dapr/dapr/issues/6799) -- **UPDATED** Injector: Change daprd projected token audience to sentry SPIFFE ID [7041](https://github.com/dapr/dapr/pull/7041) [5756](https://github.com/dapr/dapr/pull/5756) -- **ADDED** Make workflow engine configurable [7090](https://github.com/dapr/dapr/pull/7090) [7089](https://github.com/dapr/dapr/issues/7089) -- **ADDED** Workflow creation policy options. [7101](https://github.com/dapr/dapr/issues/7101) [7308](https://github.com/dapr/dapr/pull/7308) -- **ADDED** Authorization to the APIs of Operator and Placement [7111](https://github.com/dapr/dapr/pull/7111) [7112](https://github.com/dapr/dapr/pull/7112) -- **ADDED** Support for alternate backends for Dapr Workflow (currently limited to Dapr Actors only) [7127](https://github.com/dapr/dapr/issues/7127) [7283](https://github.com/dapr/dapr/pull/7283) -- **ADDED** Richer error codes model [7257](https://github.com/dapr/dapr/pull/7257) [6068](https://github.com/dapr/dapr/pull/6068) -- **ADDED** Standardize error messages for PubSub [7322](https://github.com/dapr/dapr/pull/7322) [6068](https://github.com/dapr/dapr/pull/6068) -- **FIXED** Fix timeouts in HTTP service invocation when resiliency policies with timeouts are applied [7270](https://github.com/dapr/dapr/pull/7270) [7173](https://github.com/dapr/dapr/pull/7173) [7145](https://github.com/dapr/dapr/pull/7145) -- **ADDED** Block Graceful Shutdown: stop input bindings and subscriptions [7474](https://github.com/dapr/dapr/pull/7474) -- **FIXED** dapr-api-token header population for proxied calls [7344](https://github.com/dapr/dapr/issues/7344) [7404](https://github.com/dapr/dapr/issues/7404) -- **ADDED** Calculate vnodes on daprd instead of the placement service [7382](https://github.com/dapr/dapr/pull/7382) [7415](https://github.com/dapr/dapr/pull/7415) [7428](https://github.com/dapr/dapr/pull/7428) [7462](https://github.com/dapr/dapr/pull/7462) -- **FIXED** Workflow Sub-Orchestration creation not working [7384](https://github.com/dapr/dapr/issues/7384) -- **FIXED** conflict with `content-length` metadata in pubsub subscription. [7413](https://github.com/dapr/dapr/issues/7413) [7421](https://github.com/dapr/dapr/pull/7421) -- **ADDED** Disable placement timeout with no peers [7418](https://github.com/dapr/dapr/pull/7418) -- **FIXED** Dapr workflow fails while purging retryable child workflows [7422](https://github.com/dapr/dapr/issues/7422) -- **FIXED** Workflow gRPC start API should generate instanceID if not present [7503](https://github.com/dapr/dapr/pull/7503) -- **FIXED** Subscriptions: Fix panic when match rule is empty [7539](https://github.com/dapr/dapr/pull/7539) -- **ADDED** gRPC metadata and HTTP headers added to binding response even in case of error [7572](https://github.com/dapr/dapr/pull/7572) - -### Components - -Dapr 1.13 introduces 3 new components: - -- State Store: PostgreSQL v2 [2956](https://github.com/dapr/components-contrib/issues/2956) [3250](https://github.com/dapr/components-contrib/pull/3250) - This new version of the PostgreSQL state store can offer up to 10% improved performance in some scenarios. - This version supports all stable capabilities, including Actor State Store; support for the Alpha Query API. - Note that the v1 of the component continues to be supported and there are currently no plans to deprecate it. -- State Store: Azure Blob Storage v2 [3203](https://github.com/dapr/components-contrib/pull/3203) [3032](https://github.com/dapr/components-contrib/issues/3032) - This version addresses a fundamental breaking change in the handling of the state key prefix. - Note that the v1 of the component continues to be supported and there are currently no plans to deprecate it. -- Name Resolver: SQLite [3178](https://github.com/dapr/components-contrib/pull/3178) - This component is particularly useful in local development or in single-node deployments, as an alternative to the default mDNS name resolver. - -Additionally, one component has been removed: - -- The NATS Streaming component (which was deprecated in Dapr 1.11) has been removed, since the NATS Streaming Server project is deprecated. Users are encouraged to migrate to NATS JetStream. [3150](https://github.com/dapr/components-contrib/pull/3150) - -Other improvements and fixes to components: - -- **Bindings**: - - Invocation metadata property `ttl` is now an alias for `ttlInSeconds` and accepts a Go duration format in addition to seconds as whole numbers [3122](https://github.com/dapr/components-contrib/pull/3122) - - AWS S3: - - Added support for Content-Type in the metadata request [3216](https://github.com/dapr/components-contrib/pull/3216) - - Handle object not found error [2526](https://github.com/dapr/components-contrib/issues/2526) [3223](https://github.com/dapr/components-contrib/pull/3223) - - Azure Blob Storage: - - Handle object not found error [2526](https://github.com/dapr/components-contrib/issues/2526) [3223](https://github.com/dapr/components-contrib/pull/3223) - - GCP Bucket: - - Handle object not found error [2526](https://github.com/dapr/components-contrib/issues/2526) [3223](https://github.com/dapr/components-contrib/pull/3223) - - Huawei OBS: - - Handle object not found error [2526](https://github.com/dapr/components-contrib/issues/2526) [3223](https://github.com/dapr/components-contrib/pull/3223) - - Kafka: - - Added support for AWS IAM with AWS Kafka clusters [3239](https://github.com/dapr/components-contrib/issues/3239) [3305](https://github.com/dapr/components-contrib/pull/3305) -- **PubSub**: - - Invocation metadata property `ttl` is now an alias for `ttlInSeconds` and accepts a Go duration format in addition to seconds as whole numbers [3122](https://github.com/dapr/components-contrib/pull/3122) - - AWS SQS: - - Fixed errors during Dapr shutdown and with message polling behavior [3156](https://github.com/dapr/components-contrib/issues/3156) [3174](https://github.com/dapr/components-contrib/pull/3174) - - GCP PubSub: - - Fixed: reduce unnecessary administrator calls on publish to a GCP PubSub Topic [2539](https://github.com/dapr/components-contrib/issues/2539) [3241](https://github.com/dapr/components-contrib/pull/3241) - - Kafka: - - Added support for AWS IAM with AWS Kafka clusters [3239](https://github.com/dapr/components-contrib/issues/3239) [3305](https://github.com/dapr/components-contrib/pull/3305) - - Added Avro schema registry support [3144](https://github.com/dapr/components-contrib/issues/3144)[3292](https://github.com/dapr/components-contrib/issues/3292) - - Added message key and other metadata as metadata in consumer [3289](https://github.com/dapr/components-contrib/pull/3289) - - Added more configuration options to control prefetching and concurrency [3275](https://github.com/dapr/components-contrib/pull/3275) - - Redis: - - Added support for message metadata [3320](https://github.com/dapr/components-contrib/pull/3320) -- **Secret stores**: - - AWS Secret Manager and AWS Parameter Store: - - Added connection validation [3301](https://github.com/dapr/components-contrib/pull/3301) -- **State stores**: - - AWS DynamoDB: - - Fixed: validate AWS connection [3285](https://github.com/dapr/components-contrib/pull/3285) - - Azure Blob Storage (v1): - - Added `disableEntityManagement` metadata option to work with minimal Microsoft Entra ID permissions [3213](https://github.com/dapr/components-contrib/pull/3213) - - Azure CosmosDB: - - Added ability to pass explicit partition key in Query method [3227](https://github.com/dapr/components-contrib/pull/3227) - - Cassandra: - - Added TLS verification support via metadata option `EnableHostVerification` [3230](https://github.com/dapr/components-contrib/pull/3230) - - Microsoft SQL Server: - - Improve performance of Multi invocations with 1 operation only [3300](https://github.com/dapr/components-contrib/pull/3300) - - MySQL: - - Improved performance of Set operations with first-write-wins [3159](https://github.com/dapr/components-contrib/pull/3159) - - Improved performance of Multi invocations with 1 operation only [3300](https://github.com/dapr/components-contrib/pull/3300) - - PostgreSQL (v1): - - Improved performance of Multi invocations with 1 operation only [3300](https://github.com/dapr/components-contrib/pull/3300) - - Redis: - - Fixed: numeric operators do not work correctly on large numbers when querying [3334](https://github.com/dapr/components-contrib/pull/3334) - - SQLite: - - Fixed: when connecting to an in-memory database, limit to 1 concurrent connection [3255](https://github.com/dapr/components-contrib/pull/3255) - - Improved performance of Set operations with first-write-wins [3159](https://github.com/dapr/components-contrib/pull/3159) - - Improved performance of Multi invocations with 1 operation only [3300](https://github.com/dapr/components-contrib/pull/3300) - - All components that support the alpha Query APIs now offer new filter types [3218](https://github.com/dapr/components-contrib/pull/3218) -- **Name resolvers**: - - Consul: - - Added local in-memory caching of Consul responses [934](https://github.com/dapr/components-contrib/issues/934) [3121](https://github.com/dapr/components-contrib/pull/3121) -- **Azure components**: - - Allow Azure Auth order to be specified via `azureAuthMethods` component metadata [3183](https://github.com/dapr/components-contrib/issues/3183) [3217](https://github.com/dapr/components-contrib/pull/3217) - - -### Dapr CLI - -- **FIXED** Unix: Directories in `~/.dapr` given 777 permisions. [1317](https://github.com/dapr/cli/issues/1317) -- **UPDATE** Upgrade go to 1.21 [1331](https://github.com/dapr/cli/pull/1331) -- **ADDED** Add --run-file support for stdin [1364](https://github.com/dapr/cli/pull/1364) - -### .NET SDK - -- **UPDATED** Can't use C# 9.0 Record for actor method return type [679](https://github.com/dapr/dotnet-sdk/issues/679) -- **UPDATED** Error Suppression and Vault Name Mapping [887](https://github.com/dapr/dotnet-sdk/issues/887) -- **FIXED** HttpClient created by DaprClient.CreateInvokeHttpClient can't find the target service to invoke [937](https://github.com/dapr/dotnet-sdk/issues/937) -- **ADDED** [Crypto] Implement support for EncryptAlpha1/DecryptAlpha1 APIs [1072](https://github.com/dapr/dotnet-sdk/issues/1072) -- **ADDED** FEATURE PREVIEW: Add Actor State TTL support [1078](https://github.com/dapr/dotnet-sdk/issues/1078) -- **ADDED** Proposal: Strongly-typed non-remoted Actor clients [1158](https://github.com/dapr/dotnet-sdk/issues/1158) -- **FIXED** bug: Dapr not handling enums as string in pub/sub with JsonSerializerOptions [1160](https://github.com/dapr/dotnet-sdk/issues/1160) -- **UPDATED** Increase Logging Metrics for Workflow [1170](https://github.com/dapr/dotnet-sdk/issues/1170) -- **UPDATED** GetBulkStateAsync should have typed overload that performs bulk deserialization [1172](https://github.com/dapr/dotnet-sdk/issues/1172) -- **FIXED** Exception running Actor example: Type 'Dapr.Actors.Runtime.ActorReminder' cannot be serialized. [1177](https://github.com/dapr/dotnet-sdk/issues/1177) -- **UPDATED** [Proposal] Move to C# 10 for SDK development [1181](https://github.com/dapr/dotnet-sdk/issues/1181) -- **ADDED** Support .NET 8 [1187](https://github.com/dapr/dotnet-sdk/issues/1187) -- **FIXED** [Bug] Console will be stuck in workflow sample [1191](https://github.com/dapr/dotnet-sdk/issues/1191) -- **ADDED** add some descriptions to README in workflow example [1192](https://github.com/dapr/dotnet-sdk/pull/1192) -- **ADDED** Proposal: Support cancellation tokens for non-remoted actor interfaces [1201](https://github.com/dapr/dotnet-sdk/issues/1201) -- **UPDATED** use daprWorkflowClient instead of daprClient in workflow sample [1212](https://github.com/dapr/dotnet-sdk/pull/1212) -- **UPDATED** Weakly-typed actors should support polymorphic response and null response [1213](https://github.com/dapr/dotnet-sdk/issues/1213) -- **ADDED** Cascade Terminate/Purge for workflow [1226](https://github.com/dapr/dotnet-sdk/issues/1226) -- **FIXED** AddDaprClient incompatible with keyed services [1235](https://github.com/dapr/dotnet-sdk/issues/1235) -- **UPDATED** Update protos and related use for Dapr 1.13. [1236](https://github.com/dapr/dotnet-sdk/pull/1236) - -### Go SDK - -- **ADDED** Workflow implementation in SDK [379](https://github.com/dapr/go-sdk/issues/379) -- **RESOLVED** Allow overriding the default logger [496](https://github.com/dapr/go-sdk/pull/496) - -### Java SDK - -- **FIXED** Unable to get the HTTP response details by Dapr HttpBinding if the state code is not 200 [783](https://github.com/dapr/java-sdk/issues/783) -- **UPDATED** reactore-core to v3.5.0. [815](https://github.com/dapr/java-sdk/issues/815) -- **UPDATED** Update project-reactor dependency & fix deprecated calls [816](https://github.com/dapr/java-sdk/pull/816) -- **ADDED** Additional CloudEvent fields (pubsubname, topic, time, etc) [866](https://github.com/dapr/java-sdk/pull/866) -- **FIXED** HTTP HEAD calls must not have a request body [891](https://github.com/dapr/java-sdk/issues/891) -- **ADDED** Provide getGuid() method in Java workflow SDK [931](https://github.com/dapr/java-sdk/issues/931) -- **FIXED** Cannot schedule a workflow at a specific date/time [943](https://github.com/dapr/java-sdk/issues/943) -- **ADDED** Workflow Log Enhancements [946](https://github.com/dapr/java-sdk/issues/946) [953](https://github.com/dapr/java-sdk/pull/953) -- **ADDED** Support JDK17 and springboot3 in Dapr Java SDK [971](https://github.com/dapr/java-sdk/issues/971) -- **ADDED** Error details and payload to the DaprException [998](https://github.com/dapr/java-sdk/pull/998) [1009](https://github.com/dapr/java-sdk/pull/1009) -- **ADDED** Use health check to wait for sidecar [981](https://github.com/dapr/java-sdk/pull/981) -- **ADDED** Saga Pattern support [956](https://github.com/dapr/java-sdk/pull/956) - -### Python SDK - -- **ADDED** Check outbound healthz endpoint on sidecar wait [611](https://github.com/dapr/python-sdk/issues/611) -- **ADDED** Support Cascade Terminate/Purge feature for Dapr Workflow [661](https://github.com/dapr/python-sdk/issues/661) -- **CHANGED** Improved developer experience for error handling [648](https://github.com/dapr/python-sdk/issues/648) -- **DEPRECATED** The `wait` method is now deprecated and will be removed in a future release. The automatic outbound health check covers this use case. - -##### Python Workflow Alpha SDK (`dapr-ext-workflow`) - -- **ADDED** Python decorators for workflow [635](https://github.com/dapr/python-sdk/issues/635) -- **ADDED** Add support for retry policies [576](https://github.com/dapr/python-sdk/issues/576) -- **FIXED** Child Workflow doesn't work if input or instance_id is not passed [660](https://github.com/dapr/python-sdk/issues/660) -- **CHANGED** Logs enhancements - Structured logging and right log levels [626](https://github.com/dapr/python-sdk/issues/626) -- **ADDED** Allow optional explicit naming of workflow and activity names [623](https://github.com/dapr/python-sdk/issues/623) -- **FIXED** try/except not working correctly in workflow functions [627](https://github.com/dapr/python-sdk/issues/627) - -### JavaScript SDK - -- **FIXED** Actor reminder and timer to accept empty period parameter [535](https://github.com/dapr/js-sdk/issues/535) -- **UPDATED** Accept the API token through the DAPR_API_TOKEN environment variable [547](https://github.com/dapr/js-sdk/issues/547) -- **FIXED** ActorId accepts invalid IDs, causing issues when making Actor HTTP calls [537](https://github.com/dapr/js-sdk/issues/537) -- **FIXED** PubSub Example [557](https://github.com/dapr/js-sdk/issues/557) -- **UPDATED** gRPC endpoint parsing [542](https://github.com/dapr/js-sdk/issues/542) -- **FIXED** File Header Styling [559](https://github.com/dapr/js-sdk/pull/559) -- **ADDED** Workflow Authoring Support [463](https://github.com/dapr/js-sdk/issues/463) -- **FIXED** Configuration gRPC calls not sending metadata [570](https://github.com/dapr/js-sdk/issues/570) - -### Rust SDK - -- **UPDATED** Update dependencies (axum, prost, tonic) [121](https://github.com/dapr/rust-sdk/pull/121) -- **UPDATED** Protos updated to Dapr v1.13 [120](https://github.com/dapr/rust-sdk/pull/120) -- **CHANGED** Handle metadata for Configuration API [118](https://github.com/dapr/rust-sdk/pull/118) -- **ADDED** Configuration client API implemented [110](https://github.com/dapr/rust-sdk/pull/110) -- **ADDED** Initial actor runtime implementation [99](https://github.com/dapr/rust-sdk/pull/99) - -### Quickstarts - -Dapr 1.13 Quickstarts include these major updates: - -* **ADDED** [Workflow quickstart for Javascript](https://github.com/dapr/quickstarts/tree/release-1.13/workflows/javascript/sdk) by @kaibocai [989](https://github.com/dapr/quickstarts/pull/989) -* **ADDED** [Workflow quickstart Go](https://github.com/dapr/quickstarts/tree/release-1.13/workflows/go/sdk) by @mikeee [973](https://github.com/dapr/quickstarts/pull/973) -* **UPDATED** All C# Quickstarts upgraded to .NET 8 by @pngan [987](https://github.com/dapr/quickstarts/pull/987) -* **UPDATED** [Contribution guide](https://github.com/dapr/quickstarts/blob/release-1.13/CONTRIBUTING.md) updates for Quickstart authors by @paulyuk [977] - -Other improvements include: - -- **UPDATED** dapr.yml updates [955](https://github.com/dapr/quickstarts/pull/955) -- **UPDATED** Update app.js - `process.env.STATE_STORE_NAME` [958](https://github.com/dapr/quickstarts/pull/958) -- **UPDATED** use daprWorkflowClient instead of daprClient in workflow sample [959](https://github.com/dapr/quickstarts/pull/959) -- **UPDATED** Change dotnet TargetFramework from v7.0 to v8.0 [960](https://github.com/dapr/quickstarts/pull/960) -- **UPDATED** Clarified actor state persistence description [961](https://github.com/dapr/quickstarts/pull/961) -- **UPDATED** Updating CI/CD actions to use release-1.13 of dapr/dapr runtime [976] -- **UPDATED** Update README.md [963](https://github.com/dapr/quickstarts/pull/963) -- **FIXED** dapr-bot (assign) is broken [966](https://github.com/dapr/quickstarts/issues/966) -- **FIXED** correct readme [975](https://github.com/dapr/quickstarts/pull/975) -(https://github.com/dapr/quickstarts/pull/976) -- **FIXED** Quickstart tests are failing as CRON Binding is not getting loaded [978](https://github.com/dapr/quickstarts/issues/978) -- **FIXED** Proposal: Upgrade C# quickstarts to .NET 8 LTS [980](https://github.com/dapr/quickstarts/issues/980) -- **FIXED** Its Not clear which is the most up-to-date-dotnet Workflow Sample [981](https://github.com/dapr/quickstarts/issues/981) -- **FIXED** Fix the DAPR bot script addressing this issue #966 [985](https://github.com/dapr/quickstarts/pull/985) - -## Upgrading to Dapr 1.13 - -To upgrade to this release of Dapr, follow the steps here to ensure a smooth upgrade. -You know, the one where you don't get red errors on the terminal.. we all hate that, right? - -### Local Machine / Self-hosted - -Uninstall Dapr using the CLI you currently have installed. -Note that this will remove the default $HOME/.dapr directory, binaries and all containers dapr_redis, dapr_placement and dapr_zipkin. -Linux users need to run sudo if docker command needs sudo: - -```bash -dapr uninstall --all -``` - -For RC releases like this, download the latest and greatest release from [here](https://github.com/dapr/cli/releases) and put the `dapr` binary in your PATH. - -Once you have installed the CLI, run: - -```bash -dapr init --runtime-version=1.13 -``` - -Wait for the update to finish, ensure you are using the latest version of Dapr(1.13) with: - -```bash -$ dapr --version - -CLI version: 1.13 -Runtime version: 1.13 -``` - -### Kubernetes - -#### Upgrading from previous version - -You can perform zero-downtime upgrades using both Helm 3 and the Dapr CLI. - -##### Upgrade using the CLI - -Download the latest RC release from [here](https://github.com/dapr/cli/releases) and put the `dapr` binary in your PATH. - -To upgrade Dapr, run: - -``` -dapr upgrade --runtime-version 1.13 -k -``` - -To upgrade with high availability mode: - -``` -dapr upgrade --runtime-version 1.13 --enable-ha=true -k -``` - -Wait until the operation is finished and check your status with `dapr status -k`. - -All done! - -*Note: Make sure your deployments are restarted to pick the latest version of the Dapr sidecar* - -##### Upgrade using Helm - -To upgrade Dapr using Helm, run: - -``` -helm repo add dapr https://dapr.github.io/helm-charts/ -helm repo update - -helm upgrade dapr dapr/dapr --version 1.13 --namespace=dapr-system --wait -``` - -Wait until the operation is finished and check your status with `dapr status -k`. - -All done! - -*Note: Make sure your deployments are restarted to pick the latest version of the Dapr sidecar* - -#### Starting a fresh install on a cluster - -Please see [how to deploy Dapr on a Kubernetes cluster](https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-deploy/) for a complete guide to installing Dapr on Kubernetes - -You can use Helm 3 to install Dapr: -``` -helm repo add dapr https://dapr.github.io/helm-charts/ -helm repo update - -kubectl create namespace dapr-system - -helm install dapr dapr/dapr --version 1.13 --namespace dapr-system --wait -``` - -Alternatively, you can use the latest version of CLI: - -``` -dapr init --runtime-version=1.13 -k -``` - -##### Post installation - -Verify the control plane pods are running and are healthy: - -``` -$ dapr status -k - NAME NAMESPACE HEALTHY STATUS REPLICAS VERSION AGE CREATED - dapr-sidecar-injector dapr-system True Running 1 1.13 15s 2024-02-26 13:07.39 - dapr-sentry dapr-system True Running 1 1.13 15s 2024-02-26 13:07.39 - dapr-operator dapr-system True Running 1 1.13 15s 2024-02-26 13:07.39 - dapr-placement dapr-system True Running 1 1.13 15s 2024-02-26 13:07.39 -``` - -After Dapr 1.13 has been installed, perform a rolling restart for your deployments to pick up the new version of the sidecar. -This can be done with: - -``` -kubectl rollout restart deploy/ -``` - -## Breaking Changes - -- The NATS Streaming PubSub component, which was deprecated in Dapr 1.11, has been removed. The NATS Streaming Server project has been deprecated since June 2023, and users are encouraged to switch to [NATS JetStream](https://docs.nats.io/nats-concepts/jetstream) and the [corresponding Dapr PubSub component](https://docs.dapr.io/reference/components-reference/supported-pubsub/setup-jetstream/). [components-contrib#3150](https://github.com/dapr/components-contrib/pull/3150) -- The deprecated `RenameReminder` methods have been removed from the Dapr Actor APIs and SDKs [dapr#6711](https://github.com/dapr/dapr/issues/6711) -- The preview flag `AppChannelAllowInsecureTLS` feature flag has been removed. The Dapr app channel now requires TLS 1.2 or higher when TLS is enabled, and this behavior cannot be disabled [dapr#7149](https://github.com/dapr/dapr/issues/7149) -- When terminating or stopping a Workflow, the default behavior has changed to cascade the action to child Workflows. Non-cascading termination/purge can be requested in the API call. [dapr#7340](https://github.com/dapr/dapr/pull/7340) [dotnet-sdk#1226](https://github.com/dapr/dotnet-sdk/issues/1226) -- Components must now have a unique name across all component types [dapr#7195](https://github.com/dapr/dapr/pull/7195) -- As part of the Richer Error Codes model change ([dapr#7257](https://github.com/dapr/dapr/pull/7257), [dapr#7322](https://github.com/dapr/dapr/pull/7322)), a subset of the State and PubSub API errors has been updated to use an appropriate status code (ex. `INVALID_ARGUMENT`, `FAILED_PRECONDITION`) instead of the generic `UNKNOWN` - -### .NET SDK - -Additional breaking changes for the Dapr .NET SDK: - -- **Polymorphic Responses in Weakly-typed Actors in Dapr .NET SDK**: - - Description: The .NET 6 and .NET 8 targets of the Dapr .NET SDK have different serialization behavior of properties of a derived response object on an operation of a weakly-typed actor client. - - Impact: Impacts users upgrading a consumer application to .NET 8 running Dapr `1.13` or later. - - Root cause: In the .NET 6 target of the SDK, the actor runtime serializes the response object on an operation of a weakly-typed actor client using the runtime type of the response object. In the .NET 8 target of the SDK, the actor runtime serializes the response object using the base response type as declared on the operation on the actor interface. - - Solution: - For .NET 8, the developer must decorate the base response class that is declared on the operation on the actor interface with a `JsonDerivedType` attribute specifying the derived response class. - Alternatively, a custom `IJsonTypeInfoResolver` implementation can be set on the `JsonSerializerOptions.TypeInfoResolver` property adding a `JsonDerivedType` instance to the `JsonPolymorphismOptions.DerivedTypes` property on the `JsonTypeInfo.PolymorphismOptions` property. - - Notes: - - While .NET 7 introduced polymorphic (de)serialization using `JsonDerivedType` attribute or `JsonPolymorphismOptions` on a custom `IJsonTypeInfoResolver` implementation, Dapr does not ship a .NET 7 target of the SDK. Hence, a .NET 7 consumer application uses the .NET 6 target of the Dapr SDK. Therefore, this breaking change only applies when upgrading a consumer application to .NET 8. - - The new serialization behavior in the .NET 8 version of the SDK allows for polymorphic deserialization of the response by a weakly-typed actor client. This requires that the programmer specifies a `typeDiscriminator` on the `JsonDerivedType` attribute. - -### Polymorphic Responses in Weakly-typed Actors in Dapr .NET SDK - -The .NET 6 and .NET 8 targets of the Dapr .NET SDK have different serialization behavior of properties of a derived response object on an operation of a weakly-typed actor client. - -Impacts users upgrading a consumer application to .NET 8 running Dapr `1.13` or later. - -#### Root Cause -In the .NET 6 target of the SDK, the actor runtime serializes the response object on an operation of a weakly-typed actor client using the runtime type of the response object. -In the .NET 8 target of the SDK, the actor runtime serializes the response object using the base response type as declared on the operation on the actor interface. - -#### Solution -For .NET 8, the programmer must decorate the base response class that is declared on the operation on the actor interface with a `JsonDerivedType` attribute specifying the derived response class. - -Alternatively, a custom `IJsonTypeInfoResolver` implementation can be set on the `JsonSerializerOptions.TypeInfoResolver` property adding a `JsonDerivedType` instance to the `JsonPolymorphismOptions.DerivedTypes` property on the `JsonTypeInfo.PolymorphismOptions` property. - -> Note that while .NET 7 introduced polymorphic (de)serialization using `JsonDerivedType` attribute or `JsonPolymorphismOptions` on a custom `IJsonTypeInfoResolver` implementation, Dapr does not ship a .NET 7 target of the SDK. -> Hence, a .NET 7 consumer application uses the .NET 6 target of the Dapr SDK. -> Therefore, this breaking change only applies when upgrading a consumer application to .NET 8. - -> Note that the new serialization behavior in the .NET 8 version of the SDK allows for polymorphic deserialization of the response by a weakly-typed actor client. -> This requires that the programmer specifies a `typeDiscriminator` on the `JsonDerivedType` attribute. - -### Java SDK - -- **UPDATED** Project Reactor dependency & fix deprecated calls [816](https://github.com/dapr/java-sdk/pull/816) diff --git a/go.mod b/go.mod index d409ea3f950..638832aed69 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/argoproj/argo-rollouts v1.4.1 github.com/cenkalti/backoff/v4 v4.2.1 github.com/cloudevents/sdk-go/v2 v2.14.0 - github.com/dapr/components-contrib v1.13.0-rc.10 + github.com/dapr/components-contrib v1.13.0-rc.1 github.com/dapr/kit v0.13.0 github.com/evanphx/json-patch/v5 v5.8.1 github.com/go-chi/chi/v5 v5.0.11 @@ -61,15 +61,15 @@ require ( go.opentelemetry.io/otel/trace v1.21.0 go.uber.org/automaxprocs v1.5.3 go.uber.org/ratelimit v0.3.0 - golang.org/x/crypto v0.19.0 + golang.org/x/crypto v0.18.0 golang.org/x/exp v0.0.0-20240119083558-1b970713d09a - golang.org/x/net v0.21.0 + golang.org/x/net v0.20.0 golang.org/x/sync v0.6.0 google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 google.golang.org/grpc v1.60.1 google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20 - google.golang.org/protobuf v1.33.0 + google.golang.org/protobuf v1.32.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.28.4 k8s.io/apiextensions-apiserver v0.28.4 @@ -108,17 +108,17 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 // indirect github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs v1.0.3 // indirect github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus v1.6.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventgrid/armeventgrid/v2 v2.2.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub v1.2.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventgrid/armeventgrid/v2 v2.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub v1.1.1 // indirect github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1 // indirect github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.0.1 // indirect github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue v1.0.0 // indirect - github.com/Azure/go-amqp v1.0.5-0.20240301200753-2dff4b36f85f // indirect + github.com/Azure/go-amqp v1.0.4 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 // indirect github.com/DataDog/zstd v1.5.2 // indirect - github.com/IBM/sarama v1.42.2 // indirect + github.com/IBM/sarama v1.42.1 // indirect github.com/OneOfOne/xxhash v1.2.8 // indirect github.com/PaesslerAG/gval v1.0.0 // indirect github.com/RoaringBitmap/roaring v1.1.0 // indirect @@ -201,7 +201,7 @@ require ( github.com/dubbogo/triple v1.1.8 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.6.0 // indirect - github.com/eapache/go-resiliency v1.5.0 // indirect + github.com/eapache/go-resiliency v1.4.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect github.com/eapache/queue v1.1.0 // indirect github.com/eclipse/paho.mqtt.golang v1.4.3 // indirect @@ -291,7 +291,7 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/k0kubun/pp v3.0.1+incompatible // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/klauspost/compress v1.17.7 // indirect + github.com/klauspost/compress v1.17.4 // indirect github.com/knadh/koanf v1.4.1 // indirect github.com/kubemq-io/kubemq-go v1.7.9 // indirect github.com/kubemq-io/protobuf v1.3.1 // indirect @@ -342,7 +342,7 @@ require ( github.com/pelletier/go-toml v1.9.5 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pierrec/lz4 v2.6.1+incompatible // indirect - github.com/pierrec/lz4/v4 v4.1.21 // indirect + github.com/pierrec/lz4/v4 v4.1.18 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect @@ -406,8 +406,8 @@ require ( golang.org/x/arch v0.3.0 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/oauth2 v0.16.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/term v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.17.0 // indirect diff --git a/go.sum b/go.sum index a5e92068526..ad9e8fe82a8 100644 --- a/go.sum +++ b/go.sum @@ -83,28 +83,28 @@ github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs v1.0.3 h1:zkAs5JZZm1 github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs v1.0.3/go.mod h1:P39PnDHXbDhUV+BVw/8Nb7wQnM76jKUA7qx5T7eS+BU= github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus v1.6.0 h1:Fhg/LkAagiLv9Xpw6r2knr19tn9t1TiQoJu5bOMzflc= github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus v1.6.0/go.mod h1:7xwz/6tTwO9zMKni8/EozIMi0DTexFSm7YNE9HdD3cQ= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventgrid/armeventgrid/v2 v2.2.0 h1:rK2PztrELX4EIQV1OWaM5zXPl9OAjv/+/jg2kmHKmG0= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventgrid/armeventgrid/v2 v2.2.0/go.mod h1:GdZIPeg5TQxW50uJ8y9Eqz2FT9taolHoGawJg/KI2o4= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub v1.2.0 h1:+dggnR89/BIIlRlQ6d19dkhhdd/mQUiQbXhyHUFiB4w= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub v1.2.0/go.mod h1:tI9M2Q/ueFi287QRkdrhb9LHm6ZnXgkVYLRC3FhYkPw= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0/go.mod h1:LRr2FzBTQlONPPa5HREE5+RjSCTXl7BwOvYOaWTqCaI= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 h1:7CBQ+Ei8SP2c6ydQTGCCrS35bDxgTMfoP2miAwK++OU= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1/go.mod h1:c/wcGeGx5FUPbM/JltUYHZcKmigwyVLJlDq+4HdtXaw= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.5.0 h1:AifHbc4mg0x9zW52WOpKbsHaDKuRhlI7TVl47thgQ70= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.5.0/go.mod h1:T5RfihdXtBDxt1Ch2wobif3TvzTdumDy29kahv6AV9A= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventgrid/armeventgrid/v2 v2.1.1 h1:q8d6Cw16DrwJ+o82GMEQ+xt65q7w4m7VcI4C+gK/7Jk= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventgrid/armeventgrid/v2 v2.1.1/go.mod h1:ZHJdpjiGjZBBILAyAUTP93YSLF/Foo1J72HSx30gMeQ= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub v1.1.1 h1:gZ1ZZvrVUhDNsGNpbo2N87Y0CJB8p3IS5UH9Z4Ui97g= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub v1.1.1/go.mod h1:7fQVOnRA11ScLE8dOCWanXHQa2NMFOM2i0u/1VRICXA= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2/go.mod h1:FbdwsQ2EzwvXxOPcMFYO8ogEc9uMMIj3YkmCdXdAFmk= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 h1:ECsQtyERDVz3NP3kvDOTLvbQhqWp/x9EsGKtb4ogUr8= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0/go.mod h1:s1tW/At+xHqjNFvWU4G0c0Qv33KOhvbGNj0RCTQDV8s= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0 h1:Ma67P/GGprNwsslzEH6+Kb8nybI8jpDTm4Wmzu2ReK8= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0/go.mod h1:c+Lifp3EDEamAkPVzMooRNOK6CZjNSdEnf1A7jsI9u4= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1 h1:MyVTgWR8qd/Jw1Le0NZebGBUCLbtak3bJ3z1OlqZBpw= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1/go.mod h1:GpPjLhVR9dnUoJMyHWSPy71xY9/lcmpzIPZXmF0FCVY= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.0.1 h1:8TkzQBrN9PWIwo7ekdd696KpC6IfTltV2/F8qKKBWik= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.0.1/go.mod h1:aprFpXPQiTyG5Rkz6Ot5pvU6y6YKg/AKYOcLCoxN0bk= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0 h1:D3occbWoio4EBLkbkevetNMAVX197GkzbUMtqjGWn80= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0/go.mod h1:bTSOgj05NGRuHHhQwAdPnYr9TOdNmKlZTgGLL6nyAdI= -github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1 h1:AMf7YbZOZIW5b66cXNHMWWT/zkjhz5+a+k/3x40EO7E= -github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1/go.mod h1:uwfk06ZBcvL/g4VHNjurPfVln9NMbsk2XIZxJ+hu81k= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 h1:gggzg0SUMs6SQbEw+3LoSsYf9YMjkupeAnHMX8O9mmY= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0/go.mod h1:+6KLcKIVgxoBDMqMO/Nvy7bZ9a0nbU3I1DtFQK3YvB4= github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue v1.0.0 h1:lJwNFV+xYjHREUTHJKx/ZF6CJSt9znxmLw9DqSTvyRU= github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue v1.0.0/go.mod h1:GfT0aGew8Qj5yiQVqOO5v7N8fanbJGyUoHqXg56qcVY= -github.com/Azure/go-amqp v1.0.5-0.20240301200753-2dff4b36f85f h1:9yUxNoINCNZaa2wmW6Kl8gLkUiyLmxby6ZjCCeRYCB0= -github.com/Azure/go-amqp v1.0.5-0.20240301200753-2dff4b36f85f/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE= +github.com/Azure/go-amqp v1.0.4 h1:GX5OFOs706UjuFRD5PDKm3aOuLQ92F7DMbua+DKAYCc= +github.com/Azure/go-amqp v1.0.4/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -118,8 +118,8 @@ github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3 github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= -github.com/IBM/sarama v1.42.2 h1:VoY4hVIZ+WQJ8G9KNY/SQlWguBQXQ9uvFPOnrcu8hEw= -github.com/IBM/sarama v1.42.2/go.mod h1:FLPGUGwYqEs62hq2bVG6Io2+5n+pS6s/WOXVKWSLFtE= +github.com/IBM/sarama v1.42.1 h1:wugyWa15TDEHh2kvq2gAy1IHLjEjuYOYgXz/ruC/OSQ= +github.com/IBM/sarama v1.42.1/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= @@ -435,8 +435,8 @@ github.com/dancannon/gorethink v4.0.0+incompatible h1:KFV7Gha3AuqT+gr0B/eKvGhbjm github.com/dancannon/gorethink v4.0.0+incompatible/go.mod h1:BLvkat9KmZc1efyYwhz3WnybhRZtgF1K929FD8z1avU= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= -github.com/dapr/components-contrib v1.13.0-rc.10 h1:d5xGjRAl2Gm23YsMfwa7Lwz5FFCb1ad4UqCmHTmtyV4= -github.com/dapr/components-contrib v1.13.0-rc.10/go.mod h1:CFCvUwS2ClqTVyzfqHEGiXM3gftWOjOI73pxECoY/Iw= +github.com/dapr/components-contrib v1.13.0-rc.1 h1:wPCfzlrpUli9rOKMcnFbiqEel651X9OAS0KOG7Eub/w= +github.com/dapr/components-contrib v1.13.0-rc.1/go.mod h1:64vTYxuZ8oNmcri6cRmdciJPA+T2DiVOSimCGJJIpFc= github.com/dapr/kit v0.13.0 h1:4S+5QqDCreva+MBONtIgxeg6B2b1W89bB8F5lqKgTa0= github.com/dapr/kit v0.13.0/go.mod h1:VyHrelNXPbtS/VcQX0Y/uzW0lfEVuveJ+1E5bDys8mo= github.com/dave/jennifer v1.4.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= @@ -488,8 +488,8 @@ github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+m github.com/dvsekhvalnov/jose2go v1.6.0 h1:Y9gnSnP4qEI0+/uQkHvFXeD2PLPJeXEL+ySMEA2EjTY= github.com/dvsekhvalnov/jose2go v1.6.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= -github.com/eapache/go-resiliency v1.5.0 h1:dRsaR00whmQD+SgVKlq/vCRFNgtEb5yppyeVos3Yce0= -github.com/eapache/go-resiliency v1.5.0/go.mod h1:5yPzW0MIvSe0JDsv0v+DvcjEv2FyD6iZYSs1ZI+iQho= +github.com/eapache/go-resiliency v1.4.0 h1:3OK9bWpPk5q6pbFAaYSEwD9CLUSHG8bnZuqX2yMt3B0= +github.com/eapache/go-resiliency v1.4.0/go.mod h1:5yPzW0MIvSe0JDsv0v+DvcjEv2FyD6iZYSs1ZI+iQho= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4ALJ04o5Qqpdz8XLIpNA3WM/iSIXqxtqo7UGVws= github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0= @@ -1049,8 +1049,8 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= -github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= +github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/knadh/koanf v1.4.1 h1:Z0VGW/uo8NJmjd+L1Dc3S5frq6c62w5xQ9Yf4Mg3wFQ= @@ -1342,8 +1342,8 @@ github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= -github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ= +github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -1779,8 +1779,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1909,8 +1909,8 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -2049,8 +2049,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -2062,8 +2062,8 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2310,8 +2310,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk= diff --git a/pkg/actors/actors.go b/pkg/actors/actors.go index 91138e01a34..99b4c2a776a 100644 --- a/pkg/actors/actors.go +++ b/pkg/actors/actors.go @@ -41,7 +41,7 @@ import ( "github.com/dapr/dapr/pkg/actors/internal" "github.com/dapr/dapr/pkg/actors/timers" "github.com/dapr/dapr/pkg/channel" - "github.com/dapr/dapr/pkg/config" + configuration "github.com/dapr/dapr/pkg/config" diag "github.com/dapr/dapr/pkg/diagnostics" diagUtils "github.com/dapr/dapr/pkg/diagnostics/utils" invokev1 "github.com/dapr/dapr/pkg/messaging/v1" @@ -118,7 +118,7 @@ type actorsRuntime struct { timers internal.TimersProvider actorsReminders internal.RemindersProvider actorsTable *sync.Map - tracingSpec config.TracingSpec + tracingSpec configuration.TracingSpec resiliency resiliency.Provider storeName string compStore *compstore.ComponentStore @@ -141,7 +141,7 @@ type ActorsOpts struct { AppChannel channel.AppChannel GRPCConnectionFn GRPCConnectionFn Config Config - TracingSpec config.TracingSpec + TracingSpec configuration.TracingSpec Resiliency resiliency.Provider StateStoreName string CompStore *compstore.ComponentStore diff --git a/pkg/actors/internal_actor_test.go b/pkg/actors/internal_actor_test.go index b472709ca62..de4486b874d 100644 --- a/pkg/actors/internal_actor_test.go +++ b/pkg/actors/internal_actor_test.go @@ -87,7 +87,7 @@ func (*mockInternalActor) InvokeTimer(ctx context.Context, timer InternalActorRe func newTestActorsRuntimeWithInternalActors(internalActors map[string]InternalActorFactory) (*actorsRuntime, error) { spec := config.TracingSpec{SamplingRate: "1"} store := fakeStore() - cfg := NewConfig(ConfigOpts{ + config := NewConfig(ConfigOpts{ AppID: TestAppID, ActorsService: "placement:placement:5050", HostAddress: "localhost", @@ -98,7 +98,7 @@ func newTestActorsRuntimeWithInternalActors(internalActors map[string]InternalAc compStore.AddStateStore("actorStore", store) a, err := NewActors(ActorsOpts{ CompStore: compStore, - Config: cfg, + Config: config, TracingSpec: spec, Resiliency: resiliency.New(log), StateStoreName: "actorStore", diff --git a/pkg/actors/placement/client.go b/pkg/actors/placement/client.go index ff89ca1ff54..5d6a6a8eec4 100644 --- a/pkg/actors/placement/client.go +++ b/pkg/actors/placement/client.go @@ -18,9 +18,7 @@ import ( "sync" "google.golang.org/grpc" - "google.golang.org/grpc/metadata" - "github.com/dapr/dapr/pkg/placement" v1pb "github.com/dapr/dapr/pkg/proto/placement/v1" ) @@ -65,7 +63,6 @@ func (c *placementClient) connectToServer(ctx context.Context, serverAddr string } client := v1pb.NewPlacementClient(conn) - ctx = metadata.AppendToOutgoingContext(ctx, placement.GRPCContextKeyAcceptVNodes, "false") stream, err := client.ReportDaprStatus(ctx) if err != nil { if conn != nil { diff --git a/pkg/actors/placement/client_test.go b/pkg/actors/placement/client_test.go index 97431307ca5..2311c7e9200 100644 --- a/pkg/actors/placement/client_test.go +++ b/pkg/actors/placement/client_test.go @@ -23,9 +23,7 @@ import ( "github.com/stretchr/testify/require" "google.golang.org/grpc" "google.golang.org/grpc/connectivity" - "google.golang.org/grpc/metadata" - "github.com/dapr/dapr/pkg/placement" "github.com/dapr/dapr/pkg/security" ) @@ -88,16 +86,6 @@ func TestConnectToServer(t *testing.T) { err := client.connectToServer(context.Background(), conn) require.NoError(t, err) - - // Extract the "dapr-accept-vnodes" value from the context's metadata - md, ok := metadata.FromOutgoingContext(client.clientStream.Context()) - require.True(t, ok) - - requiresVnodes, ok := md[placement.GRPCContextKeyAcceptVNodes] - require.True(t, ok) - require.Len(t, requiresVnodes, 1) - - assert.Equal(t, "false", requiresVnodes[0]) }) } diff --git a/pkg/actors/placement/placement.go b/pkg/actors/placement/placement.go index 86ac499515b..3b9ab804f1c 100644 --- a/pkg/actors/placement/placement.go +++ b/pkg/actors/placement/placement.go @@ -31,10 +31,10 @@ import ( "github.com/dapr/dapr/pkg/actors/internal" diag "github.com/dapr/dapr/pkg/diagnostics" "github.com/dapr/dapr/pkg/placement/hashing" + "github.com/dapr/dapr/pkg/placement/raft" v1pb "github.com/dapr/dapr/pkg/proto/placement/v1" "github.com/dapr/dapr/pkg/resiliency" "github.com/dapr/dapr/utils" - "github.com/dapr/kit/logger" "github.com/dapr/kit/ptr" ) @@ -454,11 +454,12 @@ func (p *actorPlacement) establishStreamConn(ctx context.Context) (established b // onPlacementError closes the current placement stream and reestablish the connection again, // uses a different placement server depending on the error code func (p *actorPlacement) onPlacementError(err error) { - log.Debugf("Disconnected from placement: %v", err) s, ok := status.FromError(err) // If the current server is not leader, then it will try to the next server. if ok && s.Code() == codes.FailedPrecondition { p.serverIndex.Store((p.serverIndex.Load() + 1) % int32(len(p.serverAddr))) + } else { + log.Debugf("Disconnected from placement: %v", err) } } @@ -550,10 +551,10 @@ func (p *actorPlacement) updatePlacements(in *v1pb.PlacementTables) { // TODO: @elena in v1.15 remove the check for versions < 1.13 // only keep `hashing.NewFromExisting` - if in.GetReplicationFactor() > 0 && len(v.GetHosts()) == 0 { - entries[k] = hashing.NewFromExisting(loadMap, in.GetReplicationFactor(), p.virtualNodesCache) - } else { + if p.apiLevel < raft.NoVirtualNodesInPlacementTablesAPILevel { entries[k] = hashing.NewFromExistingWithVirtNodes(v.GetHosts(), v.GetSortedSet(), loadMap) + } else { + entries[k] = hashing.NewFromExisting(loadMap, in.GetReplicationFactor(), p.virtualNodesCache) } } diff --git a/pkg/actors/placement/placement_test.go b/pkg/actors/placement/placement_test.go index 6511678f972..c81997d6c29 100644 --- a/pkg/actors/placement/placement_test.go +++ b/pkg/actors/placement/placement_test.go @@ -234,24 +234,29 @@ func TestOnPlacementOrder(t *testing.T) { LoadMap: map[string]*placementv1pb.Host{ "hostname1": { Name: "app-1", - Port: 3001, + Port: 3000, Id: "id-1", }, "hostname2": { Name: "app-2", - Port: 3002, + Port: 3000, Id: "id-2", }, }, }, } + testPlacement.apiLevel = 20 + t.Cleanup(func() { + testPlacement.apiLevel = 10 + }) + testPlacement.onPlacementOrder(&placementv1pb.PlacementOrder{ Operation: "update", Tables: &placementv1pb.PlacementTables{ Version: tableVersion, Entries: entries, - ApiLevel: 10, + ApiLevel: 20, ReplicationFactor: 3, }, }) @@ -268,8 +273,7 @@ func TestOnPlacementOrder(t *testing.T) { tableVersion := "3" tableUpdateCount.Store(0) - // By not sending the replication factor, we simulate an older placement service - // In that case, we expect the vnodes and sorted set to be sent by the placement service + // entries := map[string]*placementv1pb.PlacementTable{ "actorOne": { LoadMap: map[string]*placementv1pb.Host{ @@ -311,6 +315,17 @@ func TestOnPlacementOrder(t *testing.T) { assert.Containsf(t, table, "actorOne", "actorOne should be in the table") assert.Len(t, table["actorOne"].VirtualNodes(), 6) assert.Len(t, table["actorOne"].SortedSet(), 6) + + // By not sending the replication factor, we simulate an older placement service + // In that case, we expect the vnodes and sorted set to be sent by the placement service + testPlacement.onPlacementOrder(&placementv1pb.PlacementOrder{ + Operation: "update", + Tables: &placementv1pb.PlacementTables{ + Version: tableVersion, + Entries: entries, + ApiLevel: 10, + }, + }) }) t.Run("unlock operation", func(t *testing.T) { diff --git a/pkg/api/grpc/grpc.go b/pkg/api/grpc/grpc.go index c2a7c107f55..1b7a8767f6d 100644 --- a/pkg/api/grpc/grpc.go +++ b/pkg/api/grpc/grpc.go @@ -29,7 +29,6 @@ import ( "golang.org/x/exp/slices" "google.golang.org/grpc" "google.golang.org/grpc/codes" - grpcMetadata "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" @@ -64,10 +63,7 @@ import ( "github.com/dapr/kit/logger" ) -const ( - daprHTTPStatusHeader = "dapr-http-status" - metadataPrefix = "metadata." -) +const daprHTTPStatusHeader = "dapr-http-status" // API is the gRPC interface for the Dapr gRPC API. It implements both the internal and external proto definitions. type API interface { @@ -499,13 +495,6 @@ func (a *api) InvokeBinding(ctx context.Context, in *runtimev1pb.InvokeBindingRe diag.DefaultComponentMonitoring.OutputBindingEvent(context.Background(), in.GetName(), in.GetOperation(), err == nil, elapsed) - // Some bindings have metadata in the response even in case of error - if resp != nil { - for k, v := range resp.Metadata { - grpc.SetHeader(ctx, grpcMetadata.Pairs(metadataPrefix+k, v)) - } - } - if err != nil { err = status.Errorf(codes.Internal, messages.ErrInvokeOutputBinding, in.GetName(), err.Error()) apiServerLogger.Debug(err) @@ -516,7 +505,6 @@ func (a *api) InvokeBinding(ctx context.Context, in *runtimev1pb.InvokeBindingRe r.Data = resp.Data r.Metadata = resp.Metadata } - return r, nil } diff --git a/pkg/api/http/http.go b/pkg/api/http/http.go index 8a919e8dce0..925be9c0fc9 100644 --- a/pkg/api/http/http.go +++ b/pkg/api/http/http.go @@ -571,14 +571,6 @@ func (a *api) onOutputBindingMessage(reqCtx *fasthttp.RequestCtx) { diag.DefaultComponentMonitoring.OutputBindingEvent(context.Background(), name, req.Operation, err == nil, elapsed) - if resp != nil { - // Set the metadata in the response even in case of error. - // HTTP binding, for example, returns metadata even for error. - for k, v := range resp.Metadata { - reqCtx.Response.Header.Add(metadataPrefix+k, v) - } - } - if err != nil { msg := NewErrorResponse("ERR_INVOKE_OUTPUT_BINDING", fmt.Sprintf(messages.ErrInvokeOutputBinding, name, err)) fasthttpRespond(reqCtx, fasthttpResponseWithError(nethttp.StatusInternalServerError, msg)) @@ -589,6 +581,9 @@ func (a *api) onOutputBindingMessage(reqCtx *fasthttp.RequestCtx) { if resp == nil { fasthttpRespond(reqCtx, fasthttpResponseWithEmpty()) } else { + for k, v := range resp.Metadata { + reqCtx.Response.Header.Add(metadataPrefix+k, v) + } fasthttpRespond(reqCtx, fasthttpResponseWithJSON(nethttp.StatusOK, resp.Data, resp.Metadata)) } } diff --git a/pkg/components/components_loader.go b/pkg/components/components_loader.go index e7903231e33..8acb3778dd8 100644 --- a/pkg/components/components_loader.go +++ b/pkg/components/components_loader.go @@ -17,5 +17,5 @@ import componentsV1alpha1 "github.com/dapr/dapr/pkg/apis/components/v1alpha1" // ComponentLoader is an interface for returning Dapr components. type ComponentLoader interface { - Load() ([]componentsV1alpha1.Component, error) + LoadComponents() ([]componentsV1alpha1.Component, error) } diff --git a/pkg/components/kubernetes_loader.go b/pkg/components/kubernetes_loader.go index 3e45a0607ff..94bf0b8f11c 100644 --- a/pkg/components/kubernetes_loader.go +++ b/pkg/components/kubernetes_loader.go @@ -53,7 +53,7 @@ func NewKubernetesComponents(configuration config.KubernetesConfig, namespace st } // LoadComponents returns components from a given control plane address. -func (k *KubernetesComponents) Load() ([]componentsV1alpha1.Component, error) { +func (k *KubernetesComponents) LoadComponents() ([]componentsV1alpha1.Component, error) { resp, err := k.client.ListComponents(context.Background(), &operatorv1pb.ListComponentsRequest{ Namespace: k.namespace, PodName: k.podName, diff --git a/pkg/components/kubernetes_loader_test.go b/pkg/components/kubernetes_loader_test.go index 935d116bf14..760b87a97a3 100644 --- a/pkg/components/kubernetes_loader_test.go +++ b/pkg/components/kubernetes_loader_test.go @@ -91,7 +91,7 @@ func TestLoadComponents(t *testing.T) { podName: "testPodName", } - response, err := request.Load() + response, err := request.LoadComponents() require.NoError(t, err) assert.NotNil(t, response) assert.Equal(t, "test", response[0].Name) diff --git a/pkg/components/local_loader.go b/pkg/components/local_loader.go index 89ccb858e9e..cf7baf2949f 100644 --- a/pkg/components/local_loader.go +++ b/pkg/components/local_loader.go @@ -14,62 +14,22 @@ limitations under the License. package components import ( - "errors" - "fmt" - "os" - componentsV1alpha1 "github.com/dapr/dapr/pkg/apis/components/v1alpha1" - "github.com/dapr/dapr/pkg/security" ) // LocalComponents loads components from a given directory. type LocalComponents struct { componentsManifestLoader ManifestLoader[componentsV1alpha1.Component] - namespace string } // NewLocalComponents returns a new LocalComponents. func NewLocalComponents(resourcesPaths ...string) *LocalComponents { return &LocalComponents{ componentsManifestLoader: NewDiskManifestLoader[componentsV1alpha1.Component](resourcesPaths...), - namespace: security.CurrentNamespace(), } } -// Load loads dapr components from a given directory. -func (s *LocalComponents) Load() ([]componentsV1alpha1.Component, error) { - comps, err := s.componentsManifestLoader.Load() - if err != nil { - return nil, err - } - - nsDefined := len(os.Getenv("NAMESPACE")) != 0 - - names := make(map[string]string) - var errs []error - for i := range comps { - // If the process or component namespace are not defined, use the - // current defaulted security namespace. - if !nsDefined || len(comps[i].Namespace) == 0 { - comps[i].Namespace = s.namespace - } - - // Ignore components that are not in the process security namespace. - if comps[i].Namespace != s.namespace { - continue - } - - if existing, ok := names[comps[i].Name]; ok { - errs = append(errs, fmt.Errorf("duplicate definition of component name %s with existing %s", comps[i].LogName(), existing)) - continue - } - - names[comps[i].Name] = comps[i].LogName() - } - - if len(errs) > 0 { - return nil, errors.Join(errs...) - } - - return comps, nil +// LoadComponents loads dapr components from a given directory. +func (s *LocalComponents) LoadComponents() ([]componentsV1alpha1.Component, error) { + return s.componentsManifestLoader.Load() } diff --git a/pkg/components/local_loader_test.go b/pkg/components/local_loader_test.go index 0d819ee2e7c..8869ac2f0ac 100644 --- a/pkg/components/local_loader_test.go +++ b/pkg/components/local_loader_test.go @@ -53,7 +53,7 @@ spec: remove, err := writeTempConfig(filename, yaml) require.NoError(t, err) defer remove() - components, err := request.Load() + components, err := request.LoadComponents() require.NoError(t, err) assert.Len(t, components, 1) }) @@ -71,7 +71,7 @@ name: statestore` remove, err := writeTempConfig(filename, yaml) require.NoError(t, err) defer remove() - components, err := request.Load() + components, err := request.LoadComponents() require.NoError(t, err) assert.Empty(t, components) }) @@ -79,7 +79,7 @@ name: statestore` t.Run("load components file not exist", func(t *testing.T) { request := NewLocalComponents("test-path-no-exists") - components, err := request.Load() + components, err := request.LoadComponents() require.Error(t, err) assert.Empty(t, components) }) diff --git a/pkg/config/configuration.go b/pkg/config/configuration.go index 1b5389dc458..f3a8029cd37 100644 --- a/pkg/config/configuration.go +++ b/pkg/config/configuration.go @@ -43,8 +43,7 @@ type Feature string const ( // Enables support for setting TTL on Actor state keys. ActorStateTTL Feature = "ActorStateTTL" - - // Enables support for hot reloading of Daprd Components. + // Enables support for hot reloading of Daprd Components and HTTPEndpoints. HotReload Feature = "HotReload" ) diff --git a/pkg/injector/consts/consts.go b/pkg/injector/consts/consts.go index 340f7454530..82a56e954d9 100644 --- a/pkg/injector/consts/consts.go +++ b/pkg/injector/consts/consts.go @@ -37,7 +37,6 @@ const ( UserContainerAppProtocolName = "APP_PROTOCOL" // Name of the variable exposed to the app containing the app protocol. UserContainerDaprHTTPPortName = "DAPR_HTTP_PORT" // Name of the variable exposed to the app containing the Dapr HTTP port. UserContainerDaprGRPCPortName = "DAPR_GRPC_PORT" // Name of the variable exposed to the app containing the Dapr gRPC port. - DaprContainerHostIP = "DAPR_HOST_IP" // Name of the variable injected in the daprd container containing the pod's IP TokenVolumeKubernetesMountPath = "/var/run/secrets/dapr.io/sentrytoken" /* #nosec */ // Mount path for the Kubernetes service account volume with the sentry token. TokenVolumeName = "dapr-identity-token" /* #nosec */ // Name of the volume with the service account token for daprd. ComponentsUDSVolumeName = "dapr-components-unix-domain-socket" // Name of the Unix domain socket volume for components. diff --git a/pkg/injector/patcher/sidecar.go b/pkg/injector/patcher/sidecar.go index 726c1d2a072..67482d1f1d6 100644 --- a/pkg/injector/patcher/sidecar.go +++ b/pkg/injector/patcher/sidecar.go @@ -45,7 +45,6 @@ type SidecarConfig struct { OperatorAddress string SentryAddress string RunAsNonRoot bool - EnableK8sDownwardAPIs bool ReadOnlyRootFilesystem bool SidecarDropALLCapabilities bool DisableTokenVolume bool @@ -63,25 +62,25 @@ type SidecarConfig struct { Enabled bool `annotation:"dapr.io/enabled"` AppPort int32 `annotation:"dapr.io/app-port"` Config string `annotation:"dapr.io/config"` - AppProtocol string `annotation:"dapr.io/app-protocol" default:"http"` + AppProtocol string `annotation:"dapr.io/app-protocol" default:"http"` AppSSL bool `annotation:"dapr.io/app-ssl"` // TODO: Deprecated in Dapr 1.11; remove in a future Dapr version AppID string `annotation:"dapr.io/app-id"` EnableProfiling bool `annotation:"dapr.io/enable-profiling"` - LogLevel string `annotation:"dapr.io/log-level" default:"info"` + LogLevel string `annotation:"dapr.io/log-level" default:"info"` APITokenSecret string `annotation:"dapr.io/api-token-secret"` AppTokenSecret string `annotation:"dapr.io/app-token-secret"` LogAsJSON bool `annotation:"dapr.io/log-as-json"` AppMaxConcurrency *int `annotation:"dapr.io/app-max-concurrency"` - EnableMetrics bool `annotation:"dapr.io/enable-metrics" default:"true"` - SidecarMetricsPort int32 `annotation:"dapr.io/metrics-port" default:"9090"` - EnableDebug bool `annotation:"dapr.io/enable-debug" default:"false"` - SidecarDebugPort int32 `annotation:"dapr.io/debug-port" default:"40000"` + EnableMetrics bool `annotation:"dapr.io/enable-metrics" default:"true"` + SidecarMetricsPort int32 `annotation:"dapr.io/metrics-port" default:"9090"` + EnableDebug bool `annotation:"dapr.io/enable-debug" default:"false"` + SidecarDebugPort int32 `annotation:"dapr.io/debug-port" default:"40000"` Env string `annotation:"dapr.io/env"` SidecarCPURequest string `annotation:"dapr.io/sidecar-cpu-request"` SidecarCPULimit string `annotation:"dapr.io/sidecar-cpu-limit"` SidecarMemoryRequest string `annotation:"dapr.io/sidecar-memory-request"` SidecarMemoryLimit string `annotation:"dapr.io/sidecar-memory-limit"` - SidecarListenAddresses string `annotation:"dapr.io/sidecar-listen-addresses" default:"[::1],127.0.0.1"` + SidecarListenAddresses string `annotation:"dapr.io/sidecar-listen-addresses" default:"[::1],127.0.0.1"` SidecarLivenessProbeDelaySeconds int32 `annotation:"dapr.io/sidecar-liveness-probe-delay-seconds" default:"3"` SidecarLivenessProbeTimeoutSeconds int32 `annotation:"dapr.io/sidecar-liveness-probe-timeout-seconds" default:"3"` SidecarLivenessProbePeriodSeconds int32 `annotation:"dapr.io/sidecar-liveness-probe-period-seconds" default:"6"` @@ -104,10 +103,10 @@ type SidecarConfig struct { VolumeMountsRW string `annotation:"dapr.io/volume-mounts-rw"` DisableBuiltinK8sSecretStore bool `annotation:"dapr.io/disable-builtin-k8s-secret-store"` EnableAppHealthCheck bool `annotation:"dapr.io/enable-app-health-check"` - AppHealthCheckPath string `annotation:"dapr.io/app-health-check-path" default:"/healthz"` - AppHealthProbeInterval int32 `annotation:"dapr.io/app-health-probe-interval" default:"5"` // In seconds - AppHealthProbeTimeout int32 `annotation:"dapr.io/app-health-probe-timeout" default:"500"` // In milliseconds - AppHealthThreshold int32 `annotation:"dapr.io/app-health-threshold" default:"3"` + AppHealthCheckPath string `annotation:"dapr.io/app-health-check-path" default:"/healthz"` + AppHealthProbeInterval int32 `annotation:"dapr.io/app-health-probe-interval" default:"5"` // In seconds + AppHealthProbeTimeout int32 `annotation:"dapr.io/app-health-probe-timeout" default:"500"` // In milliseconds + AppHealthThreshold int32 `annotation:"dapr.io/app-health-threshold" default:"3"` PlacementAddress string `annotation:"dapr.io/placement-host-address"` PluggableComponents string `annotation:"dapr.io/pluggable-components"` PluggableComponentsSocketsFolder string `annotation:"dapr.io/pluggable-components-sockets-folder"` diff --git a/pkg/injector/patcher/sidecar_container.go b/pkg/injector/patcher/sidecar_container.go index 221ffa108d5..de236877106 100644 --- a/pkg/injector/patcher/sidecar_container.go +++ b/pkg/injector/patcher/sidecar_container.go @@ -227,45 +227,6 @@ func (c *SidecarConfig) getSidecarContainer(opts getSidecarContainerOpts) (*core // Create the container object probeHTTPHandler := getProbeHTTPHandler(c.SidecarPublicPort, injectorConsts.APIVersionV1, injectorConsts.SidecarHealthzPath) - env := []corev1.EnvVar{ - { - Name: "NAMESPACE", - Value: c.Namespace, - }, - { - Name: securityConsts.TrustAnchorsEnvVar, - Value: string(c.CurrentTrustAnchors), - }, - { - Name: "POD_NAME", - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "metadata.name", - }, - }, - }, - // TODO: @joshvanl: In v1.14, these two env vars should be moved to flags. - { - Name: securityConsts.ControlPlaneNamespaceEnvVar, - Value: c.ControlPlaneNamespace, - }, - { - Name: securityConsts.ControlPlaneTrustDomainEnvVar, - Value: c.ControlPlaneTrustDomain, - }, - } - if c.EnableK8sDownwardAPIs { - env = append(env, - corev1.EnvVar{ - Name: injectorConsts.DaprContainerHostIP, - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "status.podIP", - }, - }, - }, - ) - } container := &corev1.Container{ Name: injectorConsts.SidecarContainerName, Image: c.SidecarImage, @@ -273,8 +234,34 @@ func (c *SidecarConfig) getSidecarContainer(opts getSidecarContainerOpts) (*core SecurityContext: securityContext, Ports: ports, Args: append(cmd, args...), - Env: env, - VolumeMounts: opts.VolumeMounts, + Env: []corev1.EnvVar{ + { + Name: "NAMESPACE", + Value: c.Namespace, + }, + { + Name: "POD_NAME", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "metadata.name", + }, + }, + }, + { + Name: securityConsts.TrustAnchorsEnvVar, + Value: string(c.CurrentTrustAnchors), + }, + // TODO: @joshvanl: In v1.14, this two env vars should be moved to flags. + { + Name: securityConsts.ControlPlaneNamespaceEnvVar, + Value: c.ControlPlaneNamespace, + }, + { + Name: securityConsts.ControlPlaneTrustDomainEnvVar, + Value: c.ControlPlaneTrustDomain, + }, + }, + VolumeMounts: opts.VolumeMounts, ReadinessProbe: &corev1.Probe{ ProbeHandler: probeHTTPHandler, InitialDelaySeconds: c.SidecarReadinessProbeDelaySeconds, diff --git a/pkg/injector/patcher/sidecar_container_test.go b/pkg/injector/patcher/sidecar_container_test.go index 3cebac8e9f9..6e7661373f7 100644 --- a/pkg/injector/patcher/sidecar_container_test.go +++ b/pkg/injector/patcher/sidecar_container_test.go @@ -14,7 +14,6 @@ limitations under the License. package patcher import ( - "encoding/json" "strings" "testing" @@ -362,7 +361,24 @@ func TestGetSidecarContainer(t *testing.T) { // Command should be empty, image's entrypoint to be used. assert.Empty(t, container.Command) - assertEqualJSON(t, container.Env, `[{"name":"NAMESPACE","value":"dapr-system"},{"name":"DAPR_TRUST_ANCHORS"},{"name":"POD_NAME","valueFrom":{"fieldRef":{"fieldPath":"metadata.name"}}},{"name":"DAPR_CONTROLPLANE_NAMESPACE","value":"my-namespace"},{"name":"DAPR_CONTROLPLANE_TRUST_DOMAIN","value":"test.example.com"},{"name":"DAPR_CERT_CHAIN","value":"my-cert-chain"},{"name":"DAPR_CERT_KEY","value":"my-cert-key"},{"name":"SENTRY_LOCAL_IDENTITY","value":"pod_identity"},{"name":"DAPR_API_TOKEN","valueFrom":{"secretKeyRef":{"name":"secret","key":"token"}}},{"name":"APP_API_TOKEN","valueFrom":{"secretKeyRef":{"name":"appsecret","key":"token"}}}]`) + // NAMESPACE + assert.Equal(t, "dapr-system", container.Env[0].Value) + // POD_NAME + assert.Equal(t, "metadata.name", container.Env[1].ValueFrom.FieldRef.FieldPath) + // DAPR_CONTROLPLANE_NAMESPACE + assert.Equal(t, "my-namespace", container.Env[3].Value) + // DAPR_CONTROLPLANE_TRUST_DOMAIN + assert.Equal(t, "test.example.com", container.Env[4].Value) + // DAPR_CERT_CHAIN + assert.Equal(t, "my-cert-chain", container.Env[5].Value) + // DAPR_CERT_KEY + assert.Equal(t, "my-cert-key", container.Env[6].Value) + // SENTRY_LOCAL_IDENTITY + assert.Equal(t, "pod_identity", container.Env[7].Value) + // DAPR_API_TOKEN + assert.Equal(t, "secret", container.Env[8].ValueFrom.SecretKeyRef.Name) + // DAPR_APP_TOKEN + assert.Equal(t, "appsecret", container.Env[9].ValueFrom.SecretKeyRef.Name) // default image assert.Equal(t, "daprio/dapr", container.Image) assert.EqualValues(t, expectedArgs, container.Args) @@ -396,7 +412,6 @@ func TestGetSidecarContainer(t *testing.T) { c.ControlPlaneTrustDomain = "test.example.com" c.CertChain = "my-cert-chain" c.CertKey = "my-cert-key" - c.EnableK8sDownwardAPIs = true c.SetFromPodAnnotations() @@ -436,7 +451,24 @@ func TestGetSidecarContainer(t *testing.T) { // Command should be empty, image's entrypoint to be used. assert.Empty(t, container.Command) - assertEqualJSON(t, container.Env, `[{"name":"NAMESPACE","value":"dapr-system"},{"name":"DAPR_TRUST_ANCHORS"},{"name":"POD_NAME","valueFrom":{"fieldRef":{"fieldPath":"metadata.name"}}},{"name":"DAPR_CONTROLPLANE_NAMESPACE","value":"my-namespace"},{"name":"DAPR_CONTROLPLANE_TRUST_DOMAIN","value":"test.example.com"},{"name":"DAPR_HOST_IP","valueFrom":{"fieldRef":{"fieldPath":"status.podIP"}}},{"name":"DAPR_CERT_CHAIN","value":"my-cert-chain"},{"name":"DAPR_CERT_KEY","value":"my-cert-key"},{"name":"SENTRY_LOCAL_IDENTITY","value":"pod_identity"},{"name":"DAPR_API_TOKEN","valueFrom":{"secretKeyRef":{"name":"secret","key":"token"}}},{"name":"APP_API_TOKEN","valueFrom":{"secretKeyRef":{"name":"appsecret","key":"token"}}}]`) + // NAMESPACE + assert.Equal(t, "dapr-system", container.Env[0].Value) + // POD_NAME + assert.Equal(t, "metadata.name", container.Env[1].ValueFrom.FieldRef.FieldPath) + // DAPR_CONTROLPLANE_NAMESPACE + assert.Equal(t, "my-namespace", container.Env[3].Value) + // DAPR_CONTROLPLANE_TRUST_DOMAIN + assert.Equal(t, "test.example.com", container.Env[4].Value) + // DAPR_CERT_CHAIN + assert.Equal(t, "my-cert-chain", container.Env[5].Value) + // DAPR_CERT_KEY + assert.Equal(t, "my-cert-key", container.Env[6].Value) + // SENTRY_LOCAL_IDENTITY + assert.Equal(t, "pod_identity", container.Env[7].Value) + // DAPR_API_TOKEN + assert.Equal(t, "secret", container.Env[8].ValueFrom.SecretKeyRef.Name) + // DAPR_APP_TOKEN + assert.Equal(t, "appsecret", container.Env[9].ValueFrom.SecretKeyRef.Name) // default image assert.Equal(t, "daprio/dapr", container.Image) assert.EqualValues(t, expectedArgs, container.Args) @@ -1133,11 +1165,3 @@ func TestGetSidecarContainer(t *testing.T) { }, })) } - -func assertEqualJSON(t *testing.T, val any, expect string) { - t.Helper() - - actual, err := json.Marshal(val) - require.NoError(t, err) - assert.Equal(t, expect, string(actual)) -} diff --git a/pkg/injector/sentry/sentry.go b/pkg/injector/sentry/sentry.go index da100ef5dd6..7a58125f22a 100644 --- a/pkg/injector/sentry/sentry.go +++ b/pkg/injector/sentry/sentry.go @@ -23,9 +23,7 @@ import ( "encoding/pem" "fmt" "os" - "time" - grpcRetry "github.com/grpc-ecosystem/go-grpc-middleware/retry" "github.com/spiffe/go-spiffe/v2/spiffeid" "google.golang.org/grpc" @@ -49,34 +47,17 @@ type Requester struct { sentryID spiffeid.ID sec security.Handler kubernetesMode bool - sentryConn *grpc.ClientConn } // New returns a new instance of the Requester. -func New(ctx context.Context, opts Options) (*Requester, error) { +func New(opts Options) *Requester { _, kubeMode := os.LookupEnv("KUBERNETES_SERVICE_HOST") - r := &Requester{ + return &Requester{ sentryAddress: opts.SentryAddress, sentryID: opts.SentryID, sec: opts.Security, kubernetesMode: kubeMode, } - - return r, r.dialSentryConnection(ctx) -} - -// dialSentryConnection creates the gRPC connection to the Sentry service and blocks for 1 minute. -func (r *Requester) dialSentryConnection(ctx context.Context) error { - connCtx, cancel := context.WithTimeout(ctx, time.Minute) - defer cancel() - - conn, err := grpc.DialContext(connCtx, r.sentryAddress, r.sec.GRPCDialOptionMTLS(r.sentryID), grpc.WithBlock()) - if err != nil { - return fmt.Errorf("error establishing connection to sentry: %w", err) - } - r.sentryConn = conn - - return nil } // RequestCertificateFromSentry requests a certificate from sentry for a @@ -97,12 +78,18 @@ func (r *Requester) RequestCertificateFromSentry(ctx context.Context, namespace return nil, nil, fmt.Errorf("failed to create sidecar csr: %w", err) } + conn, err := grpc.DialContext(ctx, r.sentryAddress, r.sec.GRPCDialOptionMTLS(r.sentryID)) + if err != nil { + return nil, nil, fmt.Errorf("error establishing connection to sentry: %w", err) + } + defer conn.Close() + token, tokenValidator, err := securitytoken.GetSentryToken(r.kubernetesMode) if err != nil { return nil, nil, fmt.Errorf("error obtaining token: %w", err) } - resp, err := sentryv1pb.NewCAClient(r.sentryConn).SignCertificate(ctx, + resp, err := sentryv1pb.NewCAClient(conn).SignCertificate(ctx, &sentryv1pb.SignCertificateRequest{ CertificateSigningRequest: pem.EncodeToMemory(&pem.Block{ Type: "CERTIFICATE REQUEST", Bytes: csrDER, @@ -111,7 +98,7 @@ func (r *Requester) RequestCertificateFromSentry(ctx context.Context, namespace Token: token, Namespace: namespace, TokenValidator: tokenValidator, - }, grpcRetry.WithMax(10), grpcRetry.WithPerRetryTimeout(time.Second*3)) + }) if err != nil { return nil, nil, fmt.Errorf("error from sentry SignCertificate: %w", err) } diff --git a/pkg/injector/service/config.go b/pkg/injector/service/config.go index 57c60312922..e240bf12690 100644 --- a/pkg/injector/service/config.go +++ b/pkg/injector/service/config.go @@ -41,7 +41,6 @@ type Config struct { RemindersServiceAddress string `envconfig:"REMINDERS_SERVICE_ADDRESS"` RunAsNonRoot string `envconfig:"SIDECAR_RUN_AS_NON_ROOT"` ReadOnlyRootFilesystem string `envconfig:"SIDECAR_READ_ONLY_ROOT_FILESYSTEM"` - EnableK8sDownwardAPIs string `envconfig:"ENABLE_K8S_DOWNWARD_APIS"` SidecarDropALLCapabilities string `envconfig:"SIDECAR_DROP_ALL_CAPABILITIES"` TrustAnchorsFile string `envconfig:"DAPR_TRUST_ANCHORS_FILE"` @@ -53,7 +52,6 @@ type Config struct { parsedRemindersService patcher.Service parsedRunAsNonRoot bool parsedReadOnlyRootFilesystem bool - parsedEnableK8sDownwardAPIs bool parsedSidecarDropALLCapabilities bool parsedEntrypointTolerations []corev1.Toleration } @@ -123,10 +121,6 @@ func (c Config) GetReadOnlyRootFilesystem() bool { return c.parsedReadOnlyRootFilesystem } -func (c Config) GetEnableK8sDownwardAPIs() bool { - return c.parsedEnableK8sDownwardAPIs -} - func (c Config) GetDropCapabilities() bool { return c.parsedSidecarDropALLCapabilities } @@ -175,7 +169,6 @@ func (c *Config) parse() (err error) { c.parsedActorsEnabled = isTruthyDefaultTrue(c.ActorsEnabled) c.parsedRunAsNonRoot = isTruthyDefaultTrue(c.RunAsNonRoot) c.parsedReadOnlyRootFilesystem = isTruthyDefaultTrue(c.ReadOnlyRootFilesystem) - c.parsedEnableK8sDownwardAPIs = kitutils.IsTruthy(c.EnableK8sDownwardAPIs) c.parsedSidecarDropALLCapabilities = kitutils.IsTruthy(c.SidecarDropALLCapabilities) return nil diff --git a/pkg/injector/service/pod_patch.go b/pkg/injector/service/pod_patch.go index cd6f521bec6..2ce0e4a15f6 100644 --- a/pkg/injector/service/pod_patch.go +++ b/pkg/injector/service/pod_patch.go @@ -73,7 +73,6 @@ func (i *injector) getPodPatchOperations(ctx context.Context, ar *admissionv1.Ad sidecar.SentryAddress = sentryAddress sidecar.RunAsNonRoot = i.config.GetRunAsNonRoot() sidecar.ReadOnlyRootFilesystem = i.config.GetReadOnlyRootFilesystem() - sidecar.EnableK8sDownwardAPIs = i.config.GetEnableK8sDownwardAPIs() sidecar.SidecarDropALLCapabilities = i.config.GetDropCapabilities() sidecar.ControlPlaneNamespace = i.controlPlaneNamespace sidecar.ControlPlaneTrustDomain = i.controlPlaneTrustDomain diff --git a/pkg/messaging/v1/util.go b/pkg/messaging/v1/util.go index 6523e382b08..8f5503ee013 100644 --- a/pkg/messaging/v1/util.go +++ b/pkg/messaging/v1/util.go @@ -233,7 +233,9 @@ func InternalMetadataToHTTPHeader(ctx context.Context, internalMD DaprInternalMe continue } - if strings.HasSuffix(keyName, gRPCBinaryMetadataSuffix) || keyName == ContentTypeHeader { + if strings.HasSuffix(keyName, gRPCBinaryMetadataSuffix) || + keyName == ContentTypeHeader || + keyName == ContentLengthHeader { continue } diff --git a/pkg/placement/membership.go b/pkg/placement/membership.go index 85a708b045a..259ce056475 100644 --- a/pkg/placement/membership.go +++ b/pkg/placement/membership.go @@ -17,11 +17,9 @@ import ( "context" "errors" "fmt" - "strings" "sync" "time" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/peer" "github.com/dapr/dapr/pkg/placement/monitoring" @@ -35,7 +33,6 @@ const ( // raftApplyCommandMaxConcurrency is the max concurrency to apply command log to raft. raftApplyCommandMaxConcurrency = 10 barrierWriteTimeout = 2 * time.Minute - GRPCContextKeyAcceptVNodes = "dapr-accept-vnodes" ) // MonitorLeadership is used to monitor if we acquire or lose our role @@ -338,41 +335,21 @@ func (p *Service) performTableDissemination(ctx context.Context) error { p.disseminateLock.Lock() defer p.disseminateLock.Unlock() + state := p.raftNode.FSM().PlacementState() + + log.Infof( + "Start disseminating tables. memberUpdateCount: %d, streams: %d, targets: %d, table generation: %s", + cnt, nStreamConnPool, nTargetConns, state.GetVersion()) p.streamConnPoolLock.RLock() streamConnPool := make([]placementGRPCStream, len(p.streamConnPool)) copy(streamConnPool, p.streamConnPool) - - // Check if the cluster has daprd hosts that expect vnodes; - // older daprd versions (pre 1.13) do expect them, and newer versions (1.13+) do not. - req := &tablesUpdateRequest{ - hosts: streamConnPool, - } - for _, stream := range streamConnPool { - hostAcceptsVNodes := hostAcceptsVNodes(stream) - if hostAcceptsVNodes && req.tablesWithVNodes == nil { - req.tablesWithVNodes = p.raftNode.FSM().PlacementState(true) - } - if !hostAcceptsVNodes && req.tables == nil { - req.tables = p.raftNode.FSM().PlacementState(false) - } - if req.tablesWithVNodes != nil && req.tables != nil { - break - } - } - p.streamConnPoolLock.RUnlock() - - log.Infof( - "Start disseminating tables. memberUpdateCount: %d, streams: %d, targets: %d, table generation: %s", - cnt, nStreamConnPool, nTargetConns, req.GetVersion()) - - if err := p.performTablesUpdate(ctx, req); err != nil { + if err := p.performTablesUpdate(ctx, streamConnPool, state); err != nil { return err } - log.Infof( "Completed dissemination. memberUpdateCount: %d, streams: %d, targets: %d, table generation: %s", - cnt, nStreamConnPool, nTargetConns, req.GetVersion()) + cnt, nStreamConnPool, nTargetConns, state.GetVersion()) p.memberUpdateCount.Store(0) // set faultyHostDetectDuration to the default duration. @@ -385,29 +362,34 @@ func (p *Service) performTableDissemination(ctx context.Context) error { // It first locks so no further dapr can be taken it. Once placement table is locked // in runtime, it proceeds to update new table to Dapr runtimes and then unlock // once all runtimes have been updated. -func (p *Service) performTablesUpdate(ctx context.Context, req *tablesUpdateRequest) error { +func (p *Service) performTablesUpdate(ctx context.Context, hosts []placementGRPCStream, newTable *v1pb.PlacementTables) error { // TODO: error from disseminationOperation needs to be handle properly. // Otherwise, each Dapr runtime will have inconsistent hashing table. startedAt := p.clock.Now() // Enforce maximum API level - if req.tablesWithVNodes != nil || req.tables != nil { - req.SetAPILevel(p.minAPILevel, p.maxAPILevel) + if newTable != nil { + if newTable.GetApiLevel() < p.minAPILevel { + newTable.ApiLevel = p.minAPILevel + } + if p.maxAPILevel != nil && newTable.GetApiLevel() > *p.maxAPILevel { + newTable.ApiLevel = *p.maxAPILevel + } } ctx, cancel := context.WithTimeout(ctx, 15*time.Second) defer cancel() // Perform each update on all hosts in sequence - err := p.disseminateOperationOnHosts(ctx, req, "lock") + err := p.disseminateOperationOnHosts(ctx, hosts, "lock", nil) if err != nil { return fmt.Errorf("dissemination of 'lock' failed: %v", err) } - err = p.disseminateOperationOnHosts(ctx, req, "update") + err = p.disseminateOperationOnHosts(ctx, hosts, "update", newTable) if err != nil { return fmt.Errorf("dissemination of 'update' failed: %v", err) } - err = p.disseminateOperationOnHosts(ctx, req, "unlock") + err = p.disseminateOperationOnHosts(ctx, hosts, "unlock", nil) if err != nil { return fmt.Errorf("dissemination of 'unlock' failed: %v", err) } @@ -416,25 +398,17 @@ func (p *Service) performTablesUpdate(ctx context.Context, req *tablesUpdateRequ return nil } -func (p *Service) disseminateOperationOnHosts(ctx context.Context, req *tablesUpdateRequest, operation string) error { +func (p *Service) disseminateOperationOnHosts(ctx context.Context, hosts []placementGRPCStream, operation string, tables *v1pb.PlacementTables) error { errCh := make(chan error) - for i := 0; i < len(req.hosts); i++ { + for i := 0; i < len(hosts); i++ { go func(i int) { - var tableToSend *v1pb.PlacementTables - hostAcceptsVNodes := hostAcceptsVNodes(req.hosts[i]) - if hostAcceptsVNodes && req.tablesWithVNodes != nil { - tableToSend = req.tablesWithVNodes - } else if !hostAcceptsVNodes && req.tables != nil { - tableToSend = req.tables - } - - errCh <- p.disseminateOperation(ctx, req.hosts[i], operation, tableToSend) + errCh <- p.disseminateOperation(ctx, hosts[i], operation, tables) }(i) } var errs []error - for i := 0; i < len(req.hosts); i++ { + for i := 0; i < len(hosts); i++ { err := <-errCh if err != nil { errs = append(errs, err) @@ -478,14 +452,3 @@ func (p *Service) disseminateOperation(ctx context.Context, target placementGRPC func() { log.Debug("Dissemination successful after failure") }, ) } - -func hostAcceptsVNodes(stream placementGRPCStream) bool { - md, ok := metadata.FromIncomingContext(stream.Context()) - if !ok { - return true // default to older versions that need vnodes - } - - // Extract apiLevel from metadata - vmd := md.Get(GRPCContextKeyAcceptVNodes) - return !(len(vmd) > 0 && strings.EqualFold(vmd[0], "false")) -} diff --git a/pkg/placement/membership_test.go b/pkg/placement/membership_test.go index d861e79baad..e82ae683f0d 100644 --- a/pkg/placement/membership_test.go +++ b/pkg/placement/membership_test.go @@ -25,7 +25,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc" - "google.golang.org/grpc/metadata" clocktesting "k8s.io/utils/clock/testing" "github.com/dapr/dapr/pkg/placement/raft" @@ -283,8 +282,7 @@ func TestPerformTableUpdate(t *testing.T) { testServer.streamConnPoolLock.RUnlock() ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - req := &tablesUpdateRequest{hosts: streamConnPool} - require.NoError(t, testServer.performTablesUpdate(ctx, req)) + require.NoError(t, testServer.performTablesUpdate(ctx, streamConnPool, nil)) // assert for i := 0; i < testClients; i++ { @@ -423,58 +421,3 @@ func TestPerformTableUpdatePerf(t *testing.T) { fmt.Println("max cost time(ms)", PerformTableUpdateCostTime(t)) } } - -// MockPlacementGRPCStream simulates the behavior of placementv1pb.Placement_ReportDaprStatusServer -type MockPlacementGRPCStream struct { - v1pb.Placement_ReportDaprStatusServer - ctx context.Context -} - -func (m MockPlacementGRPCStream) Context() context.Context { - return m.ctx -} - -// Utility function to create metadata and context for testing -func createContextWithMetadata(key, value string) context.Context { - md := metadata.Pairs(key, value) - return metadata.NewIncomingContext(context.Background(), md) -} - -func TestExpectsVNodes(t *testing.T) { - tests := []struct { - name string - ctx context.Context - expected bool - }{ - { - name: "Without metadata", - ctx: context.Background(), - expected: true, - }, - { - name: "With metadata expectsVNodes true", - ctx: createContextWithMetadata(GRPCContextKeyAcceptVNodes, "true"), - expected: true, - }, - { - name: "With metadata expectsVNodes false", - ctx: createContextWithMetadata(GRPCContextKeyAcceptVNodes, "false"), - expected: false, - }, - { - name: "With invalid metadata value", - ctx: createContextWithMetadata(GRPCContextKeyAcceptVNodes, "invalid"), - expected: true, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - stream := MockPlacementGRPCStream{ctx: tt.ctx} - result := hostAcceptsVNodes(stream) - if result != tt.expected { - t.Errorf("expectsVNodes() for %s: expected %v, got %v", tt.name, tt.expected, result) - } - }) - } -} diff --git a/pkg/placement/placement.go b/pkg/placement/placement.go index 8c6305eb86a..ee7cb69fe76 100644 --- a/pkg/placement/placement.go +++ b/pkg/placement/placement.go @@ -77,40 +77,6 @@ type hostMemberChange struct { host raft.DaprHostMember } -type tablesUpdateRequest struct { - hosts []placementGRPCStream - tables *placementv1pb.PlacementTables - tablesWithVNodes *placementv1pb.PlacementTables // Temporary. Will be removed in 1.15 -} - -// GetVersion is used only for logs in membership.go -func (r *tablesUpdateRequest) GetVersion() string { - if r.tables != nil { - return r.tables.GetVersion() - } - if r.tablesWithVNodes != nil { - return r.tablesWithVNodes.GetVersion() - } - - return "" -} - -func (r *tablesUpdateRequest) SetAPILevel(minAPILevel uint32, maxAPILevel *uint32) { - setAPILevel := func(tables *placementv1pb.PlacementTables) { - if tables != nil { - if tables.GetApiLevel() < minAPILevel { - tables.ApiLevel = minAPILevel - } - if maxAPILevel != nil && tables.GetApiLevel() > *maxAPILevel { - tables.ApiLevel = *maxAPILevel - } - } - } - - setAPILevel(r.tablesWithVNodes) - setAPILevel(r.tables) -} - // Service updates the Dapr runtimes with distributed hash tables for stateful entities. type Service struct { // streamConnPool has the stream connections established between placement gRPC server and Dapr runtime. @@ -283,18 +249,10 @@ func (p *Service) ReportDaprStatus(stream placementv1pb.Placement_ReportDaprStat registeredMemberID = req.GetName() p.addStreamConn(stream) - - updateReq := &tablesUpdateRequest{ - hosts: []placementGRPCStream{stream}, - } - if hostAcceptsVNodes(stream) { - updateReq.tablesWithVNodes = p.raftNode.FSM().PlacementState(false) - } else { - updateReq.tables = p.raftNode.FSM().PlacementState(true) - } - // We need to use a background context here so dissemination isn't tied to the context of this stream - err = p.performTablesUpdate(context.Background(), updateReq) + placementTable := p.raftNode.FSM().PlacementState() + + err = p.performTablesUpdate(context.Background(), []placementGRPCStream{stream}, placementTable) if err != nil { return err } diff --git a/pkg/placement/raft/fsm.go b/pkg/placement/raft/fsm.go index 4dcca1b1a3e..89f98fffc66 100644 --- a/pkg/placement/raft/fsm.go +++ b/pkg/placement/raft/fsm.go @@ -66,11 +66,12 @@ func (c *FSM) State() *DaprHostMemberState { } // PlacementState returns the current placement tables. -// the withVirtualNodes parameter is here for backwards compatibility and should be removed in 1.15 +// the withVirtualNodes parameter is here for backwards compatibility and should be removed in 1.14 // TODO in v1.15 remove the withVirtualNodes parameter -func (c *FSM) PlacementState(withVirtualNodes bool) *v1pb.PlacementTables { +func (c *FSM) PlacementState() *v1pb.PlacementTables { c.stateLock.RLock() defer c.stateLock.RUnlock() + withVirtualNodes := c.state.APILevel() < NoVirtualNodesInPlacementTablesAPILevel newTable := &v1pb.PlacementTables{ Version: strconv.FormatUint(c.state.TableGeneration(), 10), diff --git a/pkg/placement/raft/fsm_test.go b/pkg/placement/raft/fsm_test.go index 21ee5723c41..0394156f580 100644 --- a/pkg/placement/raft/fsm_test.go +++ b/pkg/placement/raft/fsm_test.go @@ -112,9 +112,13 @@ func TestRestore(t *testing.T) { func TestPlacementStateWithVirtualNodes(t *testing.T) { fsm := newFSM(DaprHostMemberStateConfig{ - replicationFactor: 5, + replicationFactor: 100, + minAPILevel: 0, + maxAPILevel: 100, }) + // We expect to see the placement table INCLUDE vnodes, + // because the only dapr instance in the cluster is at level 10 (pre v1.13) m := DaprHostMember{ Name: "127.0.0.1:3030", AppID: "fakeAppID", @@ -131,14 +135,15 @@ func TestPlacementStateWithVirtualNodes(t *testing.T) { Data: cmdLog, }) - newTable := fsm.PlacementState(true) + newTable := fsm.PlacementState() assert.Equal(t, "1", newTable.GetVersion()) assert.Len(t, newTable.GetEntries(), 2) - assert.Equal(t, int64(5), newTable.GetReplicationFactor()) + // The default replicationFactor is 100 + assert.Equal(t, int64(100), newTable.GetReplicationFactor()) for _, host := range newTable.GetEntries() { - assert.Len(t, host.GetHosts(), 5) - assert.Len(t, host.GetSortedSet(), 5) + assert.Len(t, host.GetHosts(), 100) + assert.Len(t, host.GetSortedSet(), 100) assert.Len(t, host.GetLoadMap(), 1) assert.Contains(t, host.GetLoadMap(), "127.0.0.1:3030") } @@ -146,12 +151,15 @@ func TestPlacementStateWithVirtualNodes(t *testing.T) { func TestPlacementState(t *testing.T) { fsm := newFSM(DaprHostMemberStateConfig{ - replicationFactor: 5, + replicationFactor: 100, + minAPILevel: 0, + maxAPILevel: 100, }) m := DaprHostMember{ Name: "127.0.0.1:3030", AppID: "fakeAppID", Entities: []string{"actorTypeOne", "actorTypeTwo"}, + APILevel: 20, } cmdLog, err := makeRaftLogCommand(MemberUpsert, m) require.NoError(t, err) @@ -163,10 +171,11 @@ func TestPlacementState(t *testing.T) { Data: cmdLog, }) - newTable := fsm.PlacementState(false) + newTable := fsm.PlacementState() assert.Equal(t, "1", newTable.GetVersion()) assert.Len(t, newTable.GetEntries(), 2) - assert.Equal(t, int64(5), newTable.GetReplicationFactor()) + // The default replicationFactor is 100 + assert.Equal(t, int64(100), newTable.GetReplicationFactor()) for _, host := range newTable.GetEntries() { assert.Empty(t, host.GetHosts()) diff --git a/pkg/runtime/hotreload/hotreload.go b/pkg/runtime/hotreload/hotreload.go index 7d9ae3839f8..90318387a38 100644 --- a/pkg/runtime/hotreload/hotreload.go +++ b/pkg/runtime/hotreload/hotreload.go @@ -15,20 +15,25 @@ package hotreload import ( "context" + "errors" componentsapi "github.com/dapr/dapr/pkg/apis/components/v1alpha1" + "github.com/dapr/dapr/pkg/config" operatorv1 "github.com/dapr/dapr/pkg/proto/operator/v1" "github.com/dapr/dapr/pkg/runtime/authorizer" "github.com/dapr/dapr/pkg/runtime/compstore" - "github.com/dapr/dapr/pkg/runtime/hotreload/loader" "github.com/dapr/dapr/pkg/runtime/hotreload/loader/disk" "github.com/dapr/dapr/pkg/runtime/hotreload/loader/operator" "github.com/dapr/dapr/pkg/runtime/hotreload/reconciler" "github.com/dapr/dapr/pkg/runtime/processor" "github.com/dapr/kit/concurrency" + "github.com/dapr/kit/logger" ) +var log = logger.NewLogger("dapr.runtime.hotreload") + type OptionsReloaderDisk struct { + Config *config.Configuration Dirs []string ComponentStore *compstore.ComponentStore Authorizer *authorizer.Authorizer @@ -39,26 +44,28 @@ type OptionsReloaderOperator struct { PodName string Namespace string Client operatorv1.OperatorClient + Config *config.Configuration ComponentStore *compstore.ComponentStore Authorizer *authorizer.Authorizer Processor *processor.Processor } type Reloader struct { - componentsLoader loader.Interface + isEnabled bool componentsReconciler *reconciler.Reconciler[componentsapi.Component] } -func NewDisk(opts OptionsReloaderDisk) (*Reloader, error) { - loader, err := disk.New(disk.Options{ +func NewDisk(ctx context.Context, opts OptionsReloaderDisk) (*Reloader, error) { + loader, err := disk.New(ctx, disk.Options{ Dirs: opts.Dirs, ComponentStore: opts.ComponentStore, }) if err != nil { return nil, err } + return &Reloader{ - componentsLoader: loader, + isEnabled: opts.Config.IsFeatureEnabled(config.HotReload), componentsReconciler: reconciler.NewComponent(reconciler.Options[componentsapi.Component]{ Loader: loader, CompStore: opts.ComponentStore, @@ -77,7 +84,7 @@ func NewOperator(opts OptionsReloaderOperator) *Reloader { }) return &Reloader{ - componentsLoader: loader, + isEnabled: opts.Config.IsFeatureEnabled(config.HotReload), componentsReconciler: reconciler.NewComponent(reconciler.Options[componentsapi.Component]{ Loader: loader, CompStore: opts.ComponentStore, @@ -88,8 +95,22 @@ func NewOperator(opts OptionsReloaderOperator) *Reloader { } func (r *Reloader) Run(ctx context.Context) error { + if !r.isEnabled { + log.Debug("Hot reloading disabled") + <-ctx.Done() + return nil + } + + log.Info("Hot reloading enabled. Daprd will reload 'Component' resources on change.") + return concurrency.NewRunnerManager( - r.componentsLoader.Run, r.componentsReconciler.Run, ).Run(ctx) } + +func (r *Reloader) Close() error { + if r.isEnabled { + log.Info("Closing hot reloader") + } + return errors.Join(r.componentsReconciler.Close()) +} diff --git a/pkg/runtime/hotreload/loader/disk/disk.go b/pkg/runtime/hotreload/loader/disk/disk.go index d4004748c9f..1af5a84ae85 100644 --- a/pkg/runtime/hotreload/loader/disk/disk.go +++ b/pkg/runtime/hotreload/loader/disk/disk.go @@ -15,16 +15,18 @@ package disk import ( "context" + "errors" "fmt" "strings" + "sync" + "sync/atomic" "time" componentsapi "github.com/dapr/dapr/pkg/apis/components/v1alpha1" - "github.com/dapr/dapr/pkg/components" "github.com/dapr/dapr/pkg/runtime/compstore" "github.com/dapr/dapr/pkg/runtime/hotreload/loader" loadercompstore "github.com/dapr/dapr/pkg/runtime/hotreload/loader/store" - "github.com/dapr/kit/concurrency" + "github.com/dapr/kit/events/batcher" "github.com/dapr/kit/fswatcher" "github.com/dapr/kit/logger" "github.com/dapr/kit/ptr" @@ -39,11 +41,13 @@ type Options struct { type disk struct { component *resource[componentsapi.Component] - fs *fswatcher.FSWatcher - updateCh chan<- struct{} + + wg sync.WaitGroup + closeCh chan struct{} + closed atomic.Bool } -func New(opts Options) (loader.Interface, error) { +func New(ctx context.Context, opts Options) (loader.Interface, error) { log.Infof("Watching directories: [%s]", strings.Join(opts.Dirs, ", ")) fs, err := fswatcher.New(fswatcher.Options{ @@ -54,26 +58,60 @@ func New(opts Options) (loader.Interface, error) { return nil, fmt.Errorf("failed to create watcher: %w", err) } - updateCh := make(chan struct{}) - - return &disk{ - fs: fs, - component: newResource[componentsapi.Component]( - components.NewLocalComponents(opts.Dirs...), - loadercompstore.NewComponent(opts.ComponentStore), - updateCh, - ), - updateCh: updateCh, - }, nil + batcher := batcher.New[int](0) + eventCh := make(chan struct{}) + + d := &disk{ + closeCh: make(chan struct{}), + component: newResource[componentsapi.Component](opts, batcher, loadercompstore.NewComponent(opts.ComponentStore)), + } + + ctx, cancel := context.WithCancel(ctx) + + d.wg.Add(2) + go func() { + if err := fs.Run(ctx, eventCh); err != nil { + log.Errorf("Error watching directories: %s", err) + } + d.wg.Done() + }() + + go func() { + defer d.wg.Done() + defer batcher.Close() + defer cancel() + var i int + for { + select { + case <-d.closeCh: + return + case <-ctx.Done(): + return + + case <-eventCh: + // Use a separate: index every batch to prevent deduplicates of separate + // file updates happening at the same time. + i++ + batcher.Batch(i) + } + } + }() + + return d, nil } -func (d *disk) Run(ctx context.Context) error { - return concurrency.NewRunnerManager( - d.component.start, - func(ctx context.Context) error { - return d.fs.Run(ctx, d.updateCh) - }, - ).Run(ctx) +func (d *disk) Close() error { + defer d.wg.Wait() + if d.closed.CompareAndSwap(false, true) { + close(d.closeCh) + } + + var errs []error + if err := d.component.close(); err != nil { + errs = append(errs, err) + } + + return errors.Join(errs...) } func (d *disk) Components() loader.Loader[componentsapi.Component] { diff --git a/pkg/runtime/hotreload/loader/disk/resource.go b/pkg/runtime/hotreload/loader/disk/resource.go index 031b7ed9b7b..8d0b410f01e 100644 --- a/pkg/runtime/hotreload/loader/disk/resource.go +++ b/pkg/runtime/hotreload/loader/disk/resource.go @@ -15,7 +15,6 @@ package disk import ( "context" - "fmt" "sync" "sync/atomic" @@ -33,22 +32,17 @@ type resource[T differ.Resource] struct { batcher *batcher.Batcher[int] store store.Store[T] diskLoader components.ManifestLoader[T] - updateCh <-chan struct{} - - lock sync.RWMutex - currentResult *differ.Result[T] wg sync.WaitGroup closeCh chan struct{} closed atomic.Bool } -func newResource[T differ.Resource](loader components.ManifestLoader[T], store store.Store[T], updateCh <-chan struct{}) *resource[T] { +func newResource[T differ.Resource](opts Options, batcher *batcher.Batcher[int], store store.Store[T]) *resource[T] { return &resource[T]{ - batcher: batcher.New[int](0), + batcher: batcher, store: store, - diskLoader: loader, - updateCh: updateCh, + diskLoader: components.NewDiskManifestLoader[T](opts.Dirs...), closeCh: make(chan struct{}), } } @@ -69,100 +63,80 @@ func (r *resource[T]) List(ctx context.Context) (*differ.LocalRemoteResources[T] // Stream returns a channel of events that will be sent when a resource is // created, updated, or deleted. func (r *resource[T]) Stream(ctx context.Context) (<-chan *loader.Event[T], error) { - eventCh := make(chan *loader.Event[T]) batchCh := make(chan struct{}) r.batcher.Subscribe(batchCh) + eventCh := make(chan *loader.Event[T]) r.wg.Add(1) go func() { defer r.wg.Done() - for { - select { - case <-ctx.Done(): - return - case <-r.closeCh: - return - case <-batchCh: - r.triggerDiff(ctx, eventCh) - } - } + r.streamResources(ctx, batchCh, eventCh) }() return eventCh, nil } -func (r *resource[T]) triggerDiff(ctx context.Context, eventCh chan<- *loader.Event[T]) { - r.lock.RLock() - defer r.lock.RUnlock() - - // Each group is a list of resources which have been created, updated, or - // deleted. It is critical that we send the events in the order of deleted, - // updated, and created. This ensures we close before initing a resource - // with the same name. - for _, group := range []struct { - resources []T - eventType operatorpb.ResourceEventType - }{ - {r.currentResult.Deleted, operatorpb.ResourceEventType_DELETED}, - {r.currentResult.Updated, operatorpb.ResourceEventType_UPDATED}, - {r.currentResult.Created, operatorpb.ResourceEventType_CREATED}, - } { - for _, resource := range group.resources { - select { - case eventCh <- &loader.Event[T]{ - Resource: resource, - Type: group.eventType, - }: - case <-r.closeCh: - return - case <-ctx.Done(): - return - } - } +func (r *resource[T]) close() error { + defer r.wg.Wait() + if r.closed.CompareAndSwap(false, true) { + close(r.closeCh) } -} -func (r *resource[T]) start(ctx context.Context) error { - defer func() { - if r.closed.CompareAndSwap(false, true) { - close(r.closeCh) - } - r.batcher.Close() - r.wg.Wait() - }() + r.batcher.Close() + + return nil +} - var i int +// streamResources will stream resources from disk and send events to eventCh. +func (r *resource[T]) streamResources(ctx context.Context, batchCh <-chan struct{}, eventCh chan<- *loader.Event[T]) { for { select { case <-ctx.Done(): - return nil + return case <-r.closeCh: - return nil - case <-r.updateCh: + return + case <-batchCh: } // List the resources which exist locally (those loaded already), and those // which reside as in a resource file on disk. resources, err := r.List(ctx) if err != nil { - return fmt.Errorf("failed to load resources from disk: %s", err) + log.Errorf("Failed to load resources from disk: %s", err) + continue } // Reconcile the differences between what we have loaded locally, and what // exists on disk.k result := differ.Diff(resources) - - r.lock.Lock() - r.currentResult = result - r.lock.Unlock() - if result == nil { continue } - // Use a separate: index every batch to prevent deduplicates of separate - // file updates happening at the same time. - i++ - r.batcher.Batch(i) + // Each group is a list of resources which have been created, updated, or + // deleted. It is critical that we send the events in the order of deleted, + // updated, and created. This ensures we close before initing a resource + // with the same name. + for _, group := range []struct { + resources []T + eventType operatorpb.ResourceEventType + }{ + {result.Deleted, operatorpb.ResourceEventType_DELETED}, + {result.Updated, operatorpb.ResourceEventType_UPDATED}, + {result.Created, operatorpb.ResourceEventType_CREATED}, + } { + for _, resource := range group.resources { + select { + case eventCh <- &loader.Event[T]{ + Resource: resource, + Type: group.eventType, + }: + case <-r.closeCh: + return + case <-ctx.Done(): + return + } + } + } } } diff --git a/pkg/runtime/hotreload/loader/disk/resource_test.go b/pkg/runtime/hotreload/loader/disk/resource_test.go index 34ba98d5f0d..d9365bfedbc 100644 --- a/pkg/runtime/hotreload/loader/disk/resource_test.go +++ b/pkg/runtime/hotreload/loader/disk/resource_test.go @@ -27,11 +27,11 @@ import ( commonapi "github.com/dapr/dapr/pkg/apis/common" componentsapi "github.com/dapr/dapr/pkg/apis/components/v1alpha1" - "github.com/dapr/dapr/pkg/components" operatorpb "github.com/dapr/dapr/pkg/proto/operator/v1" "github.com/dapr/dapr/pkg/runtime/compstore" "github.com/dapr/dapr/pkg/runtime/hotreload/loader" loadercompstore "github.com/dapr/dapr/pkg/runtime/hotreload/loader/store" + "github.com/dapr/kit/events/batcher" ) const ( @@ -69,26 +69,14 @@ func Test_Disk(t *testing.T) { dir := t.TempDir() store := compstore.New() - d, err := New(Options{ + d, err := New(context.Background(), Options{ Dirs: []string{dir}, ComponentStore: store, }) require.NoError(t, err) - errCh := make(chan error) - ctx, cancel := context.WithCancel(context.Background()) - go func() { - errCh <- d.Run(ctx) - }() - t.Cleanup(func() { - cancel() - select { - case err = <-errCh: - require.NoError(t, err) - case <-time.After(time.Second): - assert.Fail(t, "expected to receive error") - } + require.NoError(t, d.Close()) }) assert.Empty(t, store.ListComponents()) @@ -113,7 +101,7 @@ func Test_Disk(t *testing.T) { { Type: operatorpb.ResourceEventType_CREATED, Resource: componentsapi.Component{ - ObjectMeta: metav1.ObjectMeta{Name: "comp1", Namespace: "default"}, + ObjectMeta: metav1.ObjectMeta{Name: "comp1"}, TypeMeta: metav1.TypeMeta{APIVersion: "dapr.io/v1alpha1", Kind: "Component"}, Spec: componentsapi.ComponentSpec{Type: "state.in-memory", Version: "v1"}, }, @@ -121,7 +109,7 @@ func Test_Disk(t *testing.T) { { Type: operatorpb.ResourceEventType_CREATED, Resource: componentsapi.Component{ - ObjectMeta: metav1.ObjectMeta{Name: "comp2", Namespace: "default"}, + ObjectMeta: metav1.ObjectMeta{Name: "comp2"}, TypeMeta: metav1.TypeMeta{APIVersion: "dapr.io/v1alpha1", Kind: "Component"}, Spec: componentsapi.ComponentSpec{Type: "state.in-memory", Version: "v1"}, }, @@ -129,7 +117,7 @@ func Test_Disk(t *testing.T) { { Type: operatorpb.ResourceEventType_CREATED, Resource: componentsapi.Component{ - ObjectMeta: metav1.ObjectMeta{Name: "comp3", Namespace: "default"}, + ObjectMeta: metav1.ObjectMeta{Name: "comp3"}, TypeMeta: metav1.TypeMeta{APIVersion: "dapr.io/v1alpha1", Kind: "Component"}, Spec: componentsapi.ComponentSpec{Type: "state.in-memory", Version: "v1"}, }, @@ -147,30 +135,20 @@ func Test_Stream(t *testing.T) { err := os.WriteFile(filepath.Join(dir, "f.yaml"), []byte(strings.Join([]string{comp1, comp2, comp3}, "\n---\n")), 0o600) require.NoError(t, err) + batcher := batcher.New[int](0) store := compstore.New() - updateCh := make(chan struct{}) r := newResource[componentsapi.Component]( - components.NewDiskManifestLoader[componentsapi.Component](dir), + Options{Dirs: []string{dir}}, + batcher, loadercompstore.NewComponent(store), - updateCh, ) - errCh := make(chan error) - ctx, cancel := context.WithCancel(context.Background()) - go func() { - errCh <- r.start(ctx) - }() - t.Cleanup(func() { - cancel() - require.NoError(t, <-errCh) - }) + batcher.Batch(0) ch, err := r.Stream(context.Background()) require.NoError(t, err) - updateCh <- struct{}{} - var events []*loader.Event[componentsapi.Component] for i := 0; i < 3; i++ { select { @@ -207,6 +185,8 @@ func Test_Stream(t *testing.T) { }, }, }, events) + + require.NoError(t, r.close()) }) t.Run("if store has a component and event happens, should send create event with new components", func(t *testing.T) { @@ -216,6 +196,7 @@ func Test_Stream(t *testing.T) { err := os.WriteFile(filepath.Join(dir, "f.yaml"), []byte(strings.Join([]string{comp1, comp2, comp3}, "\n---\n")), 0o600) require.NoError(t, err) + batcher := batcher.New[int](0) store := compstore.New() require.NoError(t, store.AddPendingComponentForCommit(componentsapi.Component{ ObjectMeta: metav1.ObjectMeta{Name: "comp1"}, @@ -224,28 +205,17 @@ func Test_Stream(t *testing.T) { })) require.NoError(t, store.CommitPendingComponent()) - updateCh := make(chan struct{}) r := newResource[componentsapi.Component]( - components.NewDiskManifestLoader[componentsapi.Component](dir), + Options{Dirs: []string{dir}}, + batcher, loadercompstore.NewComponent(store), - updateCh, ) - errCh := make(chan error) - ctx, cancel := context.WithCancel(context.Background()) - go func() { - errCh <- r.start(ctx) - }() - t.Cleanup(func() { - cancel() - require.NoError(t, <-errCh) - }) + batcher.Batch(0) ch, err := r.Stream(context.Background()) require.NoError(t, err) - updateCh <- struct{}{} - var events []*loader.Event[componentsapi.Component] for i := 0; i < 2; i++ { select { @@ -274,6 +244,8 @@ func Test_Stream(t *testing.T) { }, }, }, events) + + require.NoError(t, r.close()) }) t.Run("if store has a component and event happens, should send create/update/delete events components", func(t *testing.T) { @@ -283,6 +255,7 @@ func Test_Stream(t *testing.T) { err := os.WriteFile(filepath.Join(dir, "f.yaml"), []byte(strings.Join([]string{comp2, comp3}, "\n---\n")), 0o600) require.NoError(t, err) + batcher := batcher.New[int](0) store := compstore.New() require.NoError(t, store.AddPendingComponentForCommit(componentsapi.Component{ ObjectMeta: metav1.ObjectMeta{Name: "comp1"}, @@ -300,34 +273,23 @@ func Test_Stream(t *testing.T) { })) require.NoError(t, store.CommitPendingComponent()) - updateCh := make(chan struct{}) r := newResource[componentsapi.Component]( - components.NewDiskManifestLoader[componentsapi.Component](dir), + Options{Dirs: []string{dir}}, + batcher, loadercompstore.NewComponent(store), - updateCh, ) - errCh := make(chan error) - ctx, cancel := context.WithCancel(context.Background()) - go func() { - errCh <- r.start(ctx) - }() - t.Cleanup(func() { - cancel() - require.NoError(t, <-errCh) - }) + batcher.Batch(0) ch, err := r.Stream(context.Background()) require.NoError(t, err) - updateCh <- struct{}{} - var events []*loader.Event[componentsapi.Component] for i := 0; i < 3; i++ { select { case event := <-ch: events = append(events, event) - case <-time.After(time.Second * 5): + case <-time.After(time.Second * 3): assert.Fail(t, "expected to receive event") } } @@ -358,5 +320,7 @@ func Test_Stream(t *testing.T) { }, }, }, events) + + require.NoError(t, r.close()) }) } diff --git a/pkg/runtime/hotreload/loader/fake/fake.go b/pkg/runtime/hotreload/loader/fake/fake.go index 0359623d38e..cdb09897f66 100644 --- a/pkg/runtime/hotreload/loader/fake/fake.go +++ b/pkg/runtime/hotreload/loader/fake/fake.go @@ -22,27 +22,17 @@ import ( ) type FakeT struct { - runFn func(context.Context) error component *Fake[componentsapi.Component] - startFn func(context.Context) error } func New() *FakeT { return &FakeT{ - runFn: func(ctx context.Context) error { - <-ctx.Done() - return nil - }, component: NewFake[componentsapi.Component](), - startFn: func(ctx context.Context) error { - <-ctx.Done() - return nil - }, } } -func (f *FakeT) Run(ctx context.Context) error { - return f.runFn(ctx) +func (f *FakeT) Close() error { + return nil } func (f *FakeT) Components() loader.Loader[componentsapi.Component] { @@ -54,11 +44,6 @@ func (f *FakeT) WithComponent(fake *Fake[componentsapi.Component]) *FakeT { return f } -func (f *FakeT) WithRun(fn func(context.Context) error) *FakeT { - f.runFn = fn - return f -} - type Fake[T differ.Resource] struct { listFn func(context.Context) (*differ.LocalRemoteResources[T], error) streamFn func(context.Context) (<-chan *loader.Event[T], error) diff --git a/pkg/runtime/hotreload/loader/loader.go b/pkg/runtime/hotreload/loader/loader.go index 59e4bf9f846..b0c49c5189b 100644 --- a/pkg/runtime/hotreload/loader/loader.go +++ b/pkg/runtime/hotreload/loader/loader.go @@ -15,6 +15,7 @@ package loader import ( "context" + "io" componentsapi "github.com/dapr/dapr/pkg/apis/components/v1alpha1" operatorv1pb "github.com/dapr/dapr/pkg/proto/operator/v1" @@ -24,7 +25,7 @@ import ( // Interface is an interface for loading and watching for changes to components // a source. type Interface interface { - Run(context.Context) error + io.Closer Components() Loader[componentsapi.Component] } diff --git a/pkg/runtime/hotreload/loader/operator/operator.go b/pkg/runtime/hotreload/loader/operator/operator.go index 0292ef7927a..5e95606f5fb 100644 --- a/pkg/runtime/hotreload/loader/operator/operator.go +++ b/pkg/runtime/hotreload/loader/operator/operator.go @@ -14,8 +14,6 @@ limitations under the License. package operator import ( - "context" - componentsapi "github.com/dapr/dapr/pkg/apis/components/v1alpha1" operatorpb "github.com/dapr/dapr/pkg/proto/operator/v1" "github.com/dapr/dapr/pkg/runtime/compstore" @@ -43,8 +41,7 @@ func New(opts Options) loader.Interface { } } -func (o *operator) Run(ctx context.Context) error { - <-ctx.Done() +func (o *operator) Close() error { return o.component.close() } diff --git a/pkg/runtime/hotreload/reconciler/reconciler.go b/pkg/runtime/hotreload/reconciler/reconciler.go index 5b1adacaada..ff19823f1e5 100644 --- a/pkg/runtime/hotreload/reconciler/reconciler.go +++ b/pkg/runtime/hotreload/reconciler/reconciler.go @@ -17,6 +17,7 @@ import ( "context" "fmt" "sync" + "sync/atomic" "time" "k8s.io/utils/clock" @@ -44,7 +45,10 @@ type Reconciler[T differ.Resource] struct { kind string manager manager[T] - clock clock.WithTicker + closeCh chan struct{} + closed atomic.Bool + wg sync.WaitGroup + clock clock.WithTicker } type manager[T differ.Resource] interface { @@ -55,8 +59,9 @@ type manager[T differ.Resource] interface { func NewComponent(opts Options[componentsapi.Component]) *Reconciler[componentsapi.Component] { return &Reconciler[componentsapi.Component]{ - clock: clock.RealClock{}, - kind: componentsapi.Kind, + clock: clock.RealClock{}, + closeCh: make(chan struct{}), + kind: componentsapi.Kind, manager: &component{ Loader: opts.Loader.Components(), store: opts.CompStore, @@ -67,14 +72,26 @@ func NewComponent(opts Options[componentsapi.Component]) *Reconciler[componentsa } func (r *Reconciler[T]) Run(ctx context.Context) error { + r.wg.Add(1) + defer r.wg.Done() + stream, err := r.manager.Stream(ctx) if err != nil { - return fmt.Errorf("error running component stream: %w", err) + return fmt.Errorf("error starting component stream: %w", err) } return r.watchForEvents(ctx, stream) } +func (r *Reconciler[T]) Close() error { + defer r.wg.Wait() + if r.closed.CompareAndSwap(false, true) { + close(r.closeCh) + } + + return nil +} + func (r *Reconciler[T]) watchForEvents(ctx context.Context, stream <-chan *loader.Event[T]) error { log.Infof("Starting to watch %s updates", r.kind) @@ -88,6 +105,8 @@ func (r *Reconciler[T]) watchForEvents(ctx context.Context, stream <-chan *loade select { case <-ctx.Done(): return nil + case <-r.closeCh: + return nil case <-ticker.C(): log.Debugf("Running scheduled %s reconcile", r.kind) resources, err := r.manager.List(ctx) diff --git a/pkg/runtime/hotreload/reconciler/reconciler_test.go b/pkg/runtime/hotreload/reconciler/reconciler_test.go index 3d71149fdcb..239f935dc05 100644 --- a/pkg/runtime/hotreload/reconciler/reconciler_test.go +++ b/pkg/runtime/hotreload/reconciler/reconciler_test.go @@ -52,9 +52,8 @@ func Test_Run(t *testing.T) { r.clock = fakeClock errCh := make(chan error) - ctx, cancel := context.WithCancel(context.Background()) go func() { - errCh <- r.Run(ctx) + errCh <- r.Run(context.Background()) }() assert.Eventually(t, fakeClock.HasWaiters, time.Second*3, time.Millisecond*100) @@ -67,7 +66,8 @@ func Test_Run(t *testing.T) { return listCalled.Load() == 1 }, time.Second*3, time.Millisecond*100) - cancel() + require.NoError(t, r.Close()) + select { case err := <-errCh: require.NoError(t, err) @@ -105,9 +105,8 @@ func Test_Run(t *testing.T) { r.manager = mngr errCh := make(chan error) - ctx, cancel := context.WithCancel(context.Background()) go func() { - errCh <- r.Run(ctx) + errCh <- r.Run(context.Background()) }() comp1 := componentsapi.Component{ObjectMeta: metav1.ObjectMeta{Name: "foo"}} @@ -160,13 +159,8 @@ func Test_Run(t *testing.T) { t.Error("did not get event in time") } - cancel() - select { - case err := <-errCh: - require.NoError(t, err) - case <-time.After(time.Second * 3): - t.Error("reconciler did not return in time") - } + require.NoError(t, r.Close()) + require.NoError(t, <-errCh) }) } diff --git a/pkg/runtime/processor/pubsub/pubsub.go b/pkg/runtime/processor/pubsub/pubsub.go index 395b31f32d2..7ecefab95f0 100644 --- a/pkg/runtime/processor/pubsub/pubsub.go +++ b/pkg/runtime/processor/pubsub/pubsub.go @@ -236,7 +236,7 @@ func findMatchingRoute(rules []*rtpubsub.Rule, cloudEvent interface{}) (path str func matchRoutingRule(rules []*rtpubsub.Rule, data map[string]interface{}) (*rtpubsub.Rule, error) { for _, rule := range rules { - if rule.Match == nil || len(rule.Match.String()) == 0 { + if rule.Match == nil { return rule, nil } iResult, err := rule.Match.Eval(data) diff --git a/pkg/runtime/processor/secret/secret.go b/pkg/runtime/processor/secret/secret.go index ec1e5e678a9..93aee33f637 100644 --- a/pkg/runtime/processor/secret/secret.go +++ b/pkg/runtime/processor/secret/secret.go @@ -23,6 +23,7 @@ import ( "sync" "github.com/dapr/components-contrib/secretstores" + commonapi "github.com/dapr/dapr/pkg/apis/common" compapi "github.com/dapr/dapr/pkg/apis/components/v1alpha1" compsecret "github.com/dapr/dapr/pkg/components/secretstores" diag "github.com/dapr/dapr/pkg/diagnostics" @@ -152,6 +153,7 @@ func (s *secret) ProcessResource(ctx context.Context, resource meta.Resource) (u } metadata[i].SetValue(dec) + metadata[i].SecretKeyRef = commonapi.SecretKeyRef{} updated = true continue } @@ -186,6 +188,7 @@ func (s *secret) ProcessResource(ctx context.Context, resource meta.Resource) (u val, ok := resp.Data[secretKeyName] if ok && val != "" { metadata[i].SetValue([]byte(val)) + metadata[i].SecretKeyRef = commonapi.SecretKeyRef{} updated = true } diff --git a/pkg/runtime/processor/state/state.go b/pkg/runtime/processor/state/state.go index 0c1fcfad186..d48ea46e219 100644 --- a/pkg/runtime/processor/state/state.go +++ b/pkg/runtime/processor/state/state.go @@ -86,8 +86,8 @@ func (s *state) Init(ctx context.Context, comp compapi.Component) error { secretStoreName := s.meta.AuthSecretStoreOrDefault(&comp) secretStore, _ := s.compStore.GetSecretStore(secretStoreName) - encKeys, err := encryption.ComponentEncryptionKey(comp, secretStore) - if err != nil { + encKeys, encErr := encryption.ComponentEncryptionKey(comp, secretStore) + if encErr != nil { diag.DefaultMonitoring.ComponentInitFailed(comp.Spec.Type, "creation", comp.ObjectMeta.Name) return rterrors.NewInit(rterrors.CreateComponentFailure, fName, err) } @@ -95,8 +95,7 @@ func (s *state) Init(ctx context.Context, comp compapi.Component) error { if encKeys.Primary.Key != "" { ok := encryption.AddEncryptedStateStore(comp.ObjectMeta.Name, encKeys) if ok { - log.Infof("Automatic encryption enabled for state store %s", comp.ObjectMeta.Name) - log.Info("WARNING: Automatic state store encryption should never be used to store more than 4 billion items in the state store (including updates). Storing more items than that can cause the private key to be exposed.") + log.Infof("automatic encryption enabled for state store %s", comp.ObjectMeta.Name) } } diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index 339b3f755ea..61d5238ac04 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -197,6 +197,33 @@ func newDaprRuntime(ctx context.Context, MiddlewareHTTP: httpMiddleware, }) + var reloader *hotreload.Reloader + switch runtimeConfig.mode { + case modes.KubernetesMode: + reloader = hotreload.NewOperator(hotreload.OptionsReloaderOperator{ + PodName: podName, + Namespace: namespace, + Client: operatorClient, + Config: globalConfig, + ComponentStore: compStore, + Authorizer: authz, + Processor: processor, + }) + case modes.StandaloneMode: + reloader, err = hotreload.NewDisk(ctx, hotreload.OptionsReloaderDisk{ + Config: globalConfig, + Dirs: runtimeConfig.standalone.ResourcesPath, + ComponentStore: compStore, + Authorizer: authz, + Processor: processor, + }) + if err != nil { + return nil, err + } + default: + return nil, fmt.Errorf("invalid mode: %s", runtimeConfig.mode) + } + rt := &DaprRuntime{ runtimeConfig: runtimeConfig, globalConfig: globalConfig, @@ -212,6 +239,7 @@ func newDaprRuntime(ctx context.Context, sec: sec, processor: processor, authz: authz, + reloader: reloader, namespace: namespace, podName: podName, initComplete: make(chan struct{}), @@ -221,35 +249,6 @@ func newDaprRuntime(ctx context.Context, } close(rt.isAppHealthy) - if globalConfig.IsFeatureEnabled(config.HotReload) { - log.Info("Hot reloading enabled. Daprd will reload 'Component' resources on change.") - switch runtimeConfig.mode { - case modes.KubernetesMode: - rt.reloader = hotreload.NewOperator(hotreload.OptionsReloaderOperator{ - PodName: podName, - Namespace: namespace, - Client: operatorClient, - ComponentStore: compStore, - Authorizer: authz, - Processor: processor, - }) - case modes.StandaloneMode: - rt.reloader, err = hotreload.NewDisk(hotreload.OptionsReloaderDisk{ - Dirs: runtimeConfig.standalone.ResourcesPath, - ComponentStore: compStore, - Authorizer: authz, - Processor: processor, - }) - if err != nil { - return nil, fmt.Errorf("failed to create hot reload disk reloader: %w", err) - } - default: - return nil, fmt.Errorf("invalid mode: %s", runtimeConfig.mode) - } - } else { - log.Debug("Hot reloading disabled") - } - var gracePeriod *time.Duration if duration := runtimeConfig.gracefulShutdownDuration; duration > 0 { gracePeriod = &duration @@ -286,6 +285,9 @@ func newDaprRuntime(ctx context.Context, if err := rt.runnerCloser.Add(rt.reloader.Run); err != nil { return nil, err } + if err := rt.runnerCloser.AddCloser(rt.reloader); err != nil { + return nil, err + } } if err := rt.runnerCloser.AddCloser( @@ -999,7 +1001,7 @@ func (a *DaprRuntime) loadComponents(ctx context.Context) error { } log.Info("Loading components…") - comps, err := loader.Load() + comps, err := loader.LoadComponents() if err != nil { return err } diff --git a/tests/apps/resiliencyapp/go.mod b/tests/apps/resiliencyapp/go.mod index ee5bd6d8c71..73976cd3c08 100644 --- a/tests/apps/resiliencyapp/go.mod +++ b/tests/apps/resiliencyapp/go.mod @@ -7,7 +7,7 @@ require ( github.com/gorilla/mux v1.8.1 google.golang.org/grpc v1.60.1 google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20 - google.golang.org/protobuf v1.33.0 + google.golang.org/protobuf v1.32.0 ) require ( @@ -15,8 +15,8 @@ require ( github.com/google/uuid v1.6.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sys v0.17.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect ) diff --git a/tests/apps/resiliencyapp/go.sum b/tests/apps/resiliencyapp/go.sum index 95cb7b8254c..7e0db00039c 100644 --- a/tests/apps/resiliencyapp/go.sum +++ b/tests/apps/resiliencyapp/go.sum @@ -20,10 +20,10 @@ go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8 go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -35,7 +35,7 @@ google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20 h1:MLBCGN1O7G google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20/go.mod h1:Nr5H8+MlGWr5+xX/STzdoEqJrO+YteqFbMyCsrb6mH0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/tests/apps/resiliencyapp_grpc/go.mod b/tests/apps/resiliencyapp_grpc/go.mod index ef30c21cdc1..2eaef73b1be 100644 --- a/tests/apps/resiliencyapp_grpc/go.mod +++ b/tests/apps/resiliencyapp_grpc/go.mod @@ -6,15 +6,15 @@ require ( github.com/dapr/dapr v1.7.4 google.golang.org/grpc v1.60.1 google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20 - google.golang.org/protobuf v1.33.0 + google.golang.org/protobuf v1.32.0 ) require ( github.com/golang/protobuf v1.5.3 // indirect go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sys v0.17.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect ) diff --git a/tests/apps/resiliencyapp_grpc/go.sum b/tests/apps/resiliencyapp_grpc/go.sum index e8372ceddb6..e620d39920c 100644 --- a/tests/apps/resiliencyapp_grpc/go.sum +++ b/tests/apps/resiliencyapp_grpc/go.sum @@ -16,10 +16,10 @@ go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8 go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -31,7 +31,7 @@ google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20 h1:MLBCGN1O7G google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20/go.mod h1:Nr5H8+MlGWr5+xX/STzdoEqJrO+YteqFbMyCsrb6mH0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/tests/apps/service_invocation_grpc_proxy_client/go.mod b/tests/apps/service_invocation_grpc_proxy_client/go.mod index ac165137380..7887be2ded4 100644 --- a/tests/apps/service_invocation_grpc_proxy_client/go.mod +++ b/tests/apps/service_invocation_grpc_proxy_client/go.mod @@ -14,11 +14,11 @@ require ( github.com/google/uuid v1.6.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sys v0.17.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/protobuf v1.32.0 // indirect ) replace github.com/dapr/dapr => ../../../ diff --git a/tests/apps/service_invocation_grpc_proxy_client/go.sum b/tests/apps/service_invocation_grpc_proxy_client/go.sum index 95cb7b8254c..7e0db00039c 100644 --- a/tests/apps/service_invocation_grpc_proxy_client/go.sum +++ b/tests/apps/service_invocation_grpc_proxy_client/go.sum @@ -20,10 +20,10 @@ go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8 go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -35,7 +35,7 @@ google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20 h1:MLBCGN1O7G google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20/go.mod h1:Nr5H8+MlGWr5+xX/STzdoEqJrO+YteqFbMyCsrb6mH0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/tests/e2e/pubsub/pubsub_test.go b/tests/e2e/pubsub/pubsub_test.go index dedd528c397..c9b54814309 100644 --- a/tests/e2e/pubsub/pubsub_test.go +++ b/tests/e2e/pubsub/pubsub_test.go @@ -278,7 +278,12 @@ func testPublish(t *testing.T, publisherExternalURL string, protocol string) rec require.NoError(t, err) offset += numberOfMessagesToPublish + 1 - sentTopicAMessages, err := sendToPublisher(t, publisherExternalURL, "pubsub-a-topic", protocol, nil, "") + // Test bug where content-length metadata conflict makes message undeliverable in grpc subscriber. + // We set an arbitrarily large number that it is unlikely to match the size of the payload daprd delivers. + metadataContentLengthConflict := map[string]string{ + "content-length": "9999999", + } + sentTopicAMessages, err := sendToPublisher(t, publisherExternalURL, "pubsub-a-topic", protocol, metadataContentLengthConflict, "") require.NoError(t, err) offset += numberOfMessagesToPublish + 1 @@ -290,10 +295,10 @@ func testPublish(t *testing.T, publisherExternalURL string, protocol string) rec require.NoError(t, err) offset += numberOfMessagesToPublish + 1 - metadata := map[string]string{ + metadataRawPayload := map[string]string{ "rawPayload": "true", } - sentTopicRawMessages, err := sendToPublisher(t, publisherExternalURL, "pubsub-raw-topic", protocol, metadata, "") + sentTopicRawMessages, err := sendToPublisher(t, publisherExternalURL, "pubsub-raw-topic", protocol, metadataRawPayload, "") require.NoError(t, err) offset += numberOfMessagesToPublish + 1 diff --git a/tests/integration/framework/process/daprd/daprd.go b/tests/integration/framework/process/daprd/daprd.go index 8e6960f7c2a..c8518b4493d 100644 --- a/tests/integration/framework/process/daprd/daprd.go +++ b/tests/integration/framework/process/daprd/daprd.go @@ -15,7 +15,6 @@ package daprd import ( "context" - "encoding/json" "fmt" "net" "net/http" @@ -42,10 +41,9 @@ import ( ) type Daprd struct { - exec process.Interface - appHTTP process.Interface - freeport *util.FreePort - httpClient *http.Client + exec process.Interface + appHTTP process.Interface + freeport *util.FreePort appID string namespace string @@ -150,7 +148,6 @@ func New(t *testing.T, fopts ...Option) *Daprd { return &Daprd{ exec: exec.New(t, binary.EnvValue("daprd"), args, opts.execOpts...), freeport: fp, - httpClient: util.HTTPClient(t), appHTTP: appHTTP, appID: opts.appID, namespace: ns, @@ -185,7 +182,7 @@ func (d *Daprd) WaitUntilTCPReady(t *testing.T, ctx context.Context) { } net.Close() return true - }, 10*time.Second, 10*time.Millisecond) + }, 10*time.Second, 100*time.Millisecond) } func (d *Daprd) WaitUntilRunning(t *testing.T, ctx context.Context) { @@ -201,7 +198,7 @@ func (d *Daprd) WaitUntilRunning(t *testing.T, ctx context.Context) { } defer resp.Body.Close() return http.StatusNoContent == resp.StatusCode - }, 10*time.Second, 10*time.Millisecond) + }, 10*time.Second, 100*time.Millisecond) } func (d *Daprd) WaitUntilAppHealth(t *testing.T, ctx context.Context) { @@ -219,7 +216,7 @@ func (d *Daprd) WaitUntilAppHealth(t *testing.T, ctx context.Context) { } defer resp.Body.Close() return http.StatusNoContent == resp.StatusCode - }, 10*time.Second, 10*time.Millisecond) + }, 10*time.Second, 100*time.Millisecond) case "grpc": assert.Eventually(t, func() bool { @@ -237,12 +234,12 @@ func (d *Daprd) WaitUntilAppHealth(t *testing.T, ctx context.Context) { out := rtv1.HealthCheckResponse{} err = conn.Invoke(ctx, "/dapr.proto.runtime.v1.AppCallbackHealthCheck/HealthCheck", &in, &out) return err == nil - }, 10*time.Second, 10*time.Millisecond) + }, 10*time.Second, 100*time.Millisecond) } } func (d *Daprd) GRPCConn(t *testing.T, ctx context.Context) *grpc.ClientConn { - conn, err := grpc.DialContext(ctx, d.GRPCAddress(), + conn, err := grpc.DialContext(ctx, fmt.Sprintf("127.0.0.1:%d", d.GRPCPort()), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock(), ) @@ -256,26 +253,6 @@ func (d *Daprd) GRPCClient(t *testing.T, ctx context.Context) rtv1.DaprClient { return rtv1.NewDaprClient(d.GRPCConn(t, ctx)) } -//nolint:testifylint -func (d *Daprd) RegistedComponents(t *assert.CollectT, ctx context.Context) []*rtv1.RegisteredComponents { - url := fmt.Sprintf("http://%s/v1.0/metadata", d.HTTPAddress()) - req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) - if !assert.NoError(t, err) { - return nil - } - - var meta struct { - Components []*rtv1.RegisteredComponents - } - resp, err := d.httpClient.Do(req) - if assert.NoError(t, err) { - defer resp.Body.Close() - assert.NoError(t, json.NewDecoder(resp.Body).Decode(&meta)) - } - - return meta.Components -} - func (d *Daprd) AppID() string { return d.appID } diff --git a/tests/integration/framework/process/daprd/options.go b/tests/integration/framework/process/daprd/options.go index d6b39a5356f..cf76a091de1 100644 --- a/tests/integration/framework/process/daprd/options.go +++ b/tests/integration/framework/process/daprd/options.go @@ -14,12 +14,7 @@ limitations under the License. package daprd import ( - "testing" - - "github.com/stretchr/testify/require" - "github.com/dapr/dapr/tests/integration/framework/process/exec" - "github.com/dapr/dapr/tests/integration/framework/process/logline" ) // Option is a function that configures the dapr process. @@ -59,7 +54,7 @@ type options struct { func WithExecOptions(execOptions ...exec.Option) Option { return func(o *options) { - o.execOpts = append(o.execOpts, execOptions...) + o.execOpts = execOptions } } @@ -75,19 +70,6 @@ func WithNamespace(namespace string) Option { } } -func WithLogLineStdout(ll *logline.LogLine) Option { - return WithExecOptions(exec.WithStdout(ll.Stdout())) -} - -func WithExit1() Option { - return WithExecOptions( - exec.WithExitCode(1), - exec.WithRunError(func(t *testing.T, err error) { - require.ErrorContains(t, err, "exit status 1") - }), - ) -} - func WithAppPort(port int) Option { return func(o *options) { o.appPort = port diff --git a/tests/integration/framework/process/grpc/subscriber/options.go b/tests/integration/framework/process/grpc/subscriber/options.go deleted file mode 100644 index e7f9d4b82a2..00000000000 --- a/tests/integration/framework/process/grpc/subscriber/options.go +++ /dev/null @@ -1,17 +0,0 @@ -/* -Copyright 2024 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 subscriber - -// options contains the options for running a pubsub subscriber gRPC server app. -type options struct{} diff --git a/tests/integration/framework/process/grpc/subscriber/subscriber.go b/tests/integration/framework/process/grpc/subscriber/subscriber.go deleted file mode 100644 index a98c81c26e0..00000000000 --- a/tests/integration/framework/process/grpc/subscriber/subscriber.go +++ /dev/null @@ -1,119 +0,0 @@ -/* -Copyright 2024 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 subscriber - -import ( - "context" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - rtv1 "github.com/dapr/dapr/pkg/proto/runtime/v1" - "github.com/dapr/dapr/tests/integration/framework/process/daprd" - "github.com/dapr/dapr/tests/integration/framework/process/grpc/app" -) - -type Option func(*options) - -type Subscriber struct { - app *app.App - inCh chan *rtv1.TopicEventRequest - closeCh chan struct{} -} - -func New(t *testing.T, fopts ...Option) *Subscriber { - t.Helper() - - var opts options - for _, fopt := range fopts { - fopt(&opts) - } - - inCh := make(chan *rtv1.TopicEventRequest, 100) - closeCh := make(chan struct{}) - - return &Subscriber{ - inCh: inCh, - closeCh: closeCh, - app: app.New(t, - app.WithOnTopicEventFn(func(ctx context.Context, in *rtv1.TopicEventRequest) (*rtv1.TopicEventResponse, error) { - select { - case inCh <- in: - case <-ctx.Done(): - case <-closeCh: - } - return new(rtv1.TopicEventResponse), nil - }), - ), - } -} - -func (s *Subscriber) Run(t *testing.T, ctx context.Context) { - t.Helper() - s.app.Run(t, ctx) -} - -func (s *Subscriber) Cleanup(t *testing.T) { - t.Helper() - close(s.closeCh) - s.app.Cleanup(t) -} - -func (s *Subscriber) Port(t *testing.T) int { - t.Helper() - return s.app.Port(t) -} - -func (s *Subscriber) Receive(t *testing.T, ctx context.Context) *rtv1.TopicEventRequest { - t.Helper() - - ctx, cancel := context.WithTimeout(ctx, time.Second) - defer cancel() - - select { - case <-ctx.Done(): - require.Fail(t, "timed out waiting for event response") - return nil - case in := <-s.inCh: - return in - } -} - -func (s *Subscriber) AssertEventChanLen(t *testing.T, l int) { - t.Helper() - assert.Len(t, s.inCh, l) -} - -func (s *Subscriber) ExpectPublishReceive(t *testing.T, ctx context.Context, daprd *daprd.Daprd, req *rtv1.PublishEventRequest) { - t.Helper() - _, err := daprd.GRPCClient(t, ctx).PublishEvent(ctx, req) - require.NoError(t, err) - s.Receive(t, ctx) - s.AssertEventChanLen(t, 0) -} - -func (s *Subscriber) ExpectPublishError(t *testing.T, ctx context.Context, daprd *daprd.Daprd, req *rtv1.PublishEventRequest) { - t.Helper() - _, err := daprd.GRPCClient(t, ctx).PublishEvent(ctx, req) - require.Error(t, err) -} - -func (s *Subscriber) ExpectPublishNoReceive(t *testing.T, ctx context.Context, daprd *daprd.Daprd, req *rtv1.PublishEventRequest) { - t.Helper() - _, err := daprd.GRPCClient(t, ctx).PublishEvent(ctx, req) - require.NoError(t, err) - s.AssertEventChanLen(t, 0) -} diff --git a/tests/integration/framework/process/http/app/app.go b/tests/integration/framework/process/http/app/app.go deleted file mode 100644 index ffe85f3dd21..00000000000 --- a/tests/integration/framework/process/http/app/app.go +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright 2024 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 app - -import ( - "context" - nethttp "net/http" - "sync/atomic" - "testing" - - "github.com/dapr/dapr/tests/integration/framework/process/http" -) - -type Option func(*options) - -type App struct { - http *http.HTTP - healthz *atomic.Bool -} - -func New(t *testing.T, fopts ...Option) *App { - t.Helper() - - opts := options{ - subscribe: "[]", - config: "{}", - initialHealth: true, - } - for _, fopt := range fopts { - fopt(&opts) - } - - var healthz atomic.Bool - healthz.Store(opts.initialHealth) - - httpopts := []http.Option{ - http.WithHandlerFunc("/dapr/config", func(w nethttp.ResponseWriter, r *nethttp.Request) { - w.Write([]byte(opts.config)) - }), - http.WithHandlerFunc("/dapr/subscribe", func(w nethttp.ResponseWriter, r *nethttp.Request) { - w.Write([]byte(opts.subscribe)) - }), - http.WithHandlerFunc("/healthz", func(w nethttp.ResponseWriter, r *nethttp.Request) { - if healthz.Load() { - w.WriteHeader(nethttp.StatusOK) - } else { - w.WriteHeader(nethttp.StatusServiceUnavailable) - } - }), - } - httpopts = append(httpopts, opts.handlerFuncs...) - - return &App{ - http: http.New(t, httpopts...), - healthz: &healthz, - } -} - -func (a *App) Run(t *testing.T, ctx context.Context) { - a.http.Run(t, ctx) -} - -func (a *App) Cleanup(t *testing.T) { - a.http.Cleanup(t) -} - -func (a *App) Port() int { - return a.http.Port() -} diff --git a/tests/integration/framework/process/http/app/options.go b/tests/integration/framework/process/http/app/options.go deleted file mode 100644 index ad3d1af6b1a..00000000000 --- a/tests/integration/framework/process/http/app/options.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright 2024 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 app - -import ( - nethttp "net/http" - - "github.com/dapr/dapr/tests/integration/framework/process/http" -) - -type options struct { - subscribe string - config string - initialHealth bool - handlerFuncs []http.Option -} - -func WithSubscribe(subscribe string) Option { - return func(o *options) { - o.subscribe = subscribe - } -} - -func WithConfig(config string) Option { - return func(o *options) { - o.config = config - } -} - -func WithHandlerFunc(path string, fn nethttp.HandlerFunc) Option { - return func(o *options) { - o.handlerFuncs = append(o.handlerFuncs, http.WithHandlerFunc(path, fn)) - } -} - -func WithInitialHealth(initialHealth bool) Option { - return func(o *options) { - o.initialHealth = initialHealth - } -} diff --git a/tests/integration/framework/process/http/subscriber/options.go b/tests/integration/framework/process/http/subscriber/options.go deleted file mode 100644 index 70be0733b6f..00000000000 --- a/tests/integration/framework/process/http/subscriber/options.go +++ /dev/null @@ -1,44 +0,0 @@ -/* -Copyright 2024 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 subscriber - -import ( - "net/http" - - "github.com/dapr/dapr/tests/integration/framework/process/http/app" -) - -type options struct { - routes []string - bulkRoutes []string - handlerFuncs []app.Option -} - -func WithRoutes(routes ...string) Option { - return func(o *options) { - o.routes = append(o.routes, routes...) - } -} - -func WithBulkRoutes(routes ...string) Option { - return func(o *options) { - o.bulkRoutes = append(o.bulkRoutes, routes...) - } -} - -func WithHandlerFunc(path string, fn http.HandlerFunc) Option { - return func(o *options) { - o.handlerFuncs = append(o.handlerFuncs, app.WithHandlerFunc(path, fn)) - } -} diff --git a/tests/integration/framework/process/http/subscriber/subscriber.go b/tests/integration/framework/process/http/subscriber/subscriber.go deleted file mode 100644 index a1faa7938ba..00000000000 --- a/tests/integration/framework/process/http/subscriber/subscriber.go +++ /dev/null @@ -1,166 +0,0 @@ -/* -Copyright 2024 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 subscriber - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "strings" - "testing" - "time" - - "github.com/cloudevents/sdk-go/v2/event" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/dapr/dapr/tests/integration/framework/process/daprd" - "github.com/dapr/dapr/tests/integration/framework/process/http/app" - "github.com/dapr/dapr/tests/integration/framework/util" -) - -type Option func(*options) - -type RouteEvent struct { - Route string - *event.Event -} - -type PublishRequest struct { - Daprd *daprd.Daprd - PubSubName string - Topic string - Data string - DataContentType *string -} - -type Subscriber struct { - app *app.App - client *http.Client - inCh chan *RouteEvent - closeCh chan struct{} -} - -func New(t *testing.T, fopts ...Option) *Subscriber { - t.Helper() - - var opts options - for _, fopt := range fopts { - fopt(&opts) - } - - inCh := make(chan *RouteEvent, 100) - closeCh := make(chan struct{}) - - appOpts := make([]app.Option, 0, len(opts.routes)+len(opts.handlerFuncs)) - for _, route := range opts.routes { - appOpts = append(appOpts, app.WithHandlerFunc(route, func(w http.ResponseWriter, r *http.Request) { - var ce event.Event - require.NoError(t, json.NewDecoder(r.Body).Decode(&ce)) - select { - case inCh <- &RouteEvent{Route: r.URL.Path, Event: &ce}: - case <-closeCh: - case <-r.Context().Done(): - } - })) - } - - appOpts = append(appOpts, opts.handlerFuncs...) - - return &Subscriber{ - app: app.New(t, appOpts...), - client: util.HTTPClient(t), - inCh: inCh, - closeCh: closeCh, - } -} - -func (s *Subscriber) Run(t *testing.T, ctx context.Context) { - t.Helper() - s.app.Run(t, ctx) -} - -func (s *Subscriber) Cleanup(t *testing.T) { - t.Helper() - close(s.closeCh) - s.app.Cleanup(t) -} - -func (s *Subscriber) Port() int { - return s.app.Port() -} - -func (s *Subscriber) Receive(t *testing.T, ctx context.Context) *RouteEvent { - t.Helper() - - ctx, cancel := context.WithTimeout(ctx, time.Second) - defer cancel() - - select { - case <-ctx.Done(): - require.Fail(t, "timed out waiting for event response") - return nil - case in := <-s.inCh: - return in - } -} - -func (s *Subscriber) AssertEventChanLen(t *testing.T, l int) { - t.Helper() - assert.Len(t, s.inCh, l) -} - -func (s *Subscriber) ExpectPublishReceive(t *testing.T, ctx context.Context, req PublishRequest) { - t.Helper() - - s.Publish(t, ctx, req) - s.Receive(t, ctx) - s.AssertEventChanLen(t, 0) -} - -func (s *Subscriber) ExpectPublishError(t *testing.T, ctx context.Context, req PublishRequest) { - t.Helper() - //nolint:bodyclose - resp := s.publish(t, ctx, req) - require.Equal(t, http.StatusNotFound, resp.StatusCode) - s.AssertEventChanLen(t, 0) -} - -func (s *Subscriber) ExpectPublishNoReceive(t *testing.T, ctx context.Context, req PublishRequest) { - t.Helper() - s.Publish(t, ctx, req) - s.AssertEventChanLen(t, 0) -} - -func (s *Subscriber) Publish(t *testing.T, ctx context.Context, req PublishRequest) { - t.Helper() - //nolint:bodyclose - resp := s.publish(t, ctx, req) - require.Equal(t, http.StatusNoContent, resp.StatusCode) -} - -func (s *Subscriber) publish(t *testing.T, ctx context.Context, req PublishRequest) *http.Response { - t.Helper() - reqURL := fmt.Sprintf("http://%s/v1.0/publish/%s/%s", req.Daprd.HTTPAddress(), req.PubSubName, req.Topic) - hreq, err := http.NewRequestWithContext(ctx, http.MethodPost, reqURL, strings.NewReader(req.Data)) - require.NoError(t, err) - if req.DataContentType != nil { - hreq.Header.Add("Content-Type", *req.DataContentType) - } - resp, err := s.client.Do(hreq) - require.NoError(t, err) - require.NoError(t, resp.Body.Close()) - return resp -} diff --git a/tests/integration/framework/process/logline/logline.go b/tests/integration/framework/process/logline/logline.go index c7ad34fb9d6..924c13ca127 100644 --- a/tests/integration/framework/process/logline/logline.go +++ b/tests/integration/framework/process/logline/logline.go @@ -155,5 +155,5 @@ func (l *LogLine) Stderr() io.WriteCloser { } func (l *LogLine) EventuallyFoundAll(t *testing.T) { - assert.Eventually(t, l.FoundAll, time.Second*7, time.Millisecond*10) + assert.Eventually(t, l.FoundAll, time.Second*20, time.Millisecond*100) } diff --git a/tests/integration/framework/process/operator/operator.go b/tests/integration/framework/process/operator/operator.go index 02edaeb0491..c1f5a50df94 100644 --- a/tests/integration/framework/process/operator/operator.go +++ b/tests/integration/framework/process/operator/operator.go @@ -121,7 +121,7 @@ func (o *Operator) WaitUntilRunning(t *testing.T, ctx context.Context) { } defer resp.Body.Close() return http.StatusOK == resp.StatusCode - }, time.Second*5, 10*time.Millisecond) + }, time.Second*5, 100*time.Millisecond) } func (o *Operator) Port() int { diff --git a/tests/integration/framework/process/placement/options.go b/tests/integration/framework/process/placement/options.go index cb0f21ceef6..d64380856ac 100644 --- a/tests/integration/framework/process/placement/options.go +++ b/tests/integration/framework/process/placement/options.go @@ -32,8 +32,8 @@ type options struct { tlsEnabled bool sentryAddress *string trustAnchorsFile *string - maxAPILevel *int - minAPILevel *int + maxAPILevel int + minAPILevel int metadataEnabled bool } @@ -105,13 +105,13 @@ func WithInitialClusterPorts(ports ...int) Option { func WithMaxAPILevel(val int) Option { return func(o *options) { - o.maxAPILevel = &val + o.maxAPILevel = val } } func WithMinAPILevel(val int) Option { return func(o *options) { - o.minAPILevel = &val + o.minAPILevel = val } } diff --git a/tests/integration/framework/process/placement/placement.go b/tests/integration/framework/process/placement/placement.go index 4b4b79ff96b..3f1ece8a8af 100644 --- a/tests/integration/framework/process/placement/placement.go +++ b/tests/integration/framework/process/placement/placement.go @@ -25,8 +25,6 @@ import ( "testing" "time" - "google.golang.org/grpc/metadata" - "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -70,6 +68,8 @@ func New(t *testing.T, fopts ...Option) *Placement { metricsPort: fp.Port(t, 2), initialCluster: uid.String() + "=127.0.0.1:" + strconv.Itoa(fp.Port(t, 3)), initialClusterPorts: []int{fp.Port(t, 3)}, + maxAPILevel: -1, + minAPILevel: 0, metadataEnabled: false, } @@ -85,14 +85,10 @@ func New(t *testing.T, fopts ...Option) *Placement { "--metrics-port=" + strconv.Itoa(opts.metricsPort), "--initial-cluster=" + opts.initialCluster, "--tls-enabled=" + strconv.FormatBool(opts.tlsEnabled), + "--max-api-level=" + strconv.Itoa(opts.maxAPILevel), + "--min-api-level=" + strconv.Itoa(opts.minAPILevel), "--metadata-enabled=" + strconv.FormatBool(opts.metadataEnabled), } - if opts.maxAPILevel != nil { - args = append(args, "--max-api-level="+strconv.Itoa(*opts.maxAPILevel)) - } - if opts.minAPILevel != nil { - args = append(args, "--min-api-level="+strconv.Itoa(*opts.minAPILevel)) - } if opts.sentryAddress != nil { args = append(args, "--sentry-address="+*opts.sentryAddress) } @@ -142,7 +138,7 @@ func (p *Placement) WaitUntilRunning(t *testing.T, ctx context.Context) { } defer resp.Body.Close() return http.StatusOK == resp.StatusCode - }, time.Second*5, 10*time.Millisecond) + }, time.Second*5, 100*time.Millisecond) } func (p *Placement) ID() string { @@ -177,7 +173,7 @@ func (p *Placement) CurrentActorsAPILevel() int { return 20 // Defined in pkg/actors/internal/api_level.go } -func (p *Placement) RegisterHostWithMetadata(t *testing.T, parentCtx context.Context, msg *placementv1pb.Host, contextMetadata map[string]string) chan *placementv1pb.PlacementTables { +func (p *Placement) RegisterHost(t *testing.T, parentCtx context.Context, msg *placementv1pb.Host) chan *placementv1pb.PlacementTables { conn, err := grpc.DialContext(parentCtx, p.Address(), grpc.WithBlock(), grpc.WithTransportCredentials(insecure.NewCredentials()), @@ -185,10 +181,6 @@ func (p *Placement) RegisterHostWithMetadata(t *testing.T, parentCtx context.Con require.NoError(t, err) client := placementv1pb.NewPlacementClient(conn) - for k, v := range contextMetadata { - parentCtx = metadata.AppendToOutgoingContext(parentCtx, k, v) - } - var stream placementv1pb.Placement_ReportDaprStatusClient require.EventuallyWithT(t, func(c *assert.CollectT) { stream, err = client.ReportDaprStatus(parentCtx) @@ -209,7 +201,7 @@ func (p *Placement) RegisterHostWithMetadata(t *testing.T, parentCtx context.Con _ = stream.CloseSend() return } - }, time.Second*15, time.Millisecond*10) + }, time.Second*15, time.Millisecond*100) doneCh := make(chan error) placementUpdateCh := make(chan *placementv1pb.PlacementTables) @@ -256,7 +248,7 @@ func (p *Placement) RegisterHostWithMetadata(t *testing.T, parentCtx context.Con if in.GetOperation() == "update" { tables := in.GetTables() - require.NotEmptyf(t, tables, "Placement table is empty") + require.NotEmptyf(t, tables, "Placement tables is empty") select { case placementUpdateCh <- tables: @@ -269,12 +261,6 @@ func (p *Placement) RegisterHostWithMetadata(t *testing.T, parentCtx context.Con return placementUpdateCh } -// RegisterHost Registers a host with the placement service using default context metadata -func (p *Placement) RegisterHost(t *testing.T, ctx context.Context, msg *placementv1pb.Host) chan *placementv1pb.PlacementTables { - ctx = metadata.AppendToOutgoingContext(ctx, "dapr-accept-vnodes", "false") - return p.RegisterHostWithMetadata(t, ctx, msg, nil) -} - // AssertRegisterHostFails Expect the registration to fail with FailedPrecondition. func (p *Placement) AssertRegisterHostFails(t *testing.T, ctx context.Context, apiLevel int) { msg := &placementv1pb.Host{ diff --git a/tests/integration/framework/process/sentry/sentry.go b/tests/integration/framework/process/sentry/sentry.go index f201316b494..a134aa6c31e 100644 --- a/tests/integration/framework/process/sentry/sentry.go +++ b/tests/integration/framework/process/sentry/sentry.go @@ -160,7 +160,7 @@ func (s *Sentry) WaitUntilRunning(t *testing.T, ctx context.Context) { defer resp.Body.Close() assert.Equal(c, http.StatusOK, resp.StatusCode) } - }, time.Second*20, 10*time.Millisecond) + }, time.Second*20, 100*time.Millisecond) } func (s *Sentry) TrustAnchorsFile(t *testing.T) string { diff --git a/tests/integration/framework/process/statestore/statestore.go b/tests/integration/framework/process/statestore/statestore.go index 35bf88ff5e3..eead420dac1 100644 --- a/tests/integration/framework/process/statestore/statestore.go +++ b/tests/integration/framework/process/statestore/statestore.go @@ -103,7 +103,7 @@ func (s *StateStore) Run(t *testing.T, ctx context.Context) { _, err = client.Ping(ctx, new(compv1pb.PingRequest)) //nolint:testifylint assert.NoError(c, err) - }, 10*time.Second, 10*time.Millisecond) + }, 10*time.Second, 100*time.Millisecond) require.NoError(t, conn.Close()) } diff --git a/tests/integration/suite/actors/grpc/ttl.go b/tests/integration/suite/actors/grpc/ttl.go index 1d151f9c123..5092ee3f6cc 100644 --- a/tests/integration/suite/actors/grpc/ttl.go +++ b/tests/integration/suite/actors/grpc/ttl.go @@ -100,7 +100,7 @@ func (l *ttl) Run(t *testing.T, ctx context.Context) { }) //nolint:testifylint assert.NoError(c, err) - }, time.Second*20, time.Millisecond*10, "actor not ready") + }, time.Second*20, time.Millisecond*100, "actor not ready") now := time.Now() @@ -174,6 +174,6 @@ func (l *ttl) Run(t *testing.T, ctx context.Context) { require.NoError(c, err) assert.Empty(c, resp.GetData()) assert.Empty(c, resp.GetMetadata()) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) }) } diff --git a/tests/integration/suite/actors/healthz/deactivate-on-placement-fail.go b/tests/integration/suite/actors/healthz/deactivate-on-placement-fail.go index 4d2c12c3f26..f14a4ee2f63 100644 --- a/tests/integration/suite/actors/healthz/deactivate-on-placement-fail.go +++ b/tests/integration/suite/actors/healthz/deactivate-on-placement-fail.go @@ -113,7 +113,7 @@ func (h *deactivateOnPlacementFail) Run(t *testing.T, ctx context.Context) { body, err := io.ReadAll(resp.Body) require.NoError(t, err) assert.Equalf(t, http.StatusOK, resp.StatusCode, "Response body: %v", string(body)) - }, 10*time.Second, 10*time.Millisecond, "actor not ready") + }, 10*time.Second, 100*time.Millisecond, "actor not ready") } // Validate invocations diff --git a/tests/integration/suite/actors/healthz/endpoint/allenabled.go b/tests/integration/suite/actors/healthz/endpoint/allenabled.go index 0d2bdd88afd..de293720cb4 100644 --- a/tests/integration/suite/actors/healthz/endpoint/allenabled.go +++ b/tests/integration/suite/actors/healthz/endpoint/allenabled.go @@ -103,7 +103,7 @@ func (a *allenabled) Run(t *testing.T, ctx context.Context) { assert.Len(c, meta.GetActorRuntime().GetActiveActors(), 1) assert.Equal(c, rtv1.ActorRuntime_RUNNING, meta.GetActorRuntime().GetRuntimeStatus()) assert.Equal(c, "placement: connected", meta.GetActorRuntime().GetPlacement()) - }, time.Second*30, time.Millisecond*10) + }, time.Second*30, time.Millisecond*100) select { case <-a.healthzCalled: diff --git a/tests/integration/suite/actors/healthz/endpoint/noapp.go b/tests/integration/suite/actors/healthz/endpoint/noapp.go index 24008674da8..95884875aba 100644 --- a/tests/integration/suite/actors/healthz/endpoint/noapp.go +++ b/tests/integration/suite/actors/healthz/endpoint/noapp.go @@ -98,7 +98,7 @@ func (n *noapp) Run(t *testing.T, ctx context.Context) { assert.Len(c, meta.GetActorRuntime().GetActiveActors(), 1) assert.Equal(c, rtv1.ActorRuntime_RUNNING, meta.GetActorRuntime().GetRuntimeStatus()) assert.Equal(c, "placement: connected", meta.GetActorRuntime().GetPlacement()) - }, time.Second*30, time.Millisecond*10) + }, time.Second*30, time.Millisecond*100) select { case <-n.healthzCalled: diff --git a/tests/integration/suite/actors/healthz/endpoint/noappentities.go b/tests/integration/suite/actors/healthz/endpoint/noappentities.go index f3ccfd0e9be..e90e26716aa 100644 --- a/tests/integration/suite/actors/healthz/endpoint/noappentities.go +++ b/tests/integration/suite/actors/healthz/endpoint/noappentities.go @@ -120,7 +120,7 @@ func (n *noappentities) Run(t *testing.T, ctx context.Context) { assert.Equal(c, tv.activeActors, meta.GetActorRuntime().GetActiveActors()) assert.Equal(c, rtv1.ActorRuntime_RUNNING, meta.GetActorRuntime().GetRuntimeStatus()) assert.Equal(c, "placement: connected", meta.GetActorRuntime().GetPlacement()) - }, time.Second*30, time.Millisecond*10) + }, time.Second*30, time.Millisecond*100) } select { diff --git a/tests/integration/suite/actors/healthz/endpoint/noentities.go b/tests/integration/suite/actors/healthz/endpoint/noentities.go index 4bd257efe62..ad3f39fa07c 100644 --- a/tests/integration/suite/actors/healthz/endpoint/noentities.go +++ b/tests/integration/suite/actors/healthz/endpoint/noentities.go @@ -114,7 +114,7 @@ func (n *noentities) Run(t *testing.T, ctx context.Context) { assert.Equal(c, tv.activeActors, meta.GetActorRuntime().GetActiveActors()) assert.Equal(c, rtv1.ActorRuntime_RUNNING, meta.GetActorRuntime().GetRuntimeStatus()) assert.Equal(c, "placement: connected", meta.GetActorRuntime().GetPlacement()) - }, time.Second*30, time.Millisecond*10) + }, time.Second*30, time.Millisecond*100) } select { diff --git a/tests/integration/suite/actors/healthz/endpoint/path.go b/tests/integration/suite/actors/healthz/endpoint/path.go index 1a358598d56..d36ed129208 100644 --- a/tests/integration/suite/actors/healthz/endpoint/path.go +++ b/tests/integration/suite/actors/healthz/endpoint/path.go @@ -103,7 +103,7 @@ func (p *path) Run(t *testing.T, ctx context.Context) { assert.Len(c, meta.GetActorRuntime().GetActiveActors(), 1) assert.Equal(c, rtv1.ActorRuntime_RUNNING, meta.GetActorRuntime().GetRuntimeStatus()) assert.Equal(c, "placement: connected", meta.GetActorRuntime().GetPlacement()) - }, time.Second*30, time.Millisecond*10) + }, time.Second*30, time.Millisecond*100) select { case <-p.customHealthz: diff --git a/tests/integration/suite/actors/http/ttl.go b/tests/integration/suite/actors/http/ttl.go index 9d9840b8e3b..221b7760ab1 100644 --- a/tests/integration/suite/actors/http/ttl.go +++ b/tests/integration/suite/actors/http/ttl.go @@ -114,7 +114,7 @@ func (l *ttl) Run(t *testing.T, ctx context.Context) { require.NoError(c, resp.Body.Close()) assert.Equal(c, http.StatusOK, resp.StatusCode) } - }, time.Second*20, time.Millisecond*10, "actor not ready") + }, time.Second*20, time.Millisecond*100, "actor not ready") now := time.Now() @@ -181,6 +181,6 @@ func (l *ttl) Run(t *testing.T, ctx context.Context) { require.NoError(c, resp.Body.Close()) assert.Empty(c, string(body)) assert.Equal(c, http.StatusNoContent, resp.StatusCode) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) }) } diff --git a/tests/integration/suite/actors/metadata/client.go b/tests/integration/suite/actors/metadata/client.go index 5da051ccdbc..e9a21c90e3e 100644 --- a/tests/integration/suite/actors/metadata/client.go +++ b/tests/integration/suite/actors/metadata/client.go @@ -93,5 +93,5 @@ func (m *client) Run(t *testing.T, ctx context.Context) { assert.False(t, res.ActorRuntime.HostReady) assert.Equal(t, "placement: connected", res.ActorRuntime.Placement) assert.Empty(t, res.ActorRuntime.ActiveActors, 0) - }, 10*time.Second, 10*time.Millisecond) + }, 10*time.Second, 100*time.Millisecond) } diff --git a/tests/integration/suite/actors/metadata/disabled.go b/tests/integration/suite/actors/metadata/disabled.go index 19a326db2ab..d392029e72a 100644 --- a/tests/integration/suite/actors/metadata/disabled.go +++ b/tests/integration/suite/actors/metadata/disabled.go @@ -69,5 +69,5 @@ func (m *disabled) Run(t *testing.T, ctx context.Context) { assert.False(t, res.ActorRuntime.HostReady) assert.Empty(t, res.ActorRuntime.Placement) assert.Empty(t, res.ActorRuntime.ActiveActors) - }, 10*time.Second, 10*time.Millisecond) + }, 10*time.Second, 100*time.Millisecond) } diff --git a/tests/integration/suite/actors/metadata/host.go b/tests/integration/suite/actors/metadata/host.go index 799c4edb162..74bf5a9b00e 100644 --- a/tests/integration/suite/actors/metadata/host.go +++ b/tests/integration/suite/actors/metadata/host.go @@ -100,5 +100,5 @@ func (m *host) Run(t *testing.T, ctx context.Context) { assert.Equal(t, "myactortype", res.ActorRuntime.ActiveActors[0].Type) assert.Equal(t, 0, res.ActorRuntime.ActiveActors[0].Count) } - }, 10*time.Second, 10*time.Millisecond) + }, 10*time.Second, 100*time.Millisecond) } diff --git a/tests/integration/suite/actors/metadata/host_noplacement.go b/tests/integration/suite/actors/metadata/host_noplacement.go index 94190bfa792..e77ee301da2 100644 --- a/tests/integration/suite/actors/metadata/host_noplacement.go +++ b/tests/integration/suite/actors/metadata/host_noplacement.go @@ -93,5 +93,5 @@ func (m *hostNoPlacement) Run(t *testing.T, ctx context.Context) { assert.Equal(t, "myactortype", res.ActorRuntime.ActiveActors[0].Type) assert.Equal(t, 0, res.ActorRuntime.ActiveActors[0].Count) } - }, 10*time.Second, 10*time.Millisecond) + }, 10*time.Second, 100*time.Millisecond) } diff --git a/tests/integration/suite/actors/reminders/basic.go b/tests/integration/suite/actors/reminders/basic.go index 8d786985911..731a7b46b6e 100644 --- a/tests/integration/suite/actors/reminders/basic.go +++ b/tests/integration/suite/actors/reminders/basic.go @@ -92,7 +92,7 @@ func (b *basic) Run(t *testing.T, ctx context.Context) { assert.NoError(c, resp.Body.Close()) assert.Equal(c, http.StatusOK, resp.StatusCode) } - }, time.Second*10, time.Millisecond*10, "actor not ready in time") + }, time.Second*10, time.Millisecond*100, "actor not ready in time") body := `{"dueTime": "0ms"}` req, err = http.NewRequestWithContext(ctx, http.MethodPost, daprdURL+"/reminders/remindermethod", strings.NewReader(body)) @@ -105,7 +105,7 @@ func (b *basic) Run(t *testing.T, ctx context.Context) { assert.Eventually(t, func() bool { return b.methodcalled.Load() == 1 - }, time.Second*3, time.Millisecond*10) + }, time.Second*3, time.Millisecond*100) conn, err := grpc.DialContext(ctx, b.daprd.GRPCAddress(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock(), @@ -124,5 +124,5 @@ func (b *basic) Run(t *testing.T, ctx context.Context) { assert.Eventually(t, func() bool { return b.methodcalled.Load() == 2 - }, time.Second*3, time.Millisecond*10) + }, time.Second*3, time.Millisecond*100) } diff --git a/tests/integration/suite/actors/reminders/rebalancing.go b/tests/integration/suite/actors/reminders/rebalancing.go index f20d75fcba5..20628783216 100644 --- a/tests/integration/suite/actors/reminders/rebalancing.go +++ b/tests/integration/suite/actors/reminders/rebalancing.go @@ -126,7 +126,7 @@ func (i *rebalancing) Run(t *testing.T, ctx context.Context) { assert.Equal(c, http.StatusOK, resp.StatusCode) } } - }, 15*time.Second, 10*time.Millisecond, "actors not ready") + }, 15*time.Second, 100*time.Millisecond, "actors not ready") // Do a bunch of things in parallel errCh := make(chan error) @@ -371,7 +371,7 @@ func (i *rebalancing) getPlacementStream(t *testing.T, ctx context.Context) plac stream.CloseSend() stream = nil } - }, time.Second*20, time.Millisecond*10) + }, time.Second*20, time.Millisecond*100) return stream } diff --git a/tests/integration/suite/actors/reminders/serialization/common.go b/tests/integration/suite/actors/reminders/serialization/common.go index 1079bcca651..201f9f5d3b0 100644 --- a/tests/integration/suite/actors/reminders/serialization/common.go +++ b/tests/integration/suite/actors/reminders/serialization/common.go @@ -37,7 +37,7 @@ func invokeActor(t *testing.T, ctx context.Context, baseURL string, client *http assert.NoError(c, resp.Body.Close()) assert.Equal(c, http.StatusOK, resp.StatusCode) } - }, time.Second*20, time.Millisecond*10, "actor not ready in time") + }, time.Second*20, time.Millisecond*100, "actor not ready in time") } func storeReminder(t *testing.T, ctx context.Context, baseURL string, client *http.Client) { diff --git a/tests/integration/suite/actors/reminders/serialization/default.go b/tests/integration/suite/actors/reminders/serialization/default.go deleted file mode 100644 index a150321bcb8..00000000000 --- a/tests/integration/suite/actors/reminders/serialization/default.go +++ /dev/null @@ -1,92 +0,0 @@ -/* -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") -} diff --git a/tests/integration/suite/actors/reminders/serialization/json.go b/tests/integration/suite/actors/reminders/serialization/json.go index eebec11ec2f..380191c3378 100644 --- a/tests/integration/suite/actors/reminders/serialization/json.go +++ b/tests/integration/suite/actors/reminders/serialization/json.go @@ -69,6 +69,8 @@ func (j *jsonFormat) Setup(t *testing.T) []framework.Option { daprd.WithResourceFiles(j.db.GetComponent(t)), daprd.WithPlacementAddresses("127.0.0.1:"+strconv.Itoa(j.place.Port())), daprd.WithAppPort(j.srv.Port()), + // Daprd is super noisy in debug mode when connecting to placement. + daprd.WithLogLevel("info"), ) return []framework.Option{ diff --git a/tests/integration/suite/actors/reminders/serialization/protobuf.go b/tests/integration/suite/actors/reminders/serialization/protobuf.go index 2276f140c86..120d63294dd 100644 --- a/tests/integration/suite/actors/reminders/serialization/protobuf.go +++ b/tests/integration/suite/actors/reminders/serialization/protobuf.go @@ -56,7 +56,7 @@ func (p *protobufFormat) Setup(t *testing.T) []framework.Option { } // Init placement with minimum API level of 20 - p.place = placement.New(t, placement.WithMaxAPILevel(-1), placement.WithMinAPILevel(20)) + p.place = placement.New(t, placement.WithMinAPILevel(20)) // Create a SQLite database and ensure state tables exist now := time.Now().UTC().Format(time.RFC3339) @@ -77,6 +77,8 @@ INSERT INTO state VALUES daprd.WithResourceFiles(p.db.GetComponent(t)), daprd.WithPlacementAddresses("127.0.0.1:"+strconv.Itoa(p.place.Port())), daprd.WithAppPort(p.srv.Port()), + // Daprd is super noisy in debug mode when connecting to placement. + daprd.WithLogLevel("info"), ) return []framework.Option{ diff --git a/tests/integration/suite/daprd/binding/binding.go b/tests/integration/suite/daprd/binding/binding.go index 89fa60e3891..006d39a04aa 100644 --- a/tests/integration/suite/daprd/binding/binding.go +++ b/tests/integration/suite/daprd/binding/binding.go @@ -15,5 +15,4 @@ package binding import ( _ "github.com/dapr/dapr/tests/integration/suite/daprd/binding/input" - _ "github.com/dapr/dapr/tests/integration/suite/daprd/binding/output" ) diff --git a/tests/integration/suite/daprd/binding/input/appready.go b/tests/integration/suite/daprd/binding/input/appready.go index 0f2f095a698..68074e225eb 100644 --- a/tests/integration/suite/daprd/binding/input/appready.go +++ b/tests/integration/suite/daprd/binding/input/appready.go @@ -110,17 +110,17 @@ func (a *appready) Run(t *testing.T, ctx context.Context) { resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) called := a.healthCalled.Load() - require.Eventually(t, func() bool { return a.healthCalled.Load() > called }, time.Second*5, time.Millisecond*10) + require.Eventually(t, func() bool { return a.healthCalled.Load() > called }, time.Second*5, time.Millisecond*100) assert.Eventually(t, func() bool { resp, err := httpClient.Do(req) require.NoError(t, err) defer resp.Body.Close() return resp.StatusCode == http.StatusInternalServerError - }, time.Second*5, 10*time.Millisecond) + }, time.Second*5, 100*time.Millisecond) time.Sleep(time.Second * 2) assert.Equal(t, int64(0), a.bindingCalled.Load()) @@ -132,11 +132,11 @@ func (a *appready) Run(t *testing.T, ctx context.Context) { require.NoError(t, err) defer resp.Body.Close() return resp.StatusCode == http.StatusOK - }, time.Second*5, 10*time.Millisecond) + }, time.Second*5, 100*time.Millisecond) assert.Eventually(t, func() bool { return a.bindingCalled.Load() > 0 - }, time.Second*5, 10*time.Millisecond) + }, time.Second*5, 100*time.Millisecond) // Should stop calling binding when app becomes unhealthy a.appHealthy.Store(false) @@ -145,7 +145,7 @@ func (a *appready) Run(t *testing.T, ctx context.Context) { require.NoError(t, err) defer resp.Body.Close() return resp.StatusCode == http.StatusInternalServerError - }, time.Second*5, 10*time.Millisecond) + }, time.Second*5, 100*time.Millisecond) called = a.bindingCalled.Load() time.Sleep(time.Second * 2) assert.Equal(t, called, a.bindingCalled.Load()) diff --git a/tests/integration/suite/daprd/binding/output/errors.go b/tests/integration/suite/daprd/binding/output/errors.go deleted file mode 100644 index cbdf14a3c99..00000000000 --- a/tests/integration/suite/daprd/binding/output/errors.go +++ /dev/null @@ -1,100 +0,0 @@ -/* -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 implieh. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package output - -import ( - "context" - "fmt" - "net/http" - "strings" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" - grpcMetadata "google.golang.org/grpc/metadata" - - "github.com/dapr/dapr/pkg/proto/runtime/v1" - "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/util" - "github.com/dapr/dapr/tests/integration/suite" -) - -func init() { - suite.Register(new(bindingerrors)) -} - -type bindingerrors struct { - srv *prochttp.HTTP - daprd *daprd.Daprd -} - -func (b *bindingerrors) Setup(t *testing.T) []framework.Option { - mux := http.NewServeMux() - mux.HandleFunc("/error_404", func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusNotFound) - }) - - b.srv = prochttp.New(t, prochttp.WithHandler(mux)) - b.daprd = daprd.New(t, - daprd.WithResourceFiles(fmt.Sprintf(`apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: github-http-binding-404 -spec: - type: bindings.http - version: v1 - metadata: - - name: url - value: http://127.0.0.1:%d/error_404 -`, b.srv.Port()))) - - return []framework.Option{ - framework.WithProcesses(b.srv, b.daprd), - } -} - -func (b *bindingerrors) Run(t *testing.T, ctx context.Context) { - b.daprd.WaitUntilRunning(t, ctx) - - client := b.daprd.GRPCClient(t, ctx) - httpClient := util.HTTPClient(t) - - assert.Eventually(t, func() bool { - reqURL := fmt.Sprintf("http://localhost:%d/v1.0/bindings/github-http-binding-404", b.daprd.HTTPPort()) - req, err := http.NewRequestWithContext(ctx, http.MethodPost, reqURL, strings.NewReader("{\"operation\":\"get\"}")) - require.NoError(t, err) - resp, err := httpClient.Do(req) - require.NoError(t, err) - defer resp.Body.Close() - return (resp.StatusCode == http.StatusInternalServerError) && (resp.Header.Get("Metadata.statuscode") == "404") - }, time.Second*5, 10*time.Millisecond) - - assert.Eventually(t, func() bool { - req := runtime.InvokeBindingRequest{ - Name: "github-http-binding-404", - Operation: "get", - } - var header grpcMetadata.MD - resp, err := client.InvokeBinding(ctx, &req, grpc.Header(&header)) - require.Error(t, err) - require.Nil(t, resp) - statusCodeArr := header.Get("metadata.statuscode") - require.Len(t, statusCodeArr, 1) - return statusCodeArr[0] == "404" - }, time.Second*5, 10*time.Millisecond) -} diff --git a/tests/integration/suite/daprd/hotreload/operator/binding/input/grpc.go b/tests/integration/suite/daprd/hotreload/operator/binding/input/grpc.go index 655153dd9ee..7ddf46da6f1 100644 --- a/tests/integration/suite/daprd/hotreload/operator/binding/input/grpc.go +++ b/tests/integration/suite/daprd/hotreload/operator/binding/input/grpc.go @@ -152,7 +152,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) { //nolint:testifylint assert.NoError(c, err) assert.Len(c, resp.GetRegisteredComponents(), 1) - }, time.Second*20, time.Millisecond*10) + }, time.Second*20, time.Millisecond*100) g.expectBinding(t, 0, "binding1") }) @@ -184,7 +184,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) { resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.expectBindings(t, []bindingPair{ {0, "binding1"}, {1, "binding2"}, @@ -218,7 +218,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) { resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.expectBindings(t, []bindingPair{ {0, "binding1"}, {1, "binding2"}, @@ -234,7 +234,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) { resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.registered[0].Store(false) g.expectBindings(t, []bindingPair{ {1, "binding2"}, @@ -252,7 +252,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) { resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(c, err) assert.Empty(c, resp.GetRegisteredComponents()) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.registered[1].Store(false) g.registered[2].Store(false) // Sleep to ensure binding is not triggered. @@ -286,7 +286,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) { resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.expectBinding(t, 0, "binding1") }) } diff --git a/tests/integration/suite/daprd/hotreload/operator/binding/input/http.go b/tests/integration/suite/daprd/hotreload/operator/binding/input/http.go index 6f41a0f4964..9bf92a8f6fb 100644 --- a/tests/integration/suite/daprd/hotreload/operator/binding/input/http.go +++ b/tests/integration/suite/daprd/hotreload/operator/binding/input/http.go @@ -174,7 +174,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.expectBindings(t, []bindingPair{ {0, "binding1"}, {1, "binding2"}, @@ -206,7 +206,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.expectBindings(t, []bindingPair{ {0, "binding1"}, {1, "binding2"}, @@ -221,7 +221,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.registered[0].Store(false) h.expectBindings(t, []bindingPair{ {1, "binding2"}, @@ -237,7 +237,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) { h.operator.ComponentUpdateEvent(t, ctx, &api.ComponentUpdateEvent{Component: &comp2, EventType: operatorv1.ResourceEventType_DELETED}) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Empty(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort())) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.registered[1].Store(false) h.registered[2].Store(false) // Sleep to ensure binding is not triggered. @@ -269,7 +269,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.expectBinding(t, 0, "binding1") }) } diff --git a/tests/integration/suite/daprd/hotreload/operator/binding/output.go b/tests/integration/suite/daprd/hotreload/operator/binding/output.go index f83a65c9dfb..4bdf0ac4b1a 100644 --- a/tests/integration/suite/daprd/hotreload/operator/binding/output.go +++ b/tests/integration/suite/daprd/hotreload/operator/binding/output.go @@ -127,7 +127,7 @@ func (o *output) Run(t *testing.T, ctx context.Context) { o.operator.ComponentUpdateEvent(t, ctx, &api.ComponentUpdateEvent{Component: &comp, EventType: operatorv1.ResourceEventType_CREATED}) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, o.daprd.HTTPPort()), 1) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) o.postBinding(t, ctx, client, "binding1", "file1", "data1") o.postBindingFail(t, ctx, client, "binding2") o.postBindingFail(t, ctx, client, "binding3") @@ -154,7 +154,7 @@ func (o *output) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, o.daprd.HTTPPort()), 2) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) o.postBinding(t, ctx, client, "binding1", "file2", "data2") o.postBinding(t, ctx, client, "binding2", "file1", "data1") o.postBindingFail(t, ctx, client, "binding3") @@ -181,7 +181,7 @@ func (o *output) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, o.daprd.HTTPPort()), 3) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) o.postBinding(t, ctx, client, "binding1", "file3", "data3") o.postBinding(t, ctx, client, "binding2", "file2", "data2") o.postBinding(t, ctx, client, "binding3", "file1", "data1") @@ -197,7 +197,7 @@ func (o *output) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, o.daprd.HTTPPort()), 2) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) o.postBindingFail(t, ctx, client, "binding1") assert.NoFileExists(t, filepath.Join(o.bindingDir1, "file4")) @@ -216,7 +216,7 @@ func (o *output) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Empty(c, util.GetMetaComponents(c, ctx, client, o.daprd.HTTPPort())) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) o.postBindingFail(t, ctx, client, "binding1") o.postBindingFail(t, ctx, client, "binding2") o.postBindingFail(t, ctx, client, "binding3") @@ -240,7 +240,7 @@ func (o *output) Run(t *testing.T, ctx context.Context) { o.operator.ComponentUpdateEvent(t, ctx, &api.ComponentUpdateEvent{Component: &comp, EventType: operatorv1.ResourceEventType_CREATED}) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, o.daprd.HTTPPort()), 1) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) o.postBinding(t, ctx, client, "binding2", "file5", "data5") o.postBindingFail(t, ctx, client, "binding1") o.postBindingFail(t, ctx, client, "binding3") diff --git a/tests/integration/suite/daprd/hotreload/operator/crypto.go b/tests/integration/suite/daprd/hotreload/operator/crypto.go index a68176369bb..891288b89cf 100644 --- a/tests/integration/suite/daprd/hotreload/operator/crypto.go +++ b/tests/integration/suite/daprd/hotreload/operator/crypto.go @@ -131,7 +131,7 @@ func (c *crypto) Run(t *testing.T, ctx context.Context) { //nolint:testifylint assert.NoError(c, err) assert.Len(c, resp.GetRegisteredComponents(), 1) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) c.encryptDecrypt(t, ctx, client, "crypto1") c.encryptDecryptFail(t, ctx, client, "crypto2") @@ -162,7 +162,7 @@ func (c *crypto) Run(t *testing.T, ctx context.Context) { //nolint:testifylint assert.NoError(c, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) c.encryptDecrypt(t, ctx, client, "crypto1") c.encryptDecrypt(t, ctx, client, "crypto2") @@ -193,7 +193,7 @@ func (c *crypto) Run(t *testing.T, ctx context.Context) { //nolint:testifylint assert.NoError(c, err) assert.Len(c, resp.GetRegisteredComponents(), 3) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) c.encryptDecrypt(t, ctx, client, "crypto1") c.encryptDecrypt(t, ctx, client, "crypto2") @@ -224,7 +224,7 @@ func (c *crypto) Run(t *testing.T, ctx context.Context) { Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp.GetRegisteredComponents()) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) c.encryptDecrypt(t, ctx, client, "crypto1") c.encryptDecryptFail(t, ctx, client, "crypto2") @@ -241,7 +241,7 @@ func (c *crypto) Run(t *testing.T, ctx context.Context) { //nolint:testifylint assert.NoError(c, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) delComp = c.operator.Components()[0] c.operator.SetComponents(c.operator.Components()[1]) @@ -264,7 +264,7 @@ func (c *crypto) Run(t *testing.T, ctx context.Context) { Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp.GetRegisteredComponents()) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) c.encryptDecryptFail(t, ctx, client, "crypto1") c.encryptDecryptFail(t, ctx, client, "crypto2") @@ -289,7 +289,7 @@ func (c *crypto) Run(t *testing.T, ctx context.Context) { //nolint:testifylint assert.NoError(c, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) c.encryptDecryptFail(t, ctx, client, "crypto1") c.encryptDecrypt(t, ctx, client, "crypto2") diff --git a/tests/integration/suite/daprd/hotreload/operator/informer.go b/tests/integration/suite/daprd/hotreload/operator/informer.go index 1af786e1941..6305efbf675 100644 --- a/tests/integration/suite/daprd/hotreload/operator/informer.go +++ b/tests/integration/suite/daprd/hotreload/operator/informer.go @@ -136,7 +136,7 @@ func (i *informer) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, client, i.daprd.HTTPPort()), 1) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) metaComponents := util.GetMetaComponents(t, ctx, client, i.daprd.HTTPPort()) assert.ElementsMatch(t, metaComponents, []*rtv1.RegisteredComponents{ { @@ -174,7 +174,7 @@ func (i *informer) Run(t *testing.T, ctx context.Context) { Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "ACTOR"}, }, }) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) }) t.Run("deleting a component should delete the component", func(t *testing.T) { @@ -183,6 +183,6 @@ func (i *informer) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Empty(c, util.GetMetaComponents(c, ctx, client, i.daprd.HTTPPort())) - }, time.Second*20, time.Millisecond*10) + }, time.Second*20, time.Millisecond*100) }) } diff --git a/tests/integration/suite/daprd/hotreload/operator/middleware/http/app/routeralias.go b/tests/integration/suite/daprd/hotreload/operator/middleware/http/app/routeralias.go index 75e2634eced..270aa0ba23f 100644 --- a/tests/integration/suite/daprd/hotreload/operator/middleware/http/app/routeralias.go +++ b/tests/integration/suite/daprd/hotreload/operator/middleware/http/app/routeralias.go @@ -181,7 +181,7 @@ func (r *routeralias) Run(t *testing.T, ctx context.Context) { assert.EventuallyWithT(t, func(c *assert.CollectT) { r.doReq(c, ctx, client, fmt.Sprintf("/v1.0/invoke/%s/method/helloworld", r.daprd2.AppID()), "daprd2:/aaa") - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) } func (r *routeralias) doReq(t require.TestingT, ctx context.Context, client *nethttp.Client, path, expect string) { diff --git a/tests/integration/suite/daprd/hotreload/operator/middleware/http/app/uppercase.go b/tests/integration/suite/daprd/hotreload/operator/middleware/http/app/uppercase.go index eba58cf9873..b7a74a8f219 100644 --- a/tests/integration/suite/daprd/hotreload/operator/middleware/http/app/uppercase.go +++ b/tests/integration/suite/daprd/hotreload/operator/middleware/http/app/uppercase.go @@ -172,7 +172,7 @@ func (u *uppercase) Run(t *testing.T, ctx context.Context) { assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, client, u.daprd2.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, true) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -201,7 +201,7 @@ func (u *uppercase) Run(t *testing.T, ctx context.Context) { assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, client, u.daprd3.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, true) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -237,7 +237,7 @@ func (u *uppercase) Run(t *testing.T, ctx context.Context) { {Name: "uppercase", Type: "middleware.http.routeralias", Version: "v1"}, {Name: "uppercase2", Type: "middleware.http.routeralias", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, false) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -270,7 +270,7 @@ func (u *uppercase) Run(t *testing.T, ctx context.Context) { {Name: "uppercase", Type: "middleware.http.routeralias", Version: "v1"}, {Name: "uppercase2", Type: "middleware.http.uppercase", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, true) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -323,7 +323,7 @@ func (u *uppercase) Run(t *testing.T, ctx context.Context) { assert.Empty(c, util.GetMetaComponents(c, ctx, client, u.daprd1.HTTPPort())) assert.Empty(c, util.GetMetaComponents(c, ctx, client, u.daprd2.HTTPPort())) assert.Empty(c, util.GetMetaComponents(c, ctx, client, u.daprd3.HTTPPort())) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, false) u.doReq(t, ctx, client, u.daprd1, u.daprd2, false) diff --git a/tests/integration/suite/daprd/hotreload/operator/middleware/http/server/routeralias.go b/tests/integration/suite/daprd/hotreload/operator/middleware/http/server/routeralias.go index a3f8b05654f..e425562f079 100644 --- a/tests/integration/suite/daprd/hotreload/operator/middleware/http/server/routeralias.go +++ b/tests/integration/suite/daprd/hotreload/operator/middleware/http/server/routeralias.go @@ -203,7 +203,7 @@ func (r *routeralias) Run(t *testing.T, ctx context.Context) { assert.EventuallyWithT(t, func(c *assert.CollectT) { r.doReq(c, ctx, client, "helloworld", "daprd1:/xyz") - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) } func (r *routeralias) doReq(t require.TestingT, ctx context.Context, client *nethttp.Client, path, expect string) { diff --git a/tests/integration/suite/daprd/hotreload/operator/middleware/http/server/uppercase.go b/tests/integration/suite/daprd/hotreload/operator/middleware/http/server/uppercase.go index 2dc03103508..6f709538a95 100644 --- a/tests/integration/suite/daprd/hotreload/operator/middleware/http/server/uppercase.go +++ b/tests/integration/suite/daprd/hotreload/operator/middleware/http/server/uppercase.go @@ -172,7 +172,7 @@ func (u *uppercase) Run(t *testing.T, ctx context.Context) { assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, client, u.daprd2.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, true) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -201,7 +201,7 @@ func (u *uppercase) Run(t *testing.T, ctx context.Context) { assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, client, u.daprd3.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, true) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -237,7 +237,7 @@ func (u *uppercase) Run(t *testing.T, ctx context.Context) { {Name: "uppercase", Type: "middleware.http.routeralias", Version: "v1"}, {Name: "uppercase2", Type: "middleware.http.routeralias", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, false) u.doReq(t, ctx, client, u.daprd1, u.daprd2, false) @@ -270,7 +270,7 @@ func (u *uppercase) Run(t *testing.T, ctx context.Context) { {Name: "uppercase", Type: "middleware.http.routeralias", Version: "v1"}, {Name: "uppercase2", Type: "middleware.http.uppercase", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, true) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -323,7 +323,7 @@ func (u *uppercase) Run(t *testing.T, ctx context.Context) { assert.Empty(c, util.GetMetaComponents(t, ctx, client, u.daprd1.HTTPPort())) assert.Empty(c, util.GetMetaComponents(t, ctx, client, u.daprd2.HTTPPort())) assert.Empty(c, util.GetMetaComponents(t, ctx, client, u.daprd3.HTTPPort())) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, false) u.doReq(t, ctx, client, u.daprd1, u.daprd2, false) diff --git a/tests/integration/suite/daprd/hotreload/operator/pubsub/grpc.go b/tests/integration/suite/daprd/hotreload/operator/pubsub/grpc.go index 1b3f2325f8e..c1b1fbec122 100644 --- a/tests/integration/suite/daprd/hotreload/operator/pubsub/grpc.go +++ b/tests/integration/suite/daprd/hotreload/operator/pubsub/grpc.go @@ -138,7 +138,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) { resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.publishMessage(t, ctx, client, "pubsub1", "topic1", "/route1") g.publishMessage(t, ctx, client, "pubsub2", "topic2", "/route2") }) @@ -161,7 +161,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) { resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.publishMessage(t, ctx, client, "pubsub1", "topic1", "/route1") g.publishMessage(t, ctx, client, "pubsub2", "topic2", "/route2") g.publishMessage(t, ctx, client, "pubsub3", "topic3", "/route3") @@ -176,7 +176,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) { resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.publishMessage(t, ctx, client, "pubsub1", "topic1", "/route1") g.publishMessageFails(t, ctx, client, "pubsub2", "topic2") g.publishMessage(t, ctx, client, "pubsub3", "topic3", "/route3") @@ -191,7 +191,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) { resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.publishMessageFails(t, ctx, client, "pubsub1", "topic1") g.publishMessageFails(t, ctx, client, "pubsub2", "topic2") g.publishMessage(t, ctx, client, "pubsub3", "topic3", "/route3") @@ -206,7 +206,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) { resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Empty(c, resp.GetRegisteredComponents()) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.publishMessageFails(t, ctx, client, "pubsub1", "topic1") g.publishMessageFails(t, ctx, client, "pubsub2", "topic2") g.publishMessageFails(t, ctx, client, "pubsub3", "topic3") @@ -230,7 +230,7 @@ func (g *grpc) Run(t *testing.T, ctx context.Context) { resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.publishMessageFails(t, ctx, client, "pubsub1", "topic1") g.publishMessage(t, ctx, client, "pubsub2", "topic2", "/route2") g.publishMessageFails(t, ctx, client, "pubsub3", "topic3") diff --git a/tests/integration/suite/daprd/hotreload/operator/pubsub/http.go b/tests/integration/suite/daprd/hotreload/operator/pubsub/http.go index c2caee6b3ae..303b70442bf 100644 --- a/tests/integration/suite/daprd/hotreload/operator/pubsub/http.go +++ b/tests/integration/suite/daprd/hotreload/operator/pubsub/http.go @@ -148,7 +148,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.publishMessage(t, ctx, client, "pubsub1", "topic1", "/route1") h.publishMessage(t, ctx, client, "pubsub2", "topic2", "/route2") }) @@ -169,7 +169,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.publishMessage(t, ctx, client, "pubsub1", "topic1", "/route1") h.publishMessage(t, ctx, client, "pubsub2", "topic2", "/route2") h.publishMessage(t, ctx, client, "pubsub3", "topic3", "/route3") @@ -182,7 +182,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.publishMessage(t, ctx, client, "pubsub1", "topic1", "/route1") h.publishMessageFails(t, ctx, client, "pubsub2", "topic2") h.publishMessage(t, ctx, client, "pubsub3", "topic3", "/route3") @@ -194,7 +194,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) { h.operator.ComponentUpdateEvent(t, ctx, &api.ComponentUpdateEvent{Component: &comp, EventType: operatorv1.ResourceEventType_DELETED}) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.publishMessageFails(t, ctx, client, "pubsub1", "topic1") h.publishMessageFails(t, ctx, client, "pubsub2", "topic2") h.publishMessage(t, ctx, client, "pubsub3", "topic3", "/route3") @@ -206,7 +206,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) { h.operator.ComponentUpdateEvent(t, ctx, &api.ComponentUpdateEvent{Component: &comp, EventType: operatorv1.ResourceEventType_DELETED}) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Empty(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort())) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.publishMessageFails(t, ctx, client, "pubsub1", "topic1") h.publishMessageFails(t, ctx, client, "pubsub2", "topic2") h.publishMessageFails(t, ctx, client, "pubsub3", "topic3") @@ -227,7 +227,7 @@ func (h *http) Run(t *testing.T, ctx context.Context) { h.operator.ComponentUpdateEvent(t, ctx, &api.ComponentUpdateEvent{Component: &comp, EventType: operatorv1.ResourceEventType_CREATED}) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.publishMessageFails(t, ctx, client, "pubsub1", "topic1") h.publishMessage(t, ctx, client, "pubsub2", "topic2", "/route2") h.publishMessageFails(t, ctx, client, "pubsub3", "topic3") diff --git a/tests/integration/suite/daprd/hotreload/operator/secret.go b/tests/integration/suite/daprd/hotreload/operator/secret.go index a6c09f68927..a213ce00a88 100644 --- a/tests/integration/suite/daprd/hotreload/operator/secret.go +++ b/tests/integration/suite/daprd/hotreload/operator/secret.go @@ -126,7 +126,7 @@ func (s *secret) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, s.client, s.daprd.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) resp := util.GetMetaComponents(t, ctx, s.client, s.daprd.HTTPPort()) require.Len(t, resp, 1) @@ -190,7 +190,7 @@ func (s *secret) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, s.client, s.daprd.HTTPPort()), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) resp := util.GetMetaComponents(t, ctx, s.client, s.daprd.HTTPPort()) require.Len(t, resp, 3) @@ -235,7 +235,7 @@ func (s *secret) Run(t *testing.T, ctx context.Context) { {Name: "abc", Type: "secretstores.local.env", Version: "v1"}, {Name: "xyz", Type: "secretstores.local.env", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.read(t, ctx, "123", "SEC_1", "bar1") s.read(t, ctx, "123", "SEC_2", "bar2") @@ -317,7 +317,7 @@ func (s *secret) Run(t *testing.T, ctx context.Context) { {Name: "xyz", Type: "secretstores.local.env", Version: "v1"}, {Name: "foo", Type: "secretstores.local.env", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.read(t, ctx, "123", "1-sec-1", "foo") s.read(t, ctx, "123", "1-sec-2", "bar") @@ -364,7 +364,7 @@ func (s *secret) Run(t *testing.T, ctx context.Context) { {Name: "xyz", Type: "secretstores.local.env", Version: "v1"}, {Name: "foo", Type: "secretstores.local.env", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.read(t, ctx, "123", "1-sec-1", "foo") s.read(t, ctx, "123", "1-sec-2", "bar") @@ -406,7 +406,7 @@ func (s *secret) Run(t *testing.T, ctx context.Context) { Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.read(t, ctx, "123", "1-sec-1", "foo") s.read(t, ctx, "123", "1-sec-2", "bar") @@ -441,7 +441,7 @@ func (s *secret) Run(t *testing.T, ctx context.Context) { Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.readExpectError(t, ctx, "123", "1-sec-1", http.StatusInternalServerError) s.readExpectError(t, ctx, "xyz", "SEC_1", http.StatusInternalServerError) @@ -467,7 +467,7 @@ func (s *secret) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, s.client, s.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.read(t, ctx, "123", "SEC_1", "bar1") s.read(t, ctx, "123", "SEC_2", "bar2") diff --git a/tests/integration/suite/daprd/hotreload/operator/state.go b/tests/integration/suite/daprd/hotreload/operator/state.go index 92920823f12..a52901b5c38 100644 --- a/tests/integration/suite/daprd/hotreload/operator/state.go +++ b/tests/integration/suite/daprd/hotreload/operator/state.go @@ -105,7 +105,7 @@ func (s *state) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, client, s.daprd.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) resp := util.GetMetaComponents(t, ctx, client, s.daprd.HTTPPort()) require.Len(t, resp, 1) @@ -157,7 +157,7 @@ func (s *state) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(c *assert.CollectT) { resp = util.GetMetaComponents(t, ctx, client, s.daprd.HTTPPort()) assert.Len(c, resp, 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) assert.ElementsMatch(t, []*rtv1.RegisteredComponents{ { @@ -220,7 +220,7 @@ func (s *state) Run(t *testing.T, ctx context.Context) { Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.writeRead(t, ctx, client, "123") s.writeRead(t, ctx, client, "abc") @@ -297,7 +297,7 @@ func (s *state) Run(t *testing.T, ctx context.Context) { Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.writeRead(t, ctx, client, "123") s.writeRead(t, ctx, client, "abc") @@ -359,7 +359,7 @@ func (s *state) Run(t *testing.T, ctx context.Context) { Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.writeRead(t, ctx, client, "123") s.writeRead(t, ctx, client, "bar") @@ -410,7 +410,7 @@ func (s *state) Run(t *testing.T, ctx context.Context) { Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.writeRead(t, ctx, client, "123") s.writeExpectError(t, ctx, client, "bar", http.StatusBadRequest) @@ -437,7 +437,7 @@ func (s *state) Run(t *testing.T, ctx context.Context) { assert.ElementsMatch(c, []*rtv1.RegisteredComponents{ {Name: "bar", Type: "secretstores.local.file", Version: "v1"}, }, resp) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) s.writeExpectError(t, ctx, client, "123", http.StatusInternalServerError) s.writeExpectError(t, ctx, client, "bar", http.StatusInternalServerError) @@ -457,7 +457,7 @@ func (s *state) Run(t *testing.T, ctx context.Context) { s.operator.ComponentUpdateEvent(t, ctx, &api.ComponentUpdateEvent{Component: &comp, EventType: operatorv1.ResourceEventType_CREATED}) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, client, s.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.writeRead(t, ctx, client, "123") }) } diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/binding/input/grpc.go b/tests/integration/suite/daprd/hotreload/selfhosted/binding/input/grpc.go index 5d44c644fde..bee9a91d7e3 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/binding/input/grpc.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/binding/input/grpc.go @@ -158,7 +158,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.expectBindings(t, []bindingPair{ {0, "binding1"}, {1, "binding2"}, @@ -198,7 +198,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.expectBindings(t, []bindingPair{ {0, "binding1"}, {1, "binding2"}, @@ -225,7 +225,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.registered[0].Store(false) g.expectBindings(t, []bindingPair{ {1, "binding2"}, @@ -240,7 +240,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Empty(c, resp.GetRegisteredComponents()) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.registered[1].Store(false) g.registered[2].Store(false) // Sleep to ensure binding is not triggered. @@ -267,7 +267,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.expectBinding(t, 0, "binding1") }) } diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/binding/input/http.go b/tests/integration/suite/daprd/hotreload/selfhosted/binding/input/http.go index 0971c440e71..56cfce8e829 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/binding/input/http.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/binding/input/http.go @@ -151,7 +151,7 @@ spec: `), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.expectBindings(t, []bindingPair{ {0, "binding1"}, {1, "binding2"}, @@ -189,7 +189,7 @@ spec: `), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.expectBindings(t, []bindingPair{ {0, "binding1"}, {1, "binding2"}, @@ -214,7 +214,7 @@ spec: `), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.registered[0].Store(false) h.expectBindings(t, []bindingPair{ {1, "binding2"}, @@ -227,7 +227,7 @@ spec: require.NoError(t, os.Remove(filepath.Join(h.resDir, "2.yaml"))) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Empty(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort())) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.registered[1].Store(false) h.registered[2].Store(false) // Sleep to ensure binding is not triggered. @@ -252,7 +252,7 @@ spec: `), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.expectBinding(t, 0, "binding1") }) } diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/binding/output.go b/tests/integration/suite/daprd/hotreload/selfhosted/binding/output.go index 12c27f8d6f8..ef6c1b6829e 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/binding/output.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/binding/output.go @@ -95,7 +95,7 @@ spec: `, o.bindingDir1)), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, o.daprd.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) o.postBinding(t, ctx, client, "binding1", "file1", "data1") o.postBindingFail(t, ctx, client, "binding2") o.postBindingFail(t, ctx, client, "binding3") @@ -129,7 +129,7 @@ spec: `, o.bindingDir1, o.bindingDir2)), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, o.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) o.postBinding(t, ctx, client, "binding1", "file2", "data2") o.postBinding(t, ctx, client, "binding2", "file1", "data1") o.postBindingFail(t, ctx, client, "binding3") @@ -153,7 +153,7 @@ spec: `, o.bindingDir3)), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, o.daprd.HTTPPort()), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) o.postBinding(t, ctx, client, "binding1", "file3", "data3") o.postBinding(t, ctx, client, "binding2", "file2", "data2") o.postBinding(t, ctx, client, "binding3", "file1", "data1") @@ -178,7 +178,7 @@ spec: `, o.bindingDir2)), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, o.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) o.postBindingFail(t, ctx, client, "binding1") assert.NoFileExists(t, filepath.Join(o.bindingDir1, "file4")) o.postBinding(t, ctx, client, "binding2", "file3", "data3") @@ -192,7 +192,7 @@ spec: require.NoError(t, os.Remove(filepath.Join(o.resDir, "2.yaml"))) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Empty(c, util.GetMetaComponents(c, ctx, client, o.daprd.HTTPPort())) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) o.postBindingFail(t, ctx, client, "binding1") o.postBindingFail(t, ctx, client, "binding2") o.postBindingFail(t, ctx, client, "binding3") @@ -214,7 +214,7 @@ spec: `, o.bindingDir2)), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, o.daprd.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) o.postBinding(t, ctx, client, "binding2", "file5", "data5") o.postBindingFail(t, ctx, client, "binding1") o.postBindingFail(t, ctx, client, "binding3") diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/crypto.go b/tests/integration/suite/daprd/hotreload/selfhosted/crypto.go index 5341cb47313..977306bb4d6 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/crypto.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/crypto.go @@ -106,7 +106,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) c.encryptDecrypt(t, ctx, client, "crypto1") c.encryptDecryptFail(t, ctx, client, "crypto2") @@ -135,7 +135,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) c.encryptDecrypt(t, ctx, client, "crypto1") c.encryptDecrypt(t, ctx, client, "crypto2") @@ -174,7 +174,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) c.encryptDecrypt(t, ctx, client, "crypto1") c.encryptDecrypt(t, ctx, client, "crypto2") @@ -213,7 +213,7 @@ spec: Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp.GetRegisteredComponents()) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) c.encryptDecrypt(t, ctx, client, "crypto1") c.encryptDecryptFail(t, ctx, client, "crypto2") @@ -226,7 +226,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) require.NoError(t, os.WriteFile(filepath.Join(c.resDir, "2.yaml"), []byte(` apiVersion: dapr.io/v1alpha1 kind: Component @@ -246,7 +246,7 @@ spec: Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp.GetRegisteredComponents()) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) c.encryptDecryptFail(t, ctx, client, "crypto1") c.encryptDecryptFail(t, ctx, client, "crypto2") @@ -270,7 +270,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) c.encryptDecryptFail(t, ctx, client, "crypto1") c.encryptDecrypt(t, ctx, client, "crypto2") diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/app/routeralias.go b/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/app/routeralias.go index 4ab461176ca..9d2a2360620 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/app/routeralias.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/app/routeralias.go @@ -175,7 +175,7 @@ spec: assert.EventuallyWithT(t, func(c *assert.CollectT) { r.doReq(c, ctx, client, fmt.Sprintf("/v1.0/invoke/%s/method/helloworld", r.daprd2.AppID()), "daprd2:/aaa") - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) } func (r *routeralias) doReq(t require.TestingT, ctx context.Context, client *nethttp.Client, path, expect string) { diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/app/uppercase.go b/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/app/uppercase.go index a31dacf4317..24722b6328a 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/app/uppercase.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/app/uppercase.go @@ -153,7 +153,7 @@ spec: assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, client, u.daprd2.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, true) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -179,7 +179,7 @@ spec: assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, client, u.daprd3.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, true) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -223,7 +223,7 @@ spec: {Name: "uppercase", Type: "middleware.http.routeralias", Version: "v1"}, {Name: "uppercase2", Type: "middleware.http.routeralias", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, false) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -264,7 +264,7 @@ spec: {Name: "uppercase", Type: "middleware.http.routeralias", Version: "v1"}, {Name: "uppercase2", Type: "middleware.http.uppercase", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, true) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -286,7 +286,7 @@ spec: assert.Empty(c, util.GetMetaComponents(c, ctx, client, u.daprd1.HTTPPort())) assert.Empty(c, util.GetMetaComponents(c, ctx, client, u.daprd2.HTTPPort())) assert.Empty(c, util.GetMetaComponents(c, ctx, client, u.daprd3.HTTPPort())) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, false) u.doReq(t, ctx, client, u.daprd1, u.daprd2, false) diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/server/routeralias.go b/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/server/routeralias.go index 3b2665e609d..35c31085161 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/server/routeralias.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/server/routeralias.go @@ -173,7 +173,7 @@ spec: assert.EventuallyWithT(t, func(c *assert.CollectT) { r.doReq(c, ctx, client, "helloworld", "daprd1:/xyz") - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) } func (r *routeralias) doReq(t require.TestingT, ctx context.Context, client *nethttp.Client, path, expect string) { diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/server/uppercase.go b/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/server/uppercase.go index 85e32734645..4a4f020cf21 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/server/uppercase.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/middleware/http/server/uppercase.go @@ -153,7 +153,7 @@ spec: assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, client, u.daprd2.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, true) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -179,7 +179,7 @@ spec: assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(t, ctx, client, u.daprd3.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, true) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -223,7 +223,7 @@ spec: {Name: "uppercase", Type: "middleware.http.routeralias", Version: "v1"}, {Name: "uppercase2", Type: "middleware.http.routeralias", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, false) u.doReq(t, ctx, client, u.daprd1, u.daprd2, false) @@ -264,7 +264,7 @@ spec: {Name: "uppercase", Type: "middleware.http.routeralias", Version: "v1"}, {Name: "uppercase2", Type: "middleware.http.uppercase", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, true) u.doReq(t, ctx, client, u.daprd1, u.daprd2, true) @@ -286,7 +286,7 @@ spec: assert.Empty(c, util.GetMetaComponents(c, ctx, client, u.daprd1.HTTPPort())) assert.Empty(c, util.GetMetaComponents(c, ctx, client, u.daprd2.HTTPPort())) assert.Empty(c, util.GetMetaComponents(c, ctx, client, u.daprd3.HTTPPort())) - }, time.Second*5, time.Millisecond*10, "expected component to be loaded") + }, time.Second*5, time.Millisecond*100, "expected component to be loaded") u.doReq(t, ctx, client, u.daprd1, u.daprd1, false) u.doReq(t, ctx, client, u.daprd1, u.daprd2, false) diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/namespace/set.go b/tests/integration/suite/daprd/hotreload/selfhosted/namespace/set.go deleted file mode 100644 index 1e2639533e4..00000000000 --- a/tests/integration/suite/daprd/hotreload/selfhosted/namespace/set.go +++ /dev/null @@ -1,215 +0,0 @@ -/* -Copyright 2024 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://wwn.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 implieh. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package namespace - -import ( - "context" - "os" - "path/filepath" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - rtv1 "github.com/dapr/dapr/pkg/proto/runtime/v1" - "github.com/dapr/dapr/tests/integration/framework" - "github.com/dapr/dapr/tests/integration/framework/process/daprd" - "github.com/dapr/dapr/tests/integration/framework/process/logline" - "github.com/dapr/dapr/tests/integration/suite" -) - -func init() { - suite.Register(new(set)) -} - -// set ensures that component manifest files are hot-reloaded, but ignore -// components which are not in the same namespace when NAMESPACE env var set. -type set struct { - daprd *daprd.Daprd - logline *logline.LogLine - resDir string -} - -func (s *set) Setup(t *testing.T) []framework.Option { - configFile := filepath.Join(t.TempDir(), "config.yaml") - require.NoError(t, os.WriteFile(configFile, []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Configuration -metadata: - name: hotreloading -spec: - features: - - name: HotReload - enabled: true`), 0o600)) - - s.resDir = t.TempDir() - - s.logline = logline.New(t, logline.WithStdoutLineContains( - `"Fatal error from runtime: failed to load resources from disk: duplicate definition of component name foo (state.in-memory/v1) with existing foo (pubsub.in-memory/v1)"`, - )) - - s.daprd = daprd.New(t, - daprd.WithConfigs(configFile), - daprd.WithResourcesDir(s.resDir), - daprd.WithExit1(), - daprd.WithLogLineStdout(s.logline), - daprd.WithNamespace("mynamespace"), - ) - - require.NoError(t, os.WriteFile(filepath.Join(s.resDir, "1.yaml"), []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 -spec: - type: state.in-memory - version: v1 -`), 0o600)) - - return []framework.Option{ - framework.WithProcesses(s.logline, s.daprd), - } -} - -func (s *set) Run(t *testing.T, ctx context.Context) { - s.daprd.WaitUntilRunning(t, ctx) - - assert.EventuallyWithT(t, func(t *assert.CollectT) { - assert.ElementsMatch(t, []*rtv1.RegisteredComponents{ - { - Name: "123", Type: "state.in-memory", Version: "v1", - Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, - }, - }, s.daprd.RegistedComponents(t, ctx)) - }, 5*time.Second, 10*time.Millisecond) - - require.NoError(t, os.WriteFile(filepath.Join(s.resDir, "1.yaml"), []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 - namespace: default -spec: - type: pubsub.in-memory - version: v1 -`), 0o600)) - assert.EventuallyWithT(t, func(t *assert.CollectT) { - assert.Empty(t, s.daprd.RegistedComponents(t, ctx)) - }, 5*time.Second, 10*time.Millisecond) - - require.NoError(t, os.WriteFile(filepath.Join(s.resDir, "1.yaml"), []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 -spec: - type: pubsub.in-memory - version: v1 -`), 0o600)) - assert.EventuallyWithT(t, func(t *assert.CollectT) { - assert.ElementsMatch(t, []*rtv1.RegisteredComponents{ - { - Name: "123", Type: "pubsub.in-memory", Version: "v1", - Capabilities: []string{"SUBSCRIBE_WILDCARDS"}, - }, - }, s.daprd.RegistedComponents(t, ctx)) - }, 5*time.Second, 10*time.Millisecond) - - require.NoError(t, os.WriteFile(filepath.Join(s.resDir, "1.yaml"), []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 - namespace: mynamespace -spec: - type: state.in-memory - version: v1 -`), 0o600)) - assert.EventuallyWithT(t, func(t *assert.CollectT) { - assert.ElementsMatch(t, []*rtv1.RegisteredComponents{ - { - Name: "123", Type: "state.in-memory", Version: "v1", - Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, - }, - }, s.daprd.RegistedComponents(t, ctx)) - }, 5*time.Second, 10*time.Millisecond) - - require.NoError(t, os.WriteFile(filepath.Join(s.resDir, "1.yaml"), []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: foo - namespace: foobar -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 - namespace: mynamespace -spec: - type: pubsub.in-memory - version: v1 -`), 0o600)) - assert.EventuallyWithT(t, func(t *assert.CollectT) { - assert.ElementsMatch(t, []*rtv1.RegisteredComponents{ - { - Name: "123", Type: "pubsub.in-memory", Version: "v1", - Capabilities: []string{"SUBSCRIBE_WILDCARDS"}, - }, - }, s.daprd.RegistedComponents(t, ctx)) - }, 5*time.Second, 10*time.Millisecond) - - require.NoError(t, os.WriteFile(filepath.Join(s.resDir, "1.yaml"), []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 - namespace: mynamespace -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: foo - namespace: foobar -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: foo - namespace: mynamespace -spec: - type: pubsub.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: foo -spec: - type: state.in-memory - version: v1 -`), 0o600)) - - s.logline.EventuallyFoundAll(t) -} diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/namespace/unset.go b/tests/integration/suite/daprd/hotreload/selfhosted/namespace/unset.go deleted file mode 100644 index 7bf49f96421..00000000000 --- a/tests/integration/suite/daprd/hotreload/selfhosted/namespace/unset.go +++ /dev/null @@ -1,208 +0,0 @@ -/* -Copyright 2024 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://wwn.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 implieh. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package namespace - -import ( - "context" - "os" - "path/filepath" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - rtv1 "github.com/dapr/dapr/pkg/proto/runtime/v1" - "github.com/dapr/dapr/tests/integration/framework" - "github.com/dapr/dapr/tests/integration/framework/process/daprd" - "github.com/dapr/dapr/tests/integration/framework/process/logline" - "github.com/dapr/dapr/tests/integration/suite" -) - -func init() { - suite.Register(new(unset)) -} - -// unset ensures that component manifest files are hot-reloaded, regardless -// of the namespace set on them when NAMESPACE env var isn't set. -type unset struct { - daprd *daprd.Daprd - logline *logline.LogLine - resDir string -} - -func (u *unset) Setup(t *testing.T) []framework.Option { - configFile := filepath.Join(t.TempDir(), "config.yaml") - require.NoError(t, os.WriteFile(configFile, []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Configuration -metadata: - name: hotreloading -spec: - features: - - name: HotReload - enabled: true`), 0o600)) - - u.resDir = t.TempDir() - - u.logline = logline.New(t, logline.WithStdoutLineContains( - `Fatal error from runtime: failed to load resources from disk: duplicate definition of component name foo (pubsub.in-memory/v1) with existing foo (state.in-memory/v1)\nduplicate definition of component name foo (state.in-memory/v1) with existing foo (state.in-memory/v1)`, - )) - - u.daprd = daprd.New(t, - daprd.WithConfigs(configFile), - daprd.WithResourcesDir(u.resDir), - daprd.WithExit1(), - daprd.WithLogLineStdout(u.logline), - ) - - require.NoError(t, os.WriteFile(filepath.Join(u.resDir, "1.yaml"), []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 -spec: - type: state.in-memory - version: v1 -`), 0o600)) - - return []framework.Option{ - framework.WithProcesses(u.logline, u.daprd), - } -} - -func (u *unset) Run(t *testing.T, ctx context.Context) { - u.daprd.WaitUntilRunning(t, ctx) - - assert.EventuallyWithT(t, func(t *assert.CollectT) { - assert.ElementsMatch(t, []*rtv1.RegisteredComponents{ - { - Name: "123", Type: "state.in-memory", Version: "v1", - Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, - }, - }, u.daprd.RegistedComponents(t, ctx)) - }, 5*time.Second, 10*time.Millisecond) - - require.NoError(t, os.WriteFile(filepath.Join(u.resDir, "1.yaml"), []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 - namespace: default -spec: - type: pubsub.in-memory - version: v1 -`), 0o600)) - - assert.EventuallyWithT(t, func(t *assert.CollectT) { - assert.ElementsMatch(t, []*rtv1.RegisteredComponents{ - { - Name: "123", Type: "pubsub.in-memory", Version: "v1", - Capabilities: []string{"SUBSCRIBE_WILDCARDS"}, - }, - }, u.daprd.RegistedComponents(t, ctx)) - }, 5*time.Second, 10*time.Millisecond) - - require.NoError(t, os.WriteFile(filepath.Join(u.resDir, "1.yaml"), []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 - namespace: mynamespace -spec: - type: state.in-memory - version: v1 -`), 0o600)) - - assert.EventuallyWithT(t, func(t *assert.CollectT) { - assert.ElementsMatch(t, []*rtv1.RegisteredComponents{ - { - Name: "123", Type: "state.in-memory", Version: "v1", - Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, - }, - }, u.daprd.RegistedComponents(t, ctx)) - }, 5*time.Second, 10*time.Millisecond) - - require.NoError(t, os.WriteFile(filepath.Join(u.resDir, "1.yaml"), []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 - namespace: mynamespace -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: foo - namespace: foobar -spec: - type: state.in-memory - version: v1 -`), 0o600)) - - assert.EventuallyWithT(t, func(t *assert.CollectT) { - assert.ElementsMatch(t, []*rtv1.RegisteredComponents{ - { - Name: "123", Type: "state.in-memory", Version: "v1", - Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, - }, - { - Name: "foo", Type: "state.in-memory", Version: "v1", - Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, - }, - }, u.daprd.RegistedComponents(t, ctx)) - }, 5*time.Second, 10*time.Millisecond) - - require.NoError(t, os.WriteFile(filepath.Join(u.resDir, "1.yaml"), []byte(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 - namespace: mynamespace -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: foo - namespace: foobar -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: foo - namespace: mynamespace -spec: - type: pubsub.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: foo -spec: - type: state.in-memory - version: v1 -`), 0o600)) - - u.logline.EventuallyFoundAll(t) -} diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/pubsub/grpc.go b/tests/integration/suite/daprd/hotreload/selfhosted/pubsub/grpc.go index 01005c54b8a..23351e88a70 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/pubsub/grpc.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/pubsub/grpc.go @@ -125,7 +125,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.publishMessage(t, ctx, client, "pubsub1", "topic1", "/route1") g.publishMessage(t, ctx, client, "pubsub2", "topic2", "/route2") }) @@ -153,7 +153,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.publishMessage(t, ctx, client, "pubsub1", "topic1", "/route1") g.publishMessage(t, ctx, client, "pubsub2", "topic2", "/route2") g.publishMessage(t, ctx, client, "pubsub3", "topic3", "/route3") @@ -174,7 +174,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.publishMessage(t, ctx, client, "pubsub1", "topic1", "/route1") g.publishMessageFails(t, ctx, client, "pubsub2", "topic2") g.publishMessage(t, ctx, client, "pubsub3", "topic3", "/route3") @@ -186,7 +186,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.publishMessageFails(t, ctx, client, "pubsub1", "topic1") g.publishMessageFails(t, ctx, client, "pubsub2", "topic2") g.publishMessage(t, ctx, client, "pubsub3", "topic3", "/route3") @@ -198,7 +198,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Empty(c, resp.GetRegisteredComponents()) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.publishMessageFails(t, ctx, client, "pubsub1", "topic1") g.publishMessageFails(t, ctx, client, "pubsub2", "topic2") g.publishMessageFails(t, ctx, client, "pubsub3", "topic3") @@ -219,7 +219,7 @@ spec: resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) g.publishMessageFails(t, ctx, client, "pubsub1", "topic1") g.publishMessage(t, ctx, client, "pubsub2", "topic2", "/route2") g.publishMessageFails(t, ctx, client, "pubsub3", "topic3") diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/pubsub/http.go b/tests/integration/suite/daprd/hotreload/selfhosted/pubsub/http.go index 2614bf7e813..ba4b801fa44 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/pubsub/http.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/pubsub/http.go @@ -134,7 +134,7 @@ spec: `), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.publishMessage(t, ctx, client, "pubsub1", "topic1", "/route1") h.publishMessage(t, ctx, client, "pubsub2", "topic2", "/route2") }) @@ -159,7 +159,7 @@ spec: `), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.publishMessage(t, ctx, client, "pubsub1", "topic1", "/route1") h.publishMessage(t, ctx, client, "pubsub2", "topic2", "/route2") h.publishMessage(t, ctx, client, "pubsub3", "topic3", "/route3") @@ -177,7 +177,7 @@ spec: `), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.publishMessage(t, ctx, client, "pubsub1", "topic1", "/route1") h.publishMessageFails(t, ctx, client, "pubsub2", "topic2") h.publishMessage(t, ctx, client, "pubsub3", "topic3", "/route3") @@ -187,7 +187,7 @@ spec: require.NoError(t, os.Remove(filepath.Join(h.resDir, "1.yaml"))) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.publishMessageFails(t, ctx, client, "pubsub1", "topic1") h.publishMessageFails(t, ctx, client, "pubsub2", "topic2") h.publishMessage(t, ctx, client, "pubsub3", "topic3", "/route3") @@ -197,7 +197,7 @@ spec: require.NoError(t, os.Remove(filepath.Join(h.resDir, "2.yaml"))) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Empty(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort())) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.publishMessageFails(t, ctx, client, "pubsub1", "topic1") h.publishMessageFails(t, ctx, client, "pubsub2", "topic2") h.publishMessageFails(t, ctx, client, "pubsub3", "topic3") @@ -215,7 +215,7 @@ spec: `), 0o600)) require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, h.daprd.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) h.publishMessageFails(t, ctx, client, "pubsub1", "topic1") h.publishMessage(t, ctx, client, "pubsub2", "topic2", "/route2") h.publishMessageFails(t, ctx, client, "pubsub3", "topic3") diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/secret.go b/tests/integration/suite/daprd/hotreload/selfhosted/secret.go index 631f1e0a6e5..9fb388fb699 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/secret.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/secret.go @@ -108,7 +108,7 @@ spec: require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, s.client, s.daprd.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) resp := util.GetMetaComponents(t, ctx, s.client, s.daprd.HTTPPort()) require.Len(t, resp, 1) @@ -164,7 +164,7 @@ spec: require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, s.client, s.daprd.HTTPPort()), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) resp := util.GetMetaComponents(t, ctx, s.client, s.daprd.HTTPPort()) require.Len(t, resp, 3) @@ -205,7 +205,7 @@ spec: {Name: "abc", Type: "secretstores.local.env", Version: "v1"}, {Name: "xyz", Type: "secretstores.local.env", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.read(t, ctx, "123", "SEC_1", "bar1") s.read(t, ctx, "123", "SEC_2", "bar2") @@ -272,7 +272,7 @@ spec: {Name: "xyz", Type: "secretstores.local.env", Version: "v1"}, {Name: "foo", Type: "secretstores.local.env", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.read(t, ctx, "123", "1-sec-1", "foo") s.read(t, ctx, "123", "1-sec-2", "bar") @@ -310,7 +310,7 @@ spec: {Name: "xyz", Type: "secretstores.local.env", Version: "v1"}, {Name: "foo", Type: "secretstores.local.env", Version: "v1"}, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.read(t, ctx, "123", "1-sec-1", "foo") s.read(t, ctx, "123", "1-sec-2", "bar") @@ -349,7 +349,7 @@ spec: Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.read(t, ctx, "123", "1-sec-1", "foo") s.read(t, ctx, "123", "1-sec-2", "bar") @@ -377,7 +377,7 @@ spec: Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.readExpectError(t, ctx, "123", "1-sec-1", http.StatusInternalServerError) s.readExpectError(t, ctx, "xyz", "SEC_1", http.StatusInternalServerError) @@ -401,7 +401,7 @@ spec: require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, s.client, s.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.read(t, ctx, "123", "SEC_1", "bar1") s.read(t, ctx, "123", "SEC_2", "bar2") diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/selfhosted.go b/tests/integration/suite/daprd/hotreload/selfhosted/selfhostest.go similarity index 90% rename from tests/integration/suite/daprd/hotreload/selfhosted/selfhosted.go rename to tests/integration/suite/daprd/hotreload/selfhosted/selfhostest.go index 3b198cf31fb..634125ae291 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/selfhosted.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/selfhostest.go @@ -16,6 +16,5 @@ package selfhosted import ( _ "github.com/dapr/dapr/tests/integration/suite/daprd/hotreload/selfhosted/binding" _ "github.com/dapr/dapr/tests/integration/suite/daprd/hotreload/selfhosted/middleware" - _ "github.com/dapr/dapr/tests/integration/suite/daprd/hotreload/selfhosted/namespace" _ "github.com/dapr/dapr/tests/integration/suite/daprd/hotreload/selfhosted/pubsub" ) diff --git a/tests/integration/suite/daprd/hotreload/selfhosted/state.go b/tests/integration/suite/daprd/hotreload/selfhosted/state.go index 471ae878490..4a547679a03 100644 --- a/tests/integration/suite/daprd/hotreload/selfhosted/state.go +++ b/tests/integration/suite/daprd/hotreload/selfhosted/state.go @@ -95,7 +95,7 @@ spec: require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, s.daprd.HTTPPort()), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) resp := util.GetMetaComponents(t, ctx, client, s.daprd.HTTPPort()) assert.ElementsMatch(t, []*rtpbv1.RegisteredComponents{ { @@ -138,7 +138,7 @@ spec: require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, s.daprd.HTTPPort()), 3) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) resp := util.GetMetaComponents(t, ctx, client, s.daprd.HTTPPort()) assert.ElementsMatch(t, []*rtpbv1.RegisteredComponents{ { @@ -195,7 +195,7 @@ spec: Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.writeRead(t, ctx, client, "123") s.writeRead(t, ctx, client, "abc") @@ -261,7 +261,7 @@ spec: Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.writeRead(t, ctx, client, "123") s.writeRead(t, ctx, client, "abc") @@ -306,7 +306,7 @@ spec: Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.writeRead(t, ctx, client, "123") s.writeRead(t, ctx, client, "bar") @@ -353,7 +353,7 @@ spec: Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.writeRead(t, ctx, client, "123") s.writeExpectError(t, ctx, client, "bar", http.StatusBadRequest) @@ -375,7 +375,7 @@ spec: assert.ElementsMatch(c, []*rtpbv1.RegisteredComponents{ {Name: "bar", Type: "secretstores.local.file", Version: "v1"}, }, resp) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) s.writeExpectError(t, ctx, client, "123", http.StatusInternalServerError) s.writeExpectError(t, ctx, client, "bar", http.StatusInternalServerError) @@ -397,7 +397,7 @@ spec: require.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, s.daprd.HTTPPort()), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) s.writeRead(t, ctx, client, "123") }) diff --git a/tests/integration/suite/daprd/httpserver/httpserver.go b/tests/integration/suite/daprd/httpserver/httpserver.go index 6db3a105d49..98c60bf3039 100644 --- a/tests/integration/suite/daprd/httpserver/httpserver.go +++ b/tests/integration/suite/daprd/httpserver/httpserver.go @@ -66,7 +66,7 @@ func (h *httpServer) Run(t *testing.T, ctx context.Context) { t.Cleanup(h2cClient.CloseIdleConnections) t.Run("test with HTTP1", func(t *testing.T) { - reqCtx, reqCancel := context.WithTimeout(ctx, 10*time.Millisecond) + reqCtx, reqCancel := context.WithTimeout(ctx, 100*time.Millisecond) defer reqCancel() req, err := http.NewRequestWithContext(reqCtx, http.MethodGet, fmt.Sprintf("http://localhost:%d/v1.0/healthz", h.proc.HTTPPort()), nil) @@ -83,7 +83,7 @@ func (h *httpServer) Run(t *testing.T, ctx context.Context) { }) t.Run("test with HTTP2 Cleartext with prior knowledge", func(t *testing.T) { - reqCtx, reqCancel := context.WithTimeout(ctx, 10*time.Millisecond) + reqCtx, reqCancel := context.WithTimeout(ctx, 100*time.Millisecond) defer reqCancel() req, err := http.NewRequestWithContext(reqCtx, http.MethodGet, fmt.Sprintf("http://localhost:%d/v1.0/healthz", h.proc.HTTPPort()), nil) diff --git a/tests/integration/suite/daprd/mtls/kubernetes/disable.go b/tests/integration/suite/daprd/mtls/kubernetes/disable.go index a659969cacb..2b239988e3f 100644 --- a/tests/integration/suite/daprd/mtls/kubernetes/disable.go +++ b/tests/integration/suite/daprd/mtls/kubernetes/disable.go @@ -147,7 +147,7 @@ func (e *disable) Run(t *testing.T, ctx context.Context) { return !strings.Contains(err.Error(), "An existing connection was forcibly closed by the remote host.") } return true - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) require.ErrorContains(t, err, "tls: first record does not look like a TLS handshake") }) } diff --git a/tests/integration/suite/daprd/mtls/standalone/disable.go b/tests/integration/suite/daprd/mtls/standalone/disable.go index 4b30a21bf08..b8b32b354d0 100644 --- a/tests/integration/suite/daprd/mtls/standalone/disable.go +++ b/tests/integration/suite/daprd/mtls/standalone/disable.go @@ -130,7 +130,7 @@ func (e *disable) Run(t *testing.T, ctx context.Context) { return !strings.Contains(err.Error(), "An existing connection was forcibly closed by the remote host.") } return true - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) require.ErrorContains(t, err, "tls: first record does not look like a TLS handshake") }) } diff --git a/tests/integration/suite/daprd/outbox/grpc/basic.go b/tests/integration/suite/daprd/outbox/grpc/basic.go index 5c04448f4e9..26c695effcb 100644 --- a/tests/integration/suite/daprd/outbox/grpc/basic.go +++ b/tests/integration/suite/daprd/outbox/grpc/basic.go @@ -120,5 +120,5 @@ func (o *basic) Run(t *testing.T, ctx context.Context) { o.lock.Lock() defer o.lock.Unlock() return string(o.msg) == "2" - }, time.Second*5, time.Millisecond*10, "failed to receive message in time") + }, time.Second*5, time.Millisecond*100, "failed to receive message in time") } diff --git a/tests/integration/suite/daprd/outbox/http/basic.go b/tests/integration/suite/daprd/outbox/http/basic.go index c618c900671..85efb70d054 100644 --- a/tests/integration/suite/daprd/outbox/http/basic.go +++ b/tests/integration/suite/daprd/outbox/http/basic.go @@ -174,5 +174,5 @@ func (o *basic) Run(t *testing.T, ctx context.Context) { //nolint:testifylint assert.NoError(c, err) assert.Equal(c, "2", ce["data"]) - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) } diff --git a/tests/integration/suite/daprd/pluggable/basic.go b/tests/integration/suite/daprd/pluggable/basic.go index 9a4313cb16e..424f7dbbe74 100644 --- a/tests/integration/suite/daprd/pluggable/basic.go +++ b/tests/integration/suite/daprd/pluggable/basic.go @@ -189,5 +189,5 @@ func (b *basic) Run(t *testing.T, ctx context.Context) { require.NoError(t, err) assert.Empty(c, resp.GetData()) } - }, time.Second*2, time.Millisecond*10) + }, time.Second*2, time.Millisecond*100) } diff --git a/tests/integration/suite/daprd/pubsub/grpc/appready.go b/tests/integration/suite/daprd/pubsub/grpc/appready.go index 9a5a223999c..f2b81ff7419 100644 --- a/tests/integration/suite/daprd/pubsub/grpc/appready.go +++ b/tests/integration/suite/daprd/pubsub/grpc/appready.go @@ -103,10 +103,10 @@ func (a *appready) Run(t *testing.T, ctx context.Context) { resp, err = client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.Len(c, resp.GetRegisteredComponents(), 1) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) called := a.healthCalled.Load() - require.Eventually(t, func() bool { return a.healthCalled.Load() > called }, time.Second*5, time.Millisecond*10) + require.Eventually(t, func() bool { return a.healthCalled.Load() > called }, time.Second*5, time.Millisecond*100) assert.Eventually(t, func() bool { var resp *http.Response @@ -114,7 +114,7 @@ func (a *appready) Run(t *testing.T, ctx context.Context) { require.NoError(t, err) defer resp.Body.Close() return resp.StatusCode == http.StatusInternalServerError - }, time.Second*5, 10*time.Millisecond) + }, time.Second*5, 100*time.Millisecond) _, err = client.PublishEvent(ctx, &rtv1.PublishEventRequest{ PubsubName: "mypubsub", @@ -131,7 +131,7 @@ func (a *appready) Run(t *testing.T, ctx context.Context) { default: } return a.healthCalled.Load() > called - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) a.appHealthy.Store(true) @@ -141,7 +141,7 @@ func (a *appready) Run(t *testing.T, ctx context.Context) { require.NoError(t, err) defer resp.Body.Close() return resp.StatusCode == http.StatusOK - }, time.Second*5, 10*time.Millisecond) + }, time.Second*5, 100*time.Millisecond) _, err = client.PublishEvent(ctx, &rtv1.PublishEventRequest{ PubsubName: "mypubsub", @@ -165,7 +165,7 @@ func (a *appready) Run(t *testing.T, ctx context.Context) { require.NoError(t, err) defer resp.Body.Close() return resp.StatusCode == http.StatusInternalServerError - }, time.Second*5, 10*time.Millisecond) + }, time.Second*5, 100*time.Millisecond) _, err = client.PublishEvent(ctx, &rtv1.PublishEventRequest{ PubsubName: "mypubsub", Topic: "mytopic", @@ -181,5 +181,5 @@ func (a *appready) Run(t *testing.T, ctx context.Context) { default: } return a.healthCalled.Load() > called - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) } diff --git a/tests/integration/suite/daprd/pubsub/grpc/emptymatch.go b/tests/integration/suite/daprd/pubsub/grpc/emptymatch.go deleted file mode 100644 index 09ba2c5700c..00000000000 --- a/tests/integration/suite/daprd/pubsub/grpc/emptymatch.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2024 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 implieh. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package grpc - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - rtv1 "github.com/dapr/dapr/pkg/proto/runtime/v1" - "github.com/dapr/dapr/tests/integration/framework" - "github.com/dapr/dapr/tests/integration/framework/process/daprd" - "github.com/dapr/dapr/tests/integration/framework/process/grpc/subscriber" - "github.com/dapr/dapr/tests/integration/suite" -) - -func init() { - suite.Register(new(emptyroute)) -} - -type emptyroute struct { - daprd *daprd.Daprd - sub *subscriber.Subscriber -} - -func (e *emptyroute) Setup(t *testing.T) []framework.Option { - e.sub = subscriber.New(t) - - e.daprd = daprd.New(t, - daprd.WithAppPort(e.sub.Port(t)), - daprd.WithAppProtocol("grpc"), - daprd.WithResourceFiles(`apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: mypub -spec: - type: pubsub.in-memory - version: v1 ---- -apiVersion: dapr.io/v2alpha1 -kind: Subscription -metadata: - name: mysub -spec: - pubsubname: mypub - topic: a - routes: - rules: - - path: "/a" - match: "" -`)) - - return []framework.Option{ - framework.WithProcesses(e.sub, e.daprd), - } -} - -func (e *emptyroute) Run(t *testing.T, ctx context.Context) { - e.daprd.WaitUntilRunning(t, ctx) - - client := e.daprd.GRPCClient(t, ctx) - _, err := client.PublishEvent(ctx, &rtv1.PublishEventRequest{ - PubsubName: "mypub", - Topic: "a", - Data: []byte(`{"status": "completed"}`), - }) - require.NoError(t, err) - - resp := e.sub.Receive(t, ctx) - assert.Equal(t, "/a", resp.GetPath()) -} diff --git a/tests/integration/suite/daprd/pubsub/http/emptymatch.go b/tests/integration/suite/daprd/pubsub/http/emptymatch.go deleted file mode 100644 index fd032cc980c..00000000000 --- a/tests/integration/suite/daprd/pubsub/http/emptymatch.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2024 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 implieh. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package http - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/dapr/dapr/tests/integration/framework" - "github.com/dapr/dapr/tests/integration/framework/process/daprd" - "github.com/dapr/dapr/tests/integration/framework/process/http/subscriber" - "github.com/dapr/dapr/tests/integration/suite" -) - -func init() { - suite.Register(new(emptyroute)) -} - -type emptyroute struct { - daprd *daprd.Daprd - sub *subscriber.Subscriber -} - -func (e *emptyroute) Setup(t *testing.T) []framework.Option { - e.sub = subscriber.New(t, - subscriber.WithRoutes("/a"), - ) - - e.daprd = daprd.New(t, - daprd.WithAppPort(e.sub.Port()), - daprd.WithAppProtocol("http"), - daprd.WithResourceFiles(`apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: mypub -spec: - type: pubsub.in-memory - version: v1 ---- -apiVersion: dapr.io/v2alpha1 -kind: Subscription -metadata: - name: mysub -spec: - pubsubname: mypub - topic: a - routes: - rules: - - path: /a - match: "" -`)) - - return []framework.Option{ - framework.WithProcesses(e.sub, e.daprd), - } -} - -func (e *emptyroute) Run(t *testing.T, ctx context.Context) { - e.daprd.WaitUntilRunning(t, ctx) - - e.sub.Publish(t, ctx, subscriber.PublishRequest{ - Daprd: e.daprd, - PubSubName: "mypub", - Topic: "a", - Data: `{"status": "completed"}`, - }) - resp := e.sub.Receive(t, ctx) - assert.Equal(t, "/a", resp.Route) -} diff --git a/tests/integration/suite/daprd/resources/namespace/unset/name.go b/tests/integration/suite/daprd/resources/namespace.go similarity index 55% rename from tests/integration/suite/daprd/resources/namespace/unset/name.go rename to tests/integration/suite/daprd/resources/namespace.go index 57eb97da8d0..eaa869b578a 100644 --- a/tests/integration/suite/daprd/resources/namespace/unset/name.go +++ b/tests/integration/suite/daprd/resources/namespace.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Dapr Authors +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 @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unset +package resources import ( "context" @@ -19,70 +19,86 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" rtv1 "github.com/dapr/dapr/pkg/proto/runtime/v1" "github.com/dapr/dapr/tests/integration/framework" "github.com/dapr/dapr/tests/integration/framework/process/daprd" + "github.com/dapr/dapr/tests/integration/framework/process/exec" "github.com/dapr/dapr/tests/integration/suite" ) func init() { - suite.Register(new(name)) + suite.Register(new(namespace)) } -// name ensures that when the NAMESPACE env var is *not* set, all components will -// be loaded into as the default namespace, regardless of whether they have a -// namespace set in their metadata. -type name struct { +// namespace ensures that the component disk loader does not load components +// from different namespaces. +type namespace struct { daprd *daprd.Daprd } -func (n *name) Setup(t *testing.T) []framework.Option { +func (n *namespace) Setup(t *testing.T) []framework.Option { n.daprd = daprd.New(t, daprd.WithResourceFiles(` apiVersion: dapr.io/v1alpha1 kind: Component metadata: - name: abc - namespace: abc + name: abc spec: - type: state.in-memory - version: v1 + type: state.in-memory + version: v1 --- +# This component is skipped because it is in a different namespace. Even though +# it has the same name, daprd will not error as it is not loaded. apiVersion: dapr.io/v1alpha1 kind: Component metadata: - name: 123 + name: abc + namespace: notmynamespace spec: - type: state.in-memory - version: v1 + type: state.in-memory + version: v1 --- apiVersion: dapr.io/v1alpha1 kind: Component metadata: - name: 456 - namespace: foobar + name: ghi + namespace: notmynamespace spec: - type: state.in-memory - version: v1 + type: state.in-memory + version: v1 --- apiVersion: dapr.io/v1alpha1 kind: Component metadata: - name: 789 - namespace: mynamespace + name: def + namespace: mynamespace spec: - type: state.in-memory - version: v1 -`)) + type: state.in-memory + version: v1 +`), + daprd.WithExecOptions( + exec.WithEnvVars(t, "NAMESPACE", "mynamespace"), + ), + ) return []framework.Option{ framework.WithProcesses(n.daprd), } } -func (n *name) Run(t *testing.T, ctx context.Context) { +func (n *namespace) Run(t *testing.T, ctx context.Context) { n.daprd.WaitUntilRunning(t, ctx) - resp, err := n.daprd.GRPCClient(t, ctx).GetMetadata(ctx, new(rtv1.GetMetadataRequest)) + conn, err := grpc.DialContext(ctx, n.daprd.GRPCAddress(), + grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock(), + ) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, conn.Close()) }) + + client := rtv1.NewDaprClient(conn) + + resp, err := client.GetMetadata(ctx, new(rtv1.GetMetadataRequest)) require.NoError(t, err) assert.ElementsMatch(t, []*rtv1.RegisteredComponents{ { @@ -90,15 +106,7 @@ func (n *name) Run(t *testing.T, ctx context.Context) { Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, { - Name: "123", Type: "state.in-memory", Version: "v1", - Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, - }, - { - Name: "456", Type: "state.in-memory", Version: "v1", - Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, - }, - { - Name: "789", Type: "state.in-memory", Version: "v1", + Name: "def", Type: "state.in-memory", Version: "v1", Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, }, }, resp.GetRegisteredComponents()) diff --git a/tests/integration/suite/daprd/resources/namespace/namespace.go b/tests/integration/suite/daprd/resources/namespace/namespace.go deleted file mode 100644 index 9527717d289..00000000000 --- a/tests/integration/suite/daprd/resources/namespace/namespace.go +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2024 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 namespace - -import ( - _ "github.com/dapr/dapr/tests/integration/suite/daprd/resources/namespace/set" - _ "github.com/dapr/dapr/tests/integration/suite/daprd/resources/namespace/unset" -) diff --git a/tests/integration/suite/daprd/resources/namespace/set/name.go b/tests/integration/suite/daprd/resources/namespace/set/name.go deleted file mode 100644 index 6502b232bf6..00000000000 --- a/tests/integration/suite/daprd/resources/namespace/set/name.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright 2024 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 set - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - rtv1 "github.com/dapr/dapr/pkg/proto/runtime/v1" - "github.com/dapr/dapr/tests/integration/framework" - "github.com/dapr/dapr/tests/integration/framework/process/daprd" - "github.com/dapr/dapr/tests/integration/suite" -) - -func init() { - suite.Register(new(name)) -} - -// name ensures that when the NAMESPACE env var is set, components will only be -// loaded if they reside in the same namespace (or when namespace is omitted). -type name struct { - daprd *daprd.Daprd -} - -func (n *name) Setup(t *testing.T) []framework.Option { - n.daprd = daprd.New(t, daprd.WithResourceFiles(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: abc - namespace: abc -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 456 - namespace: foobar -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 789 - namespace: mynamespace -spec: - type: state.in-memory - version: v1 -`), - daprd.WithNamespace("mynamespace"), - ) - return []framework.Option{ - framework.WithProcesses(n.daprd), - } -} - -func (n *name) Run(t *testing.T, ctx context.Context) { - n.daprd.WaitUntilRunning(t, ctx) - - resp, err := n.daprd.GRPCClient(t, ctx).GetMetadata(ctx, new(rtv1.GetMetadataRequest)) - require.NoError(t, err) - assert.ElementsMatch(t, []*rtv1.RegisteredComponents{ - { - Name: "123", Type: "state.in-memory", Version: "v1", - Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, - }, - { - Name: "789", Type: "state.in-memory", Version: "v1", - Capabilities: []string{"ETAG", "TRANSACTIONAL", "TTL", "DELETE_WITH_PREFIX", "ACTOR"}, - }, - }, resp.GetRegisteredComponents()) -} diff --git a/tests/integration/suite/daprd/resources/namespace/set/unique.go b/tests/integration/suite/daprd/resources/namespace/set/unique.go deleted file mode 100644 index f4af38b29c3..00000000000 --- a/tests/integration/suite/daprd/resources/namespace/set/unique.go +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright 2024 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 set - -import ( - "context" - "testing" - - "github.com/dapr/dapr/tests/integration/framework" - "github.com/dapr/dapr/tests/integration/framework/process/daprd" - "github.com/dapr/dapr/tests/integration/framework/process/logline" - "github.com/dapr/dapr/tests/integration/suite" -) - -func init() { - suite.Register(new(unique)) -} - -// unique tests that components loaded in self hosted mode in the same -// namespace and same name will cause a component conflict. -type unique struct { - daprd *daprd.Daprd - - logline *logline.LogLine -} - -func (u *unique) Setup(t *testing.T) []framework.Option { - u.logline = logline.New(t, logline.WithStdoutLineContains( - `Fatal error from runtime: failed to load components: duplicate definition of component name abc (pubsub.in-memory/v1) with existing abc (state.in-memory/v1)\nduplicate definition of component name 123 (state.in-memory/v1) with existing 123 (state.in-memory/v1)\nduplicate definition of component name 123 (pubsub.in-memory/v1) with existing 123 (state.in-memory/v1)`, - )) - - u.daprd = daprd.New(t, daprd.WithResourceFiles(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: abc - namespace: mynamespace -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: abc -spec: - type: pubsub.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: abc - namespace: foobar -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 - namespace: mynamespace -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 -spec: - type: pubsub.in-memory - version: v1 -`), - daprd.WithNamespace("mynamespace"), - daprd.WithExit1(), - daprd.WithLogLineStdout(u.logline), - ) - return []framework.Option{ - framework.WithProcesses(u.logline, u.daprd), - } -} - -func (u *unique) Run(t *testing.T, ctx context.Context) { - u.logline.EventuallyFoundAll(t) -} diff --git a/tests/integration/suite/daprd/resources/namespace/unset/unique.go b/tests/integration/suite/daprd/resources/namespace/unset/unique.go deleted file mode 100644 index 41133ac3924..00000000000 --- a/tests/integration/suite/daprd/resources/namespace/unset/unique.go +++ /dev/null @@ -1,107 +0,0 @@ -/* -Copyright 2024 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 unset - -import ( - "context" - "testing" - - "github.com/dapr/dapr/tests/integration/framework" - "github.com/dapr/dapr/tests/integration/framework/process/daprd" - "github.com/dapr/dapr/tests/integration/framework/process/logline" - "github.com/dapr/dapr/tests/integration/suite" -) - -func init() { - suite.Register(new(unique)) -} - -// unique tests that components loaded in self hosted mode in the same -// namespace and same name will cause a component conflict. When the NAMESPACE -// environment variable isn't set, all components are loaded into the default -// namespace. -type unique struct { - daprd *daprd.Daprd - - logline *logline.LogLine -} - -func (u *unique) Setup(t *testing.T) []framework.Option { - u.logline = logline.New(t, logline.WithStdoutLineContains( - `Fatal error from runtime: failed to load components: duplicate definition of component name abc (pubsub.in-memory/v1) with existing abc (state.in-memory/v1)\nduplicate definition of component name abc (state.in-memory/v1) with existing abc (state.in-memory/v1)\nduplicate definition of component name 123 (state.in-memory/v1) with existing 123 (state.in-memory/v1)\nduplicate definition of component name 123 (pubsub.in-memory/v1) with existing 123 (state.in-memory/v1)`, - )) - - u.daprd = daprd.New(t, daprd.WithResourceFiles(` -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: abc - namespace: mynamespace -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: abc -spec: - type: pubsub.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: abc - namespace: foobar -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 - namespace: mynamespace -spec: - type: state.in-memory - version: v1 ---- -apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: 123 -spec: - type: pubsub.in-memory - version: v1 -`), - daprd.WithExit1(), - daprd.WithLogLineStdout(u.logline), - ) - return []framework.Option{ - framework.WithProcesses(u.logline, u.daprd), - } -} - -func (u *unique) Run(t *testing.T, ctx context.Context) { - u.logline.EventuallyFoundAll(t) -} diff --git a/tests/integration/suite/daprd/resources/resource.go b/tests/integration/suite/daprd/resources/resource.go deleted file mode 100644 index f30d0e658fe..00000000000 --- a/tests/integration/suite/daprd/resources/resource.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -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 resources - -import ( - _ "github.com/dapr/dapr/tests/integration/suite/daprd/resources/namespace" -) diff --git a/tests/integration/suite/daprd/resources/uniquename.go b/tests/integration/suite/daprd/resources/uniquename.go index 157e3588f4f..9e00e3523cc 100644 --- a/tests/integration/suite/daprd/resources/uniquename.go +++ b/tests/integration/suite/daprd/resources/uniquename.go @@ -48,7 +48,7 @@ func (u *uniquename) Setup(t *testing.T) []framework.Option { u.logline = logline.New(t, logline.WithStdoutLineContains( - "Fatal error from runtime: failed to load components: duplicate definition of component name foo (state.in-memory/v1) with existing foo (secretstores.local.file/v1)", + "Fatal error from runtime: process component foo error: [INIT_COMPONENT_FAILURE]: initialization error occurred for foo (state.in-memory/v1): component foo already exists", ), ) @@ -87,5 +87,5 @@ spec: } func (u *uniquename) Run(t *testing.T, ctx context.Context) { - assert.Eventually(t, u.logline.FoundAll, time.Second*5, time.Millisecond*10) + assert.Eventually(t, u.logline.FoundAll, time.Second*5, time.Millisecond*100) } diff --git a/tests/integration/suite/daprd/secret/http/fuzz.go b/tests/integration/suite/daprd/secret/http/fuzz.go index 1c394592a58..6dd6ae39641 100644 --- a/tests/integration/suite/daprd/secret/http/fuzz.go +++ b/tests/integration/suite/daprd/secret/http/fuzz.go @@ -122,7 +122,7 @@ func (f *fuzzsecret) Run(t *testing.T, ctx context.Context) { assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, client, f.daprd.HTTPPort()), 1) - }, time.Second*20, time.Millisecond*10) + }, time.Second*20, time.Millisecond*100) pt := util.NewParallel(t) for key, value := range f.values { diff --git a/tests/integration/suite/daprd/serviceinvocation/grpc/slowappstartup.go b/tests/integration/suite/daprd/serviceinvocation/grpc/slowappstartup.go index 3e164386a18..1b157ca2e41 100644 --- a/tests/integration/suite/daprd/serviceinvocation/grpc/slowappstartup.go +++ b/tests/integration/suite/daprd/serviceinvocation/grpc/slowappstartup.go @@ -115,6 +115,6 @@ func (s *slowappstartup) Run(t *testing.T, ctx context.Context) { if !assert.NoError(c, err) { require.ErrorContains(c, err, "app is not in a healthy state") } - }, time.Second*3, time.Millisecond*10) + }, time.Second*3, time.Millisecond*100) require.NoError(t, resp.GetData().UnmarshalTo(&pingResp)) } diff --git a/tests/integration/suite/daprd/serviceinvocation/http/httpendpoints.go b/tests/integration/suite/daprd/serviceinvocation/http/httpendpoints.go index f3bd8639ed9..d02e48724f6 100644 --- a/tests/integration/suite/daprd/serviceinvocation/http/httpendpoints.go +++ b/tests/integration/suite/daprd/serviceinvocation/http/httpendpoints.go @@ -160,7 +160,7 @@ func (h *httpendpoints) Run(t *testing.T, ctx context.Context) { require.NoError(t, resp.Body.Close()) endpoints, ok := body["httpEndpoints"] _ = assert.True(t, ok) && assert.Len(t, endpoints.([]any), 2) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) } t.Run("invoke http endpoint", func(t *testing.T) { diff --git a/tests/integration/suite/daprd/shutdown/block/app/healthy.go b/tests/integration/suite/daprd/shutdown/block/app/healthy.go index 2b091b3ba29..df89b17082b 100644 --- a/tests/integration/suite/daprd/shutdown/block/app/healthy.go +++ b/tests/integration/suite/daprd/shutdown/block/app/healthy.go @@ -148,7 +148,7 @@ func (h *healthy) Run(t *testing.T, ctx context.Context) { healthzCalled := h.healthzCalled.Load() assert.Eventually(t, func() bool { return h.healthzCalled.Load() > healthzCalled - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) _, err = client.PublishEvent(ctx, &rtv1.PublishEventRequest{ PubsubName: "foo", @@ -175,7 +175,7 @@ func (h *healthy) Run(t *testing.T, ctx context.Context) { assert.Eventually(t, func() bool { return h.healthzCalled.Load() > healthzCalled - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) assert.EventuallyWithT(t, func(c *assert.CollectT) { _, err = client.PublishEvent(ctx, &rtv1.PublishEventRequest{ @@ -185,7 +185,7 @@ func (h *healthy) Run(t *testing.T, ctx context.Context) { }) //nolint:testifylint assert.Error(c, err) - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) _, err = client.SaveState(ctx, &rtv1.SaveStateRequest{ StoreName: "mystore", States: []*commonv1.StateItem{ diff --git a/tests/integration/suite/daprd/shutdown/block/app/unhealthy.go b/tests/integration/suite/daprd/shutdown/block/app/unhealthy.go index 5f5c346747d..4f0a0b75195 100644 --- a/tests/integration/suite/daprd/shutdown/block/app/unhealthy.go +++ b/tests/integration/suite/daprd/shutdown/block/app/unhealthy.go @@ -142,5 +142,5 @@ func (u *unhealthy) Run(t *testing.T, ctx context.Context) { }) //nolint:testifylint assert.ErrorContains(c, err, "app is not in a healthy state") - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) } diff --git a/tests/integration/suite/daprd/state/grpc/fuzz.go b/tests/integration/suite/daprd/state/grpc/fuzz.go index b7f061160ad..589e7a9a746 100644 --- a/tests/integration/suite/daprd/state/grpc/fuzz.go +++ b/tests/integration/suite/daprd/state/grpc/fuzz.go @@ -170,7 +170,7 @@ func (f *fuzzstate) Run(t *testing.T, ctx context.Context) { assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, util.HTTPClient(t), f.daprd.HTTPPort()), 1) - }, time.Second*20, time.Millisecond*10) + }, time.Second*20, time.Millisecond*100) client := f.daprd.GRPCClient(t, ctx) diff --git a/tests/integration/suite/daprd/state/grpc/ttl.go b/tests/integration/suite/daprd/state/grpc/ttl.go index dcaca0a1f04..24044d632cd 100644 --- a/tests/integration/suite/daprd/state/grpc/ttl.go +++ b/tests/integration/suite/daprd/state/grpc/ttl.go @@ -76,6 +76,6 @@ func (l *ttl) Run(t *testing.T, ctx context.Context) { }) require.NoError(c, err) assert.Empty(c, resp.GetData()) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) }) } diff --git a/tests/integration/suite/daprd/state/http/encryption.go b/tests/integration/suite/daprd/state/http/encryption.go deleted file mode 100644 index fd865bd2cb0..00000000000 --- a/tests/integration/suite/daprd/state/http/encryption.go +++ /dev/null @@ -1,134 +0,0 @@ -/* -Copyright 2024 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 implieh. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package http - -import ( - "context" - "crypto/sha256" - "encoding/hex" - "fmt" - "io" - "net/http" - "os" - "path/filepath" - "strings" - "testing" - - "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" - "github.com/dapr/dapr/tests/integration/framework/util" - "github.com/dapr/dapr/tests/integration/suite" -) - -func init() { - suite.Register(new(encryption)) -} - -type encryption struct { - daprd *daprd.Daprd -} - -func SHA256(data []byte) []byte { - h := sha256.New() - h.Write(data) - return h.Sum(nil) -} - -func generateAesRandom(keyword string) (key []byte) { - data := []byte(keyword) - - hashs := SHA256(SHA256(data)) - key = hashs[0:16] - - return key -} - -func (e *encryption) Setup(t *testing.T) []framework.Option { - tmp := t.TempDir() - secretsFile := filepath.Join(tmp, "secrets.json") - - scr := generateAesRandom(strings.Repeat("a", 128)) - key := hex.EncodeToString(scr) - - secretsJSON := fmt.Sprintf(`{ "key": "%s"}`, key) - - secretStore := fmt.Sprintf(`apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: secretstore -spec: - type: secretstores.local.file - version: v1 - metadata: - - name: secretsFile - value: '%s' - `, secretsFile) - - stateStore := `apiVersion: dapr.io/v1alpha1 -kind: Component -metadata: - name: mystore -spec: - type: state.in-memory - version: v1 - metadata: - - name: primaryEncryptionKey - secretKeyRef: - name: key -auth: - secretStore: secretstore -` - - require.NoError(t, os.WriteFile(secretsFile, []byte(secretsJSON), 0o600)) - e.daprd = daprd.New(t, daprd.WithResourceFiles(secretStore, stateStore)) - - return []framework.Option{ - framework.WithProcesses(e.daprd), - } -} - -func (e *encryption) Run(t *testing.T, ctx context.Context) { - e.daprd.WaitUntilRunning(t, ctx) - - httpClient := util.HTTPClient(t) - postURL := fmt.Sprintf("http://localhost:%d/v1.0/state/mystore", e.daprd.HTTPPort()) - getURL := fmt.Sprintf("http://localhost:%d/v1.0/state/mystore/key1", e.daprd.HTTPPort()) - - t.Run("valid encrypted save", func(t *testing.T) { - req, err := http.NewRequestWithContext(ctx, http.MethodPost, postURL, strings.NewReader(`[{"key": "key1", "value": "value1"}]`)) - require.NoError(t, err) - resp, err := httpClient.Do(req) - require.NoError(t, err) - assert.Equal(t, http.StatusNoContent, resp.StatusCode) - body, err := io.ReadAll(resp.Body) - require.NoError(t, err) - require.NoError(t, resp.Body.Close()) - assert.Empty(t, string(body)) - }) - - t.Run("valid encrypted get", func(t *testing.T) { - req, err := http.NewRequestWithContext(ctx, http.MethodGet, getURL, nil) - require.NoError(t, err) - resp, err := httpClient.Do(req) - require.NoError(t, err) - assert.Equal(t, http.StatusOK, resp.StatusCode) - body, err := io.ReadAll(resp.Body) - assert.Equal(t, "value1", string(body)) - require.NoError(t, err) - require.NoError(t, resp.Body.Close()) - }) -} diff --git a/tests/integration/suite/daprd/state/http/fuzz.go b/tests/integration/suite/daprd/state/http/fuzz.go index 3c88c284677..e342d36efea 100644 --- a/tests/integration/suite/daprd/state/http/fuzz.go +++ b/tests/integration/suite/daprd/state/http/fuzz.go @@ -156,7 +156,7 @@ func (f *fuzzstate) Run(t *testing.T, ctx context.Context) { assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.Len(c, util.GetMetaComponents(c, ctx, httpClient, f.daprd.HTTPPort()), 1) - }, time.Second*20, time.Millisecond*10) + }, time.Second*20, time.Millisecond*100) t.Run("get", func(t *testing.T) { pt := util.NewParallel(t) diff --git a/tests/integration/suite/daprd/state/http/ttl.go b/tests/integration/suite/daprd/state/http/ttl.go index 4e9bcaa4a01..98c4748e525 100644 --- a/tests/integration/suite/daprd/state/http/ttl.go +++ b/tests/integration/suite/daprd/state/http/ttl.go @@ -92,6 +92,6 @@ func (l *ttl) Run(t *testing.T, ctx context.Context) { require.NoError(c, err) require.NoError(t, resp.Body.Close()) assert.Equal(c, http.StatusNoContent, resp.StatusCode) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) }) } diff --git a/tests/integration/suite/daprd/workflow/basic.go b/tests/integration/suite/daprd/workflow/basic.go index 9bb75230561..121a9c9ae50 100644 --- a/tests/integration/suite/daprd/workflow/basic.go +++ b/tests/integration/suite/daprd/workflow/basic.go @@ -174,7 +174,7 @@ func (b *basic) Run(t *testing.T, ctx context.Context) { } } return true - }, 2*time.Second, 10*time.Millisecond) + }, 2*time.Second, 100*time.Millisecond) // Terminate the root orchestration b.terminateWorkflow(t, ctx, string(id)) diff --git a/tests/integration/suite/healthz/app.go b/tests/integration/suite/healthz/app.go index 43098e78fd3..d47c77149d4 100644 --- a/tests/integration/suite/healthz/app.go +++ b/tests/integration/suite/healthz/app.go @@ -98,7 +98,7 @@ func (a *app) Run(t *testing.T, ctx context.Context) { require.NoError(t, err) require.NoError(t, resp.Body.Close()) return resp.StatusCode == http.StatusOK && string(body) == "GET /myfunc" - }, time.Second*5, 10*time.Millisecond, "expected dapr to report app healthy when /foo returns 200") + }, time.Second*5, 100*time.Millisecond, "expected dapr to report app healthy when /foo returns 200") a.healthy.Store(false) @@ -114,5 +114,5 @@ func (a *app) Run(t *testing.T, ctx context.Context) { require.NoError(t, resp.Body.Close()) return resp.StatusCode == http.StatusInternalServerError && strings.Contains(string(body), "app is not in a healthy state") - }, time.Second*20, 10*time.Millisecond, "expected dapr to report app unhealthy now /foo returns 503") + }, time.Second*20, 100*time.Millisecond, "expected dapr to report app unhealthy now /foo returns 503") } diff --git a/tests/integration/suite/healthz/daprd.go b/tests/integration/suite/healthz/daprd.go index 9f42fab29b8..203a2088c17 100644 --- a/tests/integration/suite/healthz/daprd.go +++ b/tests/integration/suite/healthz/daprd.go @@ -59,5 +59,5 @@ func (d *daprd) Run(t *testing.T, ctx context.Context) { require.NoError(t, err) require.NoError(t, resp.Body.Close()) return resp.StatusCode == http.StatusNoContent - }, time.Second*10, 10*time.Millisecond) + }, time.Second*10, 100*time.Millisecond) } diff --git a/tests/integration/suite/healthz/operator.go b/tests/integration/suite/healthz/operator.go index bcb188e106b..0a76401b775 100644 --- a/tests/integration/suite/healthz/operator.go +++ b/tests/integration/suite/healthz/operator.go @@ -76,5 +76,5 @@ func (o *operator) Run(t *testing.T, ctx context.Context) { require.NoError(t, err) require.NoError(t, resp.Body.Close()) return resp.StatusCode == http.StatusOK - }, time.Second*10, 10*time.Millisecond) + }, time.Second*10, 100*time.Millisecond) } diff --git a/tests/integration/suite/healthz/placement.go b/tests/integration/suite/healthz/placement.go index 72b2643524a..8b66347b6e0 100644 --- a/tests/integration/suite/healthz/placement.go +++ b/tests/integration/suite/healthz/placement.go @@ -59,5 +59,5 @@ func (p *placement) Run(t *testing.T, ctx context.Context) { require.NoError(t, err) require.NoError(t, resp.Body.Close()) return http.StatusOK == resp.StatusCode - }, time.Second*10, 10*time.Millisecond) + }, time.Second*10, 100*time.Millisecond) } diff --git a/tests/integration/suite/healthz/sentry.go b/tests/integration/suite/healthz/sentry.go index cb86eb2916a..1c2400ba152 100644 --- a/tests/integration/suite/healthz/sentry.go +++ b/tests/integration/suite/healthz/sentry.go @@ -57,5 +57,5 @@ func (s *sentry) Run(t *testing.T, ctx context.Context) { require.NoError(t, err) require.NoError(t, resp.Body.Close()) return http.StatusOK == resp.StatusCode - }, time.Second*10, 10*time.Millisecond) + }, time.Second*10, 100*time.Millisecond) } diff --git a/tests/integration/suite/operator/api/listcomponents.go b/tests/integration/suite/operator/api/listcomponents.go index 07ccf1f5cdf..45f3a955c88 100644 --- a/tests/integration/suite/operator/api/listcomponents.go +++ b/tests/integration/suite/operator/api/listcomponents.go @@ -124,7 +124,7 @@ func (l *listcomponents) Run(t *testing.T, ctx context.Context) { resp, err = client.ListComponents(ctx, &operatorv1.ListComponentsRequest{Namespace: "default"}) require.NoError(t, err) assert.Len(c, resp.GetComponents(), 2) - }, time.Second*20, time.Millisecond*10) + }, time.Second*20, time.Millisecond*100) b1, err := json.Marshal(l.comp1) require.NoError(t, err) diff --git a/tests/integration/suite/placement/apilevel/no_max.go b/tests/integration/suite/placement/apilevel/no_max.go index e20529e8b3c..c748b3d6d13 100644 --- a/tests/integration/suite/placement/apilevel/no_max.go +++ b/tests/integration/suite/placement/apilevel/no_max.go @@ -41,7 +41,6 @@ type noMax struct { func (n *noMax) Setup(t *testing.T) []framework.Option { n.place = placement.New(t, placement.WithMetadataEnabled(true), - placement.WithMaxAPILevel(-1), ) return []framework.Option{ @@ -101,7 +100,7 @@ func (n *noMax) Run(t *testing.T, ctx context.Context) { var tableVersion int require.EventuallyWithT(t, func(t *assert.CollectT) { tableVersion = n.place.CheckAPILevelInState(t, httpClient, level1) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) // Register the second host with the higher API level msg2 := &placementv1pb.Host{ @@ -144,7 +143,7 @@ func (n *noMax) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(t *assert.CollectT) { newTableVersion := n.place.CheckAPILevelInState(t, httpClient, level1) assert.Greater(t, newTableVersion, tableVersion) - }, 10*time.Second, 10*time.Millisecond) + }, 10*time.Second, 100*time.Millisecond) // Stop the first host, and the in API level should increase cancel1() @@ -155,7 +154,7 @@ func (n *noMax) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(t *assert.CollectT) { tableVersion = n.place.CheckAPILevelInState(t, httpClient, level2) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) // Trying to register a host with version 5 should fail n.place.AssertRegisterHostFails(t, ctx, 5) @@ -167,7 +166,7 @@ func (n *noMax) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(t *assert.CollectT) { newTableVersion := n.place.CheckAPILevelInState(t, httpClient, level2) assert.Greater(t, newTableVersion, tableVersion) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) // Trying to register a host with version 10 should fail n.place.AssertRegisterHostFails(t, ctx, level1) diff --git a/tests/integration/suite/placement/apilevel/with_max.go b/tests/integration/suite/placement/apilevel/with_max.go index e7d8c84a46b..ead407e8c94 100644 --- a/tests/integration/suite/placement/apilevel/with_max.go +++ b/tests/integration/suite/placement/apilevel/with_max.go @@ -100,7 +100,7 @@ func (n *withMax) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(t *assert.CollectT) { n.place.CheckAPILevelInState(t, httpClient, level1) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) // Register the second host with the higher API level msg2 := &placementv1pb.Host{ @@ -139,7 +139,7 @@ func (n *withMax) Run(t *testing.T, ctx context.Context) { // API level should not increase require.EventuallyWithT(t, func(t *assert.CollectT) { n.place.CheckAPILevelInState(t, httpClient, level1) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) // Stop the first host, and the in API level should increase to the max (25) cancel1() @@ -150,5 +150,5 @@ func (n *withMax) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(t *assert.CollectT) { n.place.CheckAPILevelInState(t, httpClient, 25) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) } diff --git a/tests/integration/suite/placement/apilevel/with_min.go b/tests/integration/suite/placement/apilevel/with_min.go index faee5769078..72d2a525a0b 100644 --- a/tests/integration/suite/placement/apilevel/with_min.go +++ b/tests/integration/suite/placement/apilevel/with_min.go @@ -40,7 +40,6 @@ type withMin struct { func (n *withMin) Setup(t *testing.T) []framework.Option { n.place = placement.New(t, - placement.WithMaxAPILevel(-1), placement.WithMinAPILevel(20), placement.WithMetadataEnabled(true), ) @@ -66,7 +65,7 @@ func (n *withMin) Run(t *testing.T, ctx context.Context) { // API level should be lower require.EventuallyWithT(t, func(t *assert.CollectT) { n.place.CheckAPILevelInState(t, httpClient, level1) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) // Trying to register a host with version 5 should fail n.place.AssertRegisterHostFails(t, ctx, 5) @@ -107,7 +106,7 @@ func (n *withMin) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(t *assert.CollectT) { n.place.CheckAPILevelInState(t, httpClient, level1) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) // Register the second host with the higher API level msg2 := &placementv1pb.Host{ @@ -141,7 +140,7 @@ func (n *withMin) Run(t *testing.T, ctx context.Context) { // API level should not increase require.EventuallyWithT(t, func(t *assert.CollectT) { n.place.CheckAPILevelInState(t, httpClient, level1) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) // Stop the first host, and the in API level should increase to the higher one (30) cancel1() @@ -152,5 +151,5 @@ func (n *withMin) Run(t *testing.T, ctx context.Context) { require.EventuallyWithT(t, func(t *assert.CollectT) { n.place.CheckAPILevelInState(t, httpClient, level2) - }, 5*time.Second, 10*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) } diff --git a/tests/integration/suite/placement/authz/mtls.go b/tests/integration/suite/placement/authz/mtls.go index ac8e2b3ed8f..2e289c702cf 100644 --- a/tests/integration/suite/placement/authz/mtls.go +++ b/tests/integration/suite/placement/authz/mtls.go @@ -123,7 +123,7 @@ func waitForUnlock(t *testing.T, stream v1pb.Placement_ReportDaprStatusClient) { if assert.NoError(c, err) { assert.Equal(c, "unlock", resp.GetOperation()) } - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) } func establishStream(t *testing.T, ctx context.Context, client v1pb.PlacementClient) v1pb.Placement_ReportDaprStatusClient { @@ -144,6 +144,6 @@ func establishStream(t *testing.T, ctx context.Context, client v1pb.PlacementCli //nolint:testifylint assert.NoError(c, err) } - }, time.Second*5, time.Millisecond*10) + }, time.Second*5, time.Millisecond*100) return stream } diff --git a/tests/integration/suite/placement/quorum/insecure.go b/tests/integration/suite/placement/quorum/insecure.go index 24a440e7698..c28a8393693 100644 --- a/tests/integration/suite/placement/quorum/insecure.go +++ b/tests/integration/suite/placement/quorum/insecure.go @@ -133,7 +133,7 @@ func (i *insecure) Run(t *testing.T, ctx context.Context) { return false } return true - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) err = stream.Send(&v1pb.Host{ Name: "app-1", @@ -154,5 +154,5 @@ func (i *insecure) Run(t *testing.T, ctx context.Context) { assert.Contains(c, o.GetTables().GetEntries(), "entity-1") assert.Contains(c, o.GetTables().GetEntries(), "entity-2") } - }, time.Second*20, time.Millisecond*10) + }, time.Second*20, time.Millisecond*100) } diff --git a/tests/integration/suite/placement/quorum/jwks.go b/tests/integration/suite/placement/quorum/jwks.go index 4d0c11d078a..53d08a443cc 100644 --- a/tests/integration/suite/placement/quorum/jwks.go +++ b/tests/integration/suite/placement/quorum/jwks.go @@ -179,7 +179,7 @@ func (j *jwks) Run(t *testing.T, ctx context.Context) { return false } return true - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) err = stream.Send(&v1pb.Host{ Name: "app-1", @@ -200,7 +200,7 @@ func (j *jwks) Run(t *testing.T, ctx context.Context) { assert.Contains(c, o.GetTables().GetEntries(), "entity-1") assert.Contains(c, o.GetTables().GetEntries(), "entity-2") } - }, time.Second*20, time.Millisecond*10) + }, time.Second*20, time.Millisecond*100) } func (j *jwks) signJWT(t *testing.T, jwkPriv jwk.Key, id string) []byte { diff --git a/tests/integration/suite/placement/quorum/notls.go b/tests/integration/suite/placement/quorum/notls.go index 2160de3ed60..18ce8a068ca 100644 --- a/tests/integration/suite/placement/quorum/notls.go +++ b/tests/integration/suite/placement/quorum/notls.go @@ -94,7 +94,7 @@ func (n *notls) Run(t *testing.T, ctx context.Context) { return false } return true - }, time.Second*10, time.Millisecond*10) + }, time.Second*10, time.Millisecond*100) err := stream.Send(&v1pb.Host{ Name: "app-1", @@ -115,5 +115,5 @@ func (n *notls) Run(t *testing.T, ctx context.Context) { assert.Contains(c, o.GetTables().GetEntries(), "entity-1") assert.Contains(c, o.GetTables().GetEntries(), "entity-2") } - }, time.Second*20, time.Millisecond*10) + }, time.Second*20, time.Millisecond*100) } diff --git a/tests/integration/suite/placement/vnodes/level10.go b/tests/integration/suite/placement/vnodes/level10.go new file mode 100644 index 00000000000..bd2e1bd9fa6 --- /dev/null +++ b/tests/integration/suite/placement/vnodes/level10.go @@ -0,0 +1,76 @@ +/* +Copyright 2024 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 vnodes + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + placementv1pb "github.com/dapr/dapr/pkg/proto/placement/v1" + "github.com/dapr/dapr/tests/integration/framework" + "github.com/dapr/dapr/tests/integration/framework/process/placement" + "github.com/dapr/dapr/tests/integration/suite" +) + +func init() { + suite.Register(new(vNodesAPILevel10)) +} + +type vNodesAPILevel10 struct { + place *placement.Placement +} + +func (v *vNodesAPILevel10) Setup(t *testing.T) []framework.Option { + v.place = placement.New(t, + placement.WithMetadataEnabled(true), + ) + + return []framework.Option{ + framework.WithProcesses(v.place), + } +} + +func (v *vNodesAPILevel10) Run(t *testing.T, ctx context.Context) { + v.place.WaitUntilRunning(t, ctx) + + // Register the host, with API level 10 (pre v1.13) + msg := &placementv1pb.Host{ + Name: "myapp", + Port: 1234, + Entities: []string{"someactor"}, + Id: "myapp1", + ApiLevel: uint32(10), + } + placementMessageCh := v.place.RegisterHost(t, ctx, msg) + + require.EventuallyWithT(t, func(t *assert.CollectT) { + select { + case <-ctx.Done(): + return + case placementTables := <-placementMessageCh: + if ctx.Err() != nil { + return + } + assert.Equal(t, uint32(10), placementTables.GetApiLevel()) + assert.Len(t, placementTables.GetEntries(), 1) + // Check that the placement service sends the vnodes, because of the older cluster API level + assert.Len(t, placementTables.GetEntries()["someactor"].GetHosts(), int(placementTables.GetReplicationFactor())) + assert.Len(t, placementTables.GetEntries()["someactor"].GetSortedSet(), int(placementTables.GetReplicationFactor())) + } + }, 10*time.Second, 100*time.Millisecond) +} diff --git a/tests/integration/suite/placement/vnodes/level20.go b/tests/integration/suite/placement/vnodes/level20.go new file mode 100644 index 00000000000..8c0eae93730 --- /dev/null +++ b/tests/integration/suite/placement/vnodes/level20.go @@ -0,0 +1,76 @@ +/* +Copyright 2024 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 vnodes + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + placementv1pb "github.com/dapr/dapr/pkg/proto/placement/v1" + "github.com/dapr/dapr/tests/integration/framework" + "github.com/dapr/dapr/tests/integration/framework/process/placement" + "github.com/dapr/dapr/tests/integration/suite" +) + +func init() { + suite.Register(new(vNodesAPILevel20)) +} + +type vNodesAPILevel20 struct { + place *placement.Placement +} + +func (v *vNodesAPILevel20) Setup(t *testing.T) []framework.Option { + v.place = placement.New(t, + placement.WithMetadataEnabled(true), + ) + + return []framework.Option{ + framework.WithProcesses(v.place), + } +} + +func (v *vNodesAPILevel20) Run(t *testing.T, ctx context.Context) { + v.place.WaitUntilRunning(t, ctx) + + // Register the host, with API level 20 (v1.13+) + msg := &placementv1pb.Host{ + Name: "myapp", + Port: 1234, + Entities: []string{"someactor"}, + Id: "myapp", + ApiLevel: uint32(20), + } + placementMessageCh := v.place.RegisterHost(t, ctx, msg) + + require.EventuallyWithT(t, func(t *assert.CollectT) { + select { + case <-ctx.Done(): + return + case placementTables := <-placementMessageCh: + if ctx.Err() != nil { + return + } + assert.Equal(t, uint32(20), msg.GetApiLevel()) + assert.Len(t, placementTables.GetEntries(), 1) + // Check that the vnodes are not sent, because the minimum API level of the cluster is 20+ + assert.Empty(t, placementTables.GetEntries()["someactor"].GetHosts()) + assert.Empty(t, placementTables.GetEntries()["someactor"].GetSortedSet()) + } + }, 10*time.Second, 100*time.Millisecond) +} diff --git a/tests/integration/suite/placement/vnodes/upgrade.go b/tests/integration/suite/placement/vnodes/upgrade.go new file mode 100644 index 00000000000..67e26816bf3 --- /dev/null +++ b/tests/integration/suite/placement/vnodes/upgrade.go @@ -0,0 +1,132 @@ +/* +Copyright 2024 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 vnodes + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + placementv1pb "github.com/dapr/dapr/pkg/proto/placement/v1" + "github.com/dapr/dapr/tests/integration/framework" + "github.com/dapr/dapr/tests/integration/framework/process/placement" + "github.com/dapr/dapr/tests/integration/suite" +) + +func init() { + suite.Register(new(vNodesRollingUpgrade)) +} + +type vNodesRollingUpgrade struct { + place *placement.Placement +} + +func (v *vNodesRollingUpgrade) Setup(t *testing.T) []framework.Option { + v.place = placement.New(t, + placement.WithMetadataEnabled(true), + ) + + return []framework.Option{ + framework.WithProcesses(v.place), + } +} + +func (v *vNodesRollingUpgrade) Run(t *testing.T, ctx context.Context) { + const ( + level1 = 10 + level2 = 20 + ) + + v.place.WaitUntilRunning(t, ctx) + + // Register the first host, with a lower API level (pre v1.13) + msg1 := &placementv1pb.Host{ + Name: "myapp1", + Port: 1111, + Entities: []string{"someactor1"}, + Id: "myapp1", + ApiLevel: uint32(level1), + } + ctx1, cancel1 := context.WithCancel(ctx) + defer cancel1() + placementMessageCh1 := v.place.RegisterHost(t, ctx1, msg1) + + require.EventuallyWithT(t, func(t *assert.CollectT) { + select { + case <-ctx.Done(): + return + case placementTables := <-placementMessageCh1: + if ctx.Err() != nil { + return + } + assert.Equal(t, uint32(level1), placementTables.GetApiLevel()) + assert.Len(t, placementTables.GetEntries(), 1) + // Check that the placement service sends the vnodes, because of the older cluster API level + assert.Len(t, placementTables.GetEntries()["someactor1"].GetHosts(), int(placementTables.GetReplicationFactor())) + assert.Len(t, placementTables.GetEntries()["someactor1"].GetSortedSet(), int(placementTables.GetReplicationFactor())) + } + }, 10*time.Second, 100*time.Millisecond) + + // Register the second host, with a higher API level (v1.13+) + msg2 := &placementv1pb.Host{ + Name: "myapp2", + Port: 2222, + Entities: []string{"someactor2"}, + Id: "myapp2", + ApiLevel: uint32(level2), + } + ctx2, cancel2 := context.WithCancel(ctx) + defer cancel2() + placementMessageCh2 := v.place.RegisterHost(t, ctx2, msg2) + + require.EventuallyWithT(t, func(t *assert.CollectT) { + select { + case <-ctx.Done(): + return + case placementTables := <-placementMessageCh2: + if ctx.Err() != nil { + return + } + + assert.Equal(t, uint32(level1), placementTables.GetApiLevel()) + assert.Len(t, placementTables.GetEntries(), 2) + // Check that the placement service still sends the vnodes, because cluster level is still pre v1.13 + assert.Len(t, placementTables.GetEntries()["someactor2"].GetHosts(), int(placementTables.GetReplicationFactor())) + assert.Len(t, placementTables.GetEntries()["someactor2"].GetSortedSet(), int(placementTables.GetReplicationFactor())) + } + }, 10*time.Second, 100*time.Millisecond) + + // Stop the first host; the API level should increase and vnodes shouldn't be sent anymore + cancel1() + + require.EventuallyWithT(t, func(t *assert.CollectT) { + select { + case <-ctx.Done(): + return + case placementTables := <-placementMessageCh2: + if ctx.Err() != nil { + return + } + + assert.Equal(t, uint32(level2), placementTables.GetApiLevel()) + assert.Len(t, placementTables.GetEntries(), 1) + // Check that the vnodes are not sent anymore, because the minimum API level of the cluster is 20+ + assert.Empty(t, placementTables.GetEntries()["someactor2"].GetHosts()) + assert.Empty(t, placementTables.GetEntries()["someactor2"].GetSortedSet()) + } + }, 10*time.Second, 100*time.Millisecond) +} diff --git a/tests/integration/suite/placement/vnodes/vnodes.go b/tests/integration/suite/placement/vnodes/vnodes.go deleted file mode 100644 index baa69efdbc6..00000000000 --- a/tests/integration/suite/placement/vnodes/vnodes.go +++ /dev/null @@ -1,166 +0,0 @@ -/* -Copyright 2024 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 vnodes - -import ( - "context" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - placementv1pb "github.com/dapr/dapr/pkg/proto/placement/v1" - "github.com/dapr/dapr/tests/integration/framework" - "github.com/dapr/dapr/tests/integration/framework/process/placement" - "github.com/dapr/dapr/tests/integration/suite" -) - -func init() { - suite.Register(new(vnodes)) -} - -type vnodes struct { - place *placement.Placement -} - -func (v *vnodes) Setup(t *testing.T) []framework.Option { - v.place = placement.New(t, - placement.WithMetadataEnabled(true), - ) - - return []framework.Option{ - framework.WithProcesses(v.place), - } -} - -func (v *vnodes) Run(t *testing.T, ctx context.Context) { - v.place.WaitUntilRunning(t, ctx) - - t.Run("register host without vnodes metadata (simulating daprd <1.13)", func(t *testing.T) { - // Register the host, with API level 10 (pre v1.13) - msg := &placementv1pb.Host{ - Name: "myapp", - Port: 1234, - Entities: []string{"someactor"}, - Id: "myapp1", - ApiLevel: uint32(10), - } - - // The host won't send the "dapr-accept-vnodes" metadata, simulating an older daprd version - placementMessageCh := v.place.RegisterHostWithMetadata(t, ctx, msg, nil) - - require.EventuallyWithT(t, func(t *assert.CollectT) { - select { - case <-ctx.Done(): - return - case placementTables := <-placementMessageCh: - if ctx.Err() != nil { - return - } - assert.Len(t, placementTables.GetEntries(), 1) - // Check that the placement service sends the vnodes - assert.Len(t, placementTables.GetEntries()["someactor"].GetHosts(), int(placementTables.GetReplicationFactor())) - assert.Len(t, placementTables.GetEntries()["someactor"].GetSortedSet(), int(placementTables.GetReplicationFactor())) - } - }, 10*time.Second, 10*time.Millisecond) - }) - - t.Run("register host with vnodes metadata (simulating daprd 1.13+)", func(t *testing.T) { - // Register the host, with API level 10 (pre v1.13) - msg := &placementv1pb.Host{ - Name: "myapp", - Port: 1234, - Entities: []string{"someactor"}, - Id: "myapp1", - ApiLevel: uint32(10), - } - - // The host will send the "dapr-accept-vnodes" metadata, simulating an older daprd version - placementMessageCh := v.place.RegisterHost(t, ctx, msg) - - require.EventuallyWithT(t, func(t *assert.CollectT) { - select { - case <-ctx.Done(): - return - case placementTables := <-placementMessageCh: - assert.Len(t, placementTables.GetEntries(), 1) - // Check that the placement service doesn't send the vnodes - assert.Empty(t, placementTables.GetEntries()["someactor"].GetHosts()) - assert.Empty(t, placementTables.GetEntries()["someactor"].GetSortedSet()) - } - }, 10*time.Second, 10*time.Millisecond) - }) - - t.Run("register heterogeneous hosts (simulating daprd pre and post 1.13)", func(t *testing.T) { - const ( - level1 = 10 - level2 = 20 - ) - - msg1 := &placementv1pb.Host{ - Name: "myapp1", - Port: 1111, - Entities: []string{"someactor1"}, - Id: "myapp1", - ApiLevel: uint32(level1), - } - msg2 := &placementv1pb.Host{ - Name: "myapp2", - Port: 2222, - Entities: []string{"someactor2"}, - Id: "myapp2", - ApiLevel: uint32(level2), - } - - // First host won't send the "dapr-accept-vnodes" metadata, simulating daprd pre 1.13 - placementMessageCh1 := v.place.RegisterHostWithMetadata(t, ctx, msg1, nil) - - // Second host will send the "dapr-accept-vnodes" metadata, simulating daprd 1.13+ - placementMessageCh2 := v.place.RegisterHost(t, ctx, msg2) - - require.EventuallyWithT(t, func(t *assert.CollectT) { - select { - case <-ctx.Done(): - return - case placementTables := <-placementMessageCh1: - assert.Len(t, placementTables.GetEntries(), 2) - // Check that the placement service sends the vnodes - assert.Len(t, placementTables.GetEntries()["someactor1"].GetHosts(), int(placementTables.GetReplicationFactor())) - assert.Len(t, placementTables.GetEntries()["someactor1"].GetSortedSet(), int(placementTables.GetReplicationFactor())) - assert.Len(t, placementTables.GetEntries()["someactor2"].GetHosts(), int(placementTables.GetReplicationFactor())) - assert.Len(t, placementTables.GetEntries()["someactor2"].GetSortedSet(), int(placementTables.GetReplicationFactor())) - } - }, 10*time.Second, 500*time.Millisecond) - - require.EventuallyWithT(t, func(t *assert.CollectT) { - select { - case <-ctx.Done(): - return - case placementTables := <-placementMessageCh2: - if ctx.Err() != nil { - return - } - - assert.Len(t, placementTables.GetEntries(), 2) - // Check that the placement service doesn't send the vnodes to this (1.13+) host, - // even though there are hosts with lower dapr versions in the cluster - assert.Empty(t, placementTables.GetEntries()["someactor1"].GetHosts()) - assert.Empty(t, placementTables.GetEntries()["someactor1"].GetSortedSet()) - assert.Empty(t, placementTables.GetEntries()["someactor2"].GetHosts()) - assert.Empty(t, placementTables.GetEntries()["someactor2"].GetSortedSet()) - } - }, 10*time.Second, 2000*time.Millisecond) - }) -} diff --git a/tests/integration/suite/ports/daprd.go b/tests/integration/suite/ports/daprd.go index ea201ed092e..d927b0c6b46 100644 --- a/tests/integration/suite/ports/daprd.go +++ b/tests/integration/suite/ports/daprd.go @@ -61,6 +61,6 @@ func (d *daprd) Run(t *testing.T, ctx context.Context) { } require.NoError(t, conn.Close()) return true - }, time.Second*5, 10*time.Millisecond, "port %s (:%d) was not available in time", name, port) + }, time.Second*5, 100*time.Millisecond, "port %s (:%d) was not available in time", name, port) } } diff --git a/tests/integration/suite/ports/operator.go b/tests/integration/suite/ports/operator.go index 093fe0bd00d..645af473b69 100644 --- a/tests/integration/suite/ports/operator.go +++ b/tests/integration/suite/ports/operator.go @@ -70,10 +70,6 @@ func (o *operator) Run(t *testing.T, ctx context.Context) { conn, err := dialer.DialContext(ctx, "tcp", fmt.Sprintf("localhost:%d", port)) //nolint:testifylint _ = assert.NoError(c, err) && assert.NoError(c, conn.Close()) - }, time.Second*10, 10*time.Millisecond, "port %s (:%d) was not available in time", name, port) + }, time.Second*10, 100*time.Millisecond, "port %s (:%d) was not available in time", name, port) } - - // Shutting the operator down too fast will cause the operator to exit error - // as the cache has not had time to sync. Wait until healthz before exiting. - o.proc.WaitUntilRunning(t, ctx) } diff --git a/tests/integration/suite/ports/placement.go b/tests/integration/suite/ports/placement.go index 9785ff26997..2c76d5ef7a0 100644 --- a/tests/integration/suite/ports/placement.go +++ b/tests/integration/suite/ports/placement.go @@ -59,6 +59,6 @@ func (p *placement) Run(t *testing.T, ctx context.Context) { } require.NoError(t, conn.Close()) return true - }, time.Second*5, 10*time.Millisecond, "port %s (:%d) was not available in time", name, port) + }, time.Second*5, 100*time.Millisecond, "port %s (:%d) was not available in time", name, port) } } diff --git a/tests/integration/suite/ports/sentry.go b/tests/integration/suite/ports/sentry.go index e00ab82e360..9a8afe5cb07 100644 --- a/tests/integration/suite/ports/sentry.go +++ b/tests/integration/suite/ports/sentry.go @@ -58,6 +58,6 @@ func (s *sentry) Run(t *testing.T, ctx context.Context) { } require.NoError(t, conn.Close()) return true - }, time.Second*5, 10*time.Millisecond, "port %s (:%d) was not available in time", name, port) + }, time.Second*5, 100*time.Millisecond, "port %s (:%d) was not available in time", name, port) } }