Skip to content

Commit 30bce57

Browse files
committed
Moving durabletask tests into specific dir and more
Signed-off-by: Ryan Lettieri <[email protected]>
1 parent e46d90a commit 30bce57

File tree

9 files changed

+88
-4
lines changed

9 files changed

+88
-4
lines changed

.github/workflows/pr-validation.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
run: |
3535
flake8 . --count --show-source --statistics --exit-zero
3636
- name: Pytest unit tests
37+
working-directory: examples/durabletask-azuremanaged
3738
run: |
3839
pytest -m "not e2e" --verbose
3940
@@ -45,6 +46,7 @@ jobs:
4546

4647
# Install and run the durabletask-go sidecar for running e2e tests
4748
- name: Pytest e2e tests
49+
working-directory: examples/durabletask-azuremanaged
4850
run: |
4951
go install github.com/microsoft/durabletask-go@main
5052
durabletask-go --port 4001 &

.github/workflows/publish-dts-sdk.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
name: Publish Durable Task Scheduler to PyPI
22

3+
# on:
4+
# push:
5+
# tags:
6+
# - 'azuremanaged-v*' # Only run for tags starting with "azuremanaged-v"
7+
38
on:
49
push:
5-
tags:
6-
- 'azuremanaged-v*' # Only run for tags starting with "azuremanaged-v"
10+
branches: [ "main" ]
11+
pull_request:
12+
branches: [ "main" ]
13+
714

815
jobs:
916
lint:
@@ -47,9 +54,15 @@ jobs:
4754
echo "TASKHUB=default" >> $GITHUB_ENV
4855
echo "ENDPOINT=http://localhost:8080" >> $GITHUB_ENV
4956
57+
- name: Install dependencies
58+
working-directory: examples/durabletask-azuremanaged
59+
run: |
60+
python -m pip install --upgrade pip
61+
pip install -r requirements.txt
62+
5063
- name: Run the tests
51-
working-directory: durabletask-azuremanaged
52-
run: python -m dts_activity_sequence
64+
working-directory: tests/durabletask-azuremanaged
65+
run: python -m test_activity_sequence
5366

5467

5568
publish:
File renamed without changes.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"""End-to-end sample that demonstrates how to configure an orchestrator
2+
that calls an activity function in a sequence and prints the outputs."""
3+
import os
4+
5+
from durabletask import client, task
6+
from durabletask.azuremanaged.client import DurableTaskSchedulerClient
7+
from durabletask.azuremanaged.worker import DurableTaskSchedulerWorker
8+
9+
import pytest
10+
11+
12+
pytestmark = pytest.mark.dts
13+
14+
def hello(ctx: task.ActivityContext, name: str) -> str:
15+
"""Activity function that returns a greeting"""
16+
return f'Hello {name}!'
17+
18+
19+
def sequence(ctx: task.OrchestrationContext, _):
20+
"""Orchestrator function that calls the 'hello' activity function in a sequence"""
21+
# call "hello" activity function in a sequence
22+
result1 = yield ctx.call_activity(hello, input='Tokyo')
23+
result2 = yield ctx.call_activity(hello, input='Seattle')
24+
result3 = yield ctx.call_activity(hello, input='London')
25+
26+
# return an array of results
27+
return [result1, result2, result3]
28+
29+
30+
# Read the environment variable
31+
taskhub_name = os.getenv("TASKHUB")
32+
33+
# Check if the variable exists
34+
if taskhub_name:
35+
print(f"The value of TASKHUB is: {taskhub_name}")
36+
else:
37+
print("TASKHUB is not set. Please set the TASKHUB environment variable to the name of the taskhub you wish to use")
38+
print("If you are using windows powershell, run the following: $env:TASKHUB=\"<taskhubname>\"")
39+
print("If you are using bash, run the following: export TASKHUB=\"<taskhubname>\"")
40+
exit()
41+
42+
# Read the environment variable
43+
endpoint = os.getenv("ENDPOINT")
44+
45+
# Check if the variable exists
46+
if endpoint:
47+
print(f"The value of ENDPOINT is: {endpoint}")
48+
else:
49+
print("ENDPOINT is not set. Please set the ENDPOINT environment variable to the endpoint of the scheduler")
50+
print("If you are using windows powershell, run the following: $env:ENDPOINT=\"<schedulerEndpoint>\"")
51+
print("If you are using bash, run the following: export ENDPOINT=\"<schedulerEndpoint>\"")
52+
exit()
53+
54+
# configure and start the worker
55+
with DurableTaskSchedulerWorker(host_address=endpoint, secure_channel=True,
56+
taskhub=taskhub_name, token_credential=None) as w:
57+
w.add_orchestrator(sequence)
58+
w.add_activity(hello)
59+
w.start()
60+
61+
# Construct the client and run the orchestrations
62+
c = DurableTaskSchedulerClient(host_address=endpoint, secure_channel=True,
63+
taskhub=taskhub_name, token_credential=None)
64+
instance_id = c.schedule_new_orchestration(sequence)
65+
state = c.wait_for_orchestration_completion(instance_id, timeout=60)
66+
if state and state.runtime_status == client.OrchestrationStatus.COMPLETED:
67+
print(f'Orchestration completed! Result: {state.serialized_output}')
68+
elif state:
69+
print(f'Orchestration failed: {state.failure_details}')

tests/durabletask/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)