diff --git a/.github/infrastructure/conformance/temporal/worker/main.go b/.github/infrastructure/conformance/temporal/worker/main.go index 45bb37a6b..e68b2b4b2 100644 --- a/.github/infrastructure/conformance/temporal/worker/main.go +++ b/.github/infrastructure/conformance/temporal/worker/main.go @@ -17,7 +17,10 @@ import ( "context" "time" +<<<<<<< HEAD "github.com/zouyx/agollo/v3/component/log" +======= +>>>>>>> Initial creation of workflows building block "go.temporal.io/sdk/activity" "go.temporal.io/sdk/client" "go.temporal.io/sdk/worker" @@ -36,7 +39,10 @@ func main() { // Create the workflow client clientTwo, err := client.Dial(cOpt) if err != nil { +<<<<<<< HEAD log.Error("Unable to create client.") +======= +>>>>>>> Initial creation of workflows building block return } wOpt := worker.Options{} @@ -49,7 +55,10 @@ func main() { err = w.Start() if err != nil { +<<<<<<< HEAD log.Error("Unable to start worker.") +======= +>>>>>>> Initial creation of workflows building block return } w.Run(worker.InterruptCh()) @@ -66,9 +75,15 @@ func TestWorkflow(ctx workflow.Context, runtimeSeconds int) error { } ctx = workflow.WithActivityOptions(ctx, options) +<<<<<<< HEAD err := workflow.ExecuteActivity(ctx, ExampleActivity, runtimeSeconds).Get(ctx, nil) if err != nil { log.Error("Unable to execute activity.") +======= + newCtx, _ := workflow.NewDisconnectedContext(ctx) + err := workflow.ExecuteActivity(newCtx, ExampleActivity, runtimeSeconds).Get(ctx, nil) + if err != nil { +>>>>>>> Initial creation of workflows building block return err } diff --git a/.github/infrastructure/conformance/temporal/worker/worker b/.github/infrastructure/conformance/temporal/worker/worker new file mode 100755 index 000000000..47bccf61e Binary files /dev/null and b/.github/infrastructure/conformance/temporal/worker/worker differ diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index 6d3c3c69f..0476e5592 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -84,6 +84,7 @@ jobs: - state.cockroachdb - workflows.temporal - state.rethinkdb + - workflows.temporal EOF ) echo "::set-output name=pr-components::$PR_COMPONENTS" diff --git a/tests/certification/workflows/temporal/.env b/tests/certification/workflows/temporal/.env new file mode 100644 index 000000000..53c785cd1 --- /dev/null +++ b/tests/certification/workflows/temporal/.env @@ -0,0 +1,8 @@ +COMPOSE_PROJECT_NAME=temporal +CASSANDRA_VERSION=3.11.9 +ELASTICSEARCH_VERSION=7.16.2 +MYSQL_VERSION=8 +POSTGRESQL_VERSION=13 +TEMPORAL_VERSION=1.17.1 +TEMPORAL_WEB_VERSION=1.15.0 +TEMPORAL_UI_VERSION=2.2.3 diff --git a/tests/certification/workflows/temporal/docker-compose.yml b/tests/certification/workflows/temporal/docker-compose.yml new file mode 100644 index 000000000..b823ecc39 --- /dev/null +++ b/tests/certification/workflows/temporal/docker-compose.yml @@ -0,0 +1,34 @@ +version: "3.5" +services: + postgresql: + container_name: temporal-postgresql + environment: + POSTGRES_PASSWORD: temporal + POSTGRES_USER: temporal + image: postgres:${POSTGRESQL_VERSION} + networks: + - temporal-network + ports: + - 5432:5432 + temporal: + container_name: temporal + depends_on: + - postgresql + environment: + - DB=postgresql + - DB_PORT=5432 + - POSTGRES_USER=temporal + - POSTGRES_PWD=temporal + - POSTGRES_SEEDS=postgresql + - DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development-sql.yaml + image: temporalio/auto-setup:${TEMPORAL_VERSION} + networks: + - temporal-network + ports: + - 7233:7233 + volumes: + - ./dynamicconfig:/etc/temporal/config/dynamicconfig +networks: + temporal-network: + driver: bridge + name: temporal-network diff --git a/tests/certification/workflows/temporal/dynamicconfig/README.md b/tests/certification/workflows/temporal/dynamicconfig/README.md new file mode 100755 index 000000000..85a37c09d --- /dev/null +++ b/tests/certification/workflows/temporal/dynamicconfig/README.md @@ -0,0 +1,39 @@ +Use `docker.yaml` file to override the default dynamic config value (they are specified +when creating the service config). + +Each key can have zero or more values and each value can have zero or more +constraints. There are only three types of constraint: +1. `namespace`: `string` +2. `taskQueueName`: `string` +3. `taskType`: `int` (`1`:`Workflow`, `2`:`Activity`) +A value will be selected and returned if all its has exactly the same constraints +as the ones specified in query filters (including the number of constraints). + +Please use the following format: +``` +testGetBoolPropertyKey: + - value: false + - value: true + constraints: + namespace: "global-samples-namespace" + - value: false + constraints: + namespace: "samples-namespace" +testGetDurationPropertyKey: + - value: "1m" + constraints: + namespace: "samples-namespace" + taskQueueName: "longIdleTimeTaskqueue" +testGetFloat64PropertyKey: + - value: 12.0 + constraints: + namespace: "samples-namespace" +testGetMapPropertyKey: + - value: + key1: 1 + key2: "value 2" + key3: + - false + - key4: true + key5: 2.0 +``` diff --git a/tests/certification/workflows/temporal/dynamicconfig/development-cass.yaml b/tests/certification/workflows/temporal/dynamicconfig/development-cass.yaml new file mode 100755 index 000000000..4b9161638 --- /dev/null +++ b/tests/certification/workflows/temporal/dynamicconfig/development-cass.yaml @@ -0,0 +1,3 @@ +system.forceSearchAttributesCacheRefreshOnRead: + - value: true # Dev setup only. Please don't turn this on in production. + constraints: {} diff --git a/tests/certification/workflows/temporal/dynamicconfig/development-sql.yaml b/tests/certification/workflows/temporal/dynamicconfig/development-sql.yaml new file mode 100755 index 000000000..8862dfad7 --- /dev/null +++ b/tests/certification/workflows/temporal/dynamicconfig/development-sql.yaml @@ -0,0 +1,6 @@ +limit.maxIDLength: + - value: 255 + constraints: {} +system.forceSearchAttributesCacheRefreshOnRead: + - value: true # Dev setup only. Please don't turn this on in production. + constraints: {} diff --git a/tests/certification/workflows/temporal/dynamicconfig/docker.yaml b/tests/certification/workflows/temporal/dynamicconfig/docker.yaml new file mode 100755 index 000000000..e69de29bb diff --git a/tests/certification/workflows/temporal/temporal_test.go b/tests/certification/workflows/temporal/temporal_test.go new file mode 100644 index 000000000..3ffa18889 --- /dev/null +++ b/tests/certification/workflows/temporal/temporal_test.go @@ -0,0 +1,31 @@ +/* +Copyright 2021 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 temporal_test + +import ( + "fmt" + "strconv" + "testing" + "time" + // "github.com/dapr/components-contrib/workflows" +) + +func TestTemporal(t *testing.T) { + log := logger.NewLogger("dapr.components") + ports, err := dapr_testing.GetFreePorts(2) + assert.NoError(t, err) + + currentGrpcPort := ports[0] + currentHTTPPort := ports[1] +} diff --git a/workflows/temporal/temporal_test.go b/workflows/temporal/temporal_test.go new file mode 100644 index 000000000..d4305a6c0 --- /dev/null +++ b/workflows/temporal/temporal_test.go @@ -0,0 +1,34 @@ +/* +Copyright 2021 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 temporal + +import ( + "testing" + + workflows "github.com/dapr/components-contrib/workflows" + "github.com/dapr/kit/logger" + "gotest.tools/assert" +) + +func TestStartTemporalClient(t *testing.T) { + m := workflows.Metadata{} + m.Properties = map[string]string{ + "Identity": "TemporalTestClient", + "HostPort": "localhost:7233", + } + temporal := TemporalWF{logger: logger.NewLogger("TemporalTestLogger")} + err := temporal.Init(m) + assert.Equal(t, nil, err) + +}