Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grant notes while onboarding to DSE and taking 102 courses. #50

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/debug-activity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ in the Workflow code, rather than in an Activity, since that is typically
not prone to failure and unlikely to affect whether the Workflow executes
in a deterministic manner. This exercise implemented it in the Activity,
since you can deploy a fix to Activity code without a risk of causing a
non-deterministic error. Later in this course, you'll safely
non-deterministic error. As you learned earlier in this course, there are also ways to safely
deploy changes to Workflow Definitions.

### This is the end of the exercise.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('activities', () => {
customerID: 12983,
orderNumber: 'PI314',
description: '2 large cheese pizzas',
amount: 2600,
amount: 2600, // does not qualify for a discount
};
const confirmation: OrderConfirmation = await env.run(activities.sendBill, input);
assert.equal(confirmation.orderNumber, input.orderNumber);
Expand Down
5 changes: 3 additions & 2 deletions exercises/durable-execution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You'll need four terminal windows for this exercise.
## Part B: Add Logging to the Activity Code

1. Edit the `src/activities.ts` file.
2. Add an import to the top of the file so you can access the logger: `import * as activity from @temporalio/activity` package.
2. Add an import to the top of the file so you can access the logger: `import * as activity from '@temporalio/activity'` package.
3. Define a new `context` variable at the top of the Activity function and assign it `activity.Context.current()` to get access to the logger.
4. Insert a logging statement using `context.log` at the Info level just after this, so you'll know when the Activity is invoked.
1. Include the term being translated and the language code as name-value pairs.
Expand All @@ -44,7 +44,8 @@ You'll need four terminal windows for this exercise.
You will now add a Timer between the two Activity calls in the Workflow Definition, which will make it easier to observe durable execution in the next section.

1. After the statement where `helloMessage` is defined, but before the statement where `goodbyeInput` is defined, add a new statement that logs the message `Sleeping between translation calls` at the Debug level.
2. Just after the new log statement, use `await sleep("10 seconds");` to set a Timer for 10 seconds.
2. Add the `sleep` function to the `import { proxyActivities } from '@temporalio/workflow';` line.
3. Just after the new log statement, use `await sleep("10 seconds");` to set a Timer for 10 seconds.

## Part D: Observe Durable Execution
It is typical to run Temporal applications using two or more Worker processes. Not only do additional Workers allow the application to scale, it also increases availability since another Worker can take over if a Worker crashes during Workflow Execution. You'll see this for yourself now and will learn more about how Temporal achieves this as you continue through the course.
Expand Down
19 changes: 11 additions & 8 deletions exercises/testing-code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,26 @@ continue with the following steps.
`cp src/mocha/workflows.test.ts src/mocha/workflows-mocks.test.ts`
2. Edit the `src/mocha/workflows-mocks.test.ts` file
3. Add an import for `sinon` with `import sinon from 'sinon';`
4. Rename the test function to `it('successfully completes French translation with a mocked call', async () => {`
5. Make the following changes between where the object representing
4. Add an import for the Translation Activity input and output
`import { TranslationActivityInput, TranslationActivityOutput } from '../shared';`
5. Rename the test function to `it('successfully completes French translation with a mocked call', async () => {`
6. Make the following changes between where the object representing
workflow input is defined and where the Worker is defined:
* Create and populate an instance of the `TranslationActivityInput`
object to represent input passed to the Activity when translating
the greeting
the greeting. Name it `helloInput`.
* Create and populate an instance of the `TranslationActivityOutput`
object to represent output returned by the Activity when translating
the greeting
* Repeat the above three steps, this time creating objects for the goodbye message.
the greeting. Name it `helloOutput`.
* Repeat the above two steps, this time creating objects for the goodbye message.
Switch the names from `hello` to `goodbye`.
* Use Sinon to create a mock that represents the `TranslateTerm` Activity,
which will return the output object you created when called
with the input object you created: `const translateTermMock = sinon.stub();`
* Add the following two lines to return mock results for the translations:
`translateTermMock.withArgs(helloInput).resolves(helloOutput);`
`translateTermMock.withArgs(goodbyeInput).resolves(goodbyeOutput);`
6. For the Worker, modify the registered Activities so it uses your mock:
7. For the Worker, modify the registered Activities so it uses your mock:
`activities: { translateTerm: translateTermMock },`
7. Save your changes
8. Run `npm test` to run the tests
8. Save your changes
9. Run `npm test` to run the tests
2 changes: 0 additions & 2 deletions exercises/testing-code/practice/src/mocha/workflows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ describe('SayHelloGoodbye workflow', () => {
})
);

// TODO: Assert that Workflow Execution completed

// TODO: Assert that the HelloMessage field in the
// result is: Bonjour, Pierre

Expand Down
Loading