Skip to content
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
9 changes: 9 additions & 0 deletions .vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,15 @@ const fullSidebar = [
{ text: "Environment Variables", link: "/writing-workflows/environment-variables" },
{ text: "Labels", link: "/writing-workflows/labels" },
{ text: "Tags", link: "/writing-workflows/tags" },
{
text: "Workflow Tests",
link: "/writing-workflows/workflow-tests",
collapsed: true,
items: [
{ text: "Overview", link: "/writing-workflows/workflow-tests" },
{ text: "Reference", link: "/writing-workflows/workflow-test-reference" },
],
},
],
},
{
Expand Down
40 changes: 38 additions & 2 deletions getting-started/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Commands accept either DAG names (from YAML `name` field) or file paths.
- Both formats: `start`, `stop`, `status`, `retry`, `dry`, `enqueue`
- DAG name only: `restart`
- History by DAG name or YAML path; definition by filename, stem, or configured path: `rm`
- Local-only commands: `ls`, `rm`, `profile`, `ps`, `human-task complete`, `human-task push-back`, `browser cache clear`, `browser session`, `browser writes`, `computer check`, `computer elements`, `computer cache clear`, `computer cache show`, `xlsx inspect`, `xlsx read`, `xlsx cache clear`
- Local-only commands: `ls`, `rm`, `profile`, `ps`, `test`, `human-task complete`, `human-task push-back`, `browser cache clear`, `browser session`, `browser writes`, `computer check`, `computer elements`, `computer cache clear`, `computer cache show`, `xlsx inspect`, `xlsx read`, `xlsx cache clear`

## Global Options

Expand Down Expand Up @@ -802,6 +802,38 @@ dagu dry --profile prod my-workflow.yaml
dagu dry --no-reuse report-pipeline.yaml
```

### `test`

Run [workflow tests](/writing-workflows/workflow-tests). Each case of a test file runs the DAG beside it, or the one its `dag` field names, through the same runner as `start`, with step actions replaced by mocks, in a temporary directory. A step the case lists under `real` runs its real action. Requires a Dagu release after v2.27.0.

```bash
dagu test [options] [TEST_FILE_DAG_FILE_DAG_NAME_OR_DIRECTORY...]
```

A test file argument ends in `.test.yaml` or `.test.yml`. A DAG file argument, a `.yaml` or `.yml` file that is not a test file, runs the test files beside it: `release.yaml` runs `release.test.yaml` and `release.test.yml`, whichever exist. An argument that is not an existing path is a DAG name, resolved in the DAGs directory as `start` resolves one. A DAG with no test file exits `2` with an error that names `dagu test --init`. A directory argument runs every test file under it, skipping directories whose names start with `.` and not following symbolic links. Without an argument, every test file under the DAGs directory runs. Selecting no test file is not an error and exits `0`.

With `--init`, the one argument is a DAG file, and Dagu writes its test file beside it instead of running tests. See [Generate a Test File](/writing-workflows/workflow-tests#generate-a-test-file).

**Options:**
- `--run` - Run only the cases whose name this RE2 regular expression matches
- `--timeout` - Longest a case may run, such as `30s` (default: `5m`)
- `--format, -f` - Report format: `text` (default) or `json`
- `--keep` - Keep each case directory and print its path
- `--init` - Write the test file of the DAG file given as the one argument, with a mock for every step that needs one and one case that expects the result of a run with those mocks. It never replaces a test file and takes no `--update`, `--run`, `--keep`, or `--format json`
- `--update` - Run the selected cases and rewrite each case's `expect` from its run, for review as a diff. It never removes an assertion. It combines with `--run`, `--timeout`, `--keep`, and `--format`, and not with `--init`. See [Update Expectations After a Change](/writing-workflows/workflow-tests#update-expectations-after-a-change)

```bash
dagu test workflows/
dagu test workflows/release.yaml
dagu test release
dagu test --run 'failed build' --timeout 30s workflows/release.test.yaml
dagu test --format json --keep workflows/
dagu test --init workflows/release.yaml
dagu test --update workflows/release.test.yaml
```

Exits `0` when every case passed, `1` when a case failed, and `2` when a test file, a case, or the arguments are invalid. With `--update`, a test file edited during the run is left unwritten, and the command exits `1` even when every case passed, or `2` when a test file or case is invalid. See [Running Tests in CI](/writing-workflows/workflow-tests#running-tests-in-ci).

### `browser cache clear`

Clear the recorded `act` and `upload` operations that [browser steps](/step-types/browser#replay-cache) replay, so the next run asks the model again.
Expand Down Expand Up @@ -1314,7 +1346,7 @@ Values are shown as read from the file, the environment, or the defaults, before

### `schema`

Browse the JSON schema for DAG definitions, server configuration, or calendar files.
Browse the JSON schema for DAG definitions, server configuration, calendar files, or workflow test files.

```bash
dagu schema dag
Expand All @@ -1324,8 +1356,12 @@ dagu schema config
dagu schema config server
dagu schema calendar
dagu schema calendar holidays
dagu schema test
dagu schema test cases.expect
```

Save the test file schema for an editor with `dagu schema test > workflow-test.schema.json`. See [Editor Support](/writing-workflows/workflow-tests#editor-support).

### `calendar`

Check [business calendars](/writing-workflows/business-calendars) and preview the runs they allow. Calendar files live in `paths.calendars_dir`.
Expand Down
27 changes: 27 additions & 0 deletions ja/server-admin/upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,33 @@ macOS では、インストーラーが設定する launchd エージェント

各ワーカーホストのバイナリまたはイメージも更新してください。[ワーカーページ](/server-admin/distributed/workers/#web-ui-workers-page)には各ワーカーの Dagu のバージョンが表示され、サーバーより古いワーカーや新しいワーカーには印が付きます。すべてのワーカーの更新が終わったかをここで確認できます。

## 2.27.0 以前からのアップグレード {#upgrading-from-2-27-0-or-earlier}

ファイル名が `.test.yaml` または `.test.yml` で終わる DAG ファイルは、[ワークフローテスト](/writing-workflows/workflow-tests)のファイルとして扱われるようになります。DAG 一覧に表示されなくなり、スケジューラも実行せず、`dagu start` も受け付けません。アップグレードの前に、このようなファイルの名前を変更してください(例: `smoke.test.yaml` を `smoke-test.yaml` に変更)。あわせて、古い名前やパスでその DAG を開始しているもの(`dag.run` ステップの `dag` や、`dagu start` を実行するスクリプトなど)もすべて更新してください。

対象のファイルを探すには、サーバーと同じ設定と環境で `dagu config` を実行し、`DAGs directory` の行を確認します。スクリプトインストーラーで登録したサービスは、システムサービスでは `/var/lib/dagu`、ユーザーサービスでは `~/.dagu` の下にデータを置きます。確認したディレクトリを検索します。`-H` を付けると、そのディレクトリがシンボリックリンクの場合もリンク先を検索します。

```bash
dagu config | grep 'DAGs directory'
find -H /path/to/dags -name '*.test.yaml' -o -name '*.test.yml'
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
```

スクリプトや `dag.run` ステップからパスで開始する DAG ファイルを置いているディレクトリがほかにあれば、それぞれで同じ検索を行ってください。上のコマンドは POSIX シェル用です。Windows の PowerShell では次のとおりです。

```powershell
dagu config | Select-String 'DAGs directory'
Get-ChildItem -LiteralPath 'C:\path\to\dags' -Recurse -File -Force |
Where-Object { $_.Name -like '*.test.yaml' -or $_.Name -like '*.test.yml' }
```

`-LiteralPath` は、名前に `[` や `]` を含むディレクトリも書いたとおりに読みます。`-Force` を付けると隠しファイルも対象になります。`find` と同じく、`Get-ChildItem` は検索中に見つかったディレクトリへのシンボリックリンクの中は検索しません。

アップグレード後、`dagu scheduler`、`dagu server`、`dagu start-all` は起動時に、最初のドキュメントにトップレベルの `steps` があり `cases` がないファイルごとに、そのフルパスを含む警告をログに出力します。

```text
/path/to/dags/smoke.test.yaml reads as a DAG, with steps and no cases, but Dagu treats it as a test file and does not run it as a DAG; rename it, for example to smoke-test.yaml
```

## 2.26.0 以前からのアップグレード {#upgrading-from-2-26-0-or-earlier}

それより後のリリースでは、スケジューラの動作が 4 点変更されています。
Expand Down
27 changes: 27 additions & 0 deletions server-admin/upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,33 @@ Upgrade the standby first. The upgraded instance then takes over once, and an ol

Upgrade the binary or image on each worker host as well. The [Workers page](/server-admin/distributed/workers/#web-ui-workers-page) shows the Dagu version of each worker and marks a worker older or newer than the server, so it shows when every worker is upgraded.

## Upgrading from 2.27.0 or earlier

A DAG file whose name ends in `.test.yaml` or `.test.yml` becomes a [workflow test](/writing-workflows/workflow-tests) file. It leaves the DAG list, the scheduler stops running it, and `dagu start` refuses it. Before the upgrade, rename such files, for example `smoke.test.yaml` to `smoke-test.yaml`, and update everything that starts one by its old name or path, such as the `dag` of a `dag.run` step or a script that runs `dagu start`.

To find them, run `dagu config` as the server runs, with its configuration and environment, and read the `DAGs directory` line. A service installed by the script installer keeps its data under `/var/lib/dagu` for a system service or `~/.dagu` for a user service. Then search that directory. `-H` follows it when it is a symbolic link:

```bash
dagu config | grep 'DAGs directory'
find -H /path/to/dags -name '*.test.yaml' -o -name '*.test.yml'
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
```

Run the search again in each other directory that holds DAG files started by path, such as from a script or a `dag.run` step. The commands above are for a POSIX shell. In PowerShell on Windows:

```powershell
dagu config | Select-String 'DAGs directory'
Get-ChildItem -LiteralPath 'C:\path\to\dags' -Recurse -File -Force |
Where-Object { $_.Name -like '*.test.yaml' -or $_.Name -like '*.test.yml' }
```

`-LiteralPath` reads the directory as written, even with `[` or `]` in its name, and `-Force` includes hidden files. Like `find`, `Get-ChildItem` does not search inside symbolic links to directories that it finds during the search.

After the upgrade, `dagu scheduler`, `dagu server`, and `dagu start-all` log a warning at startup for each such file whose first document has top-level `steps` and no `cases`, with its full path:

```text
/path/to/dags/smoke.test.yaml reads as a DAG, with steps and no cases, but Dagu treats it as a test file and does not run it as a DAG; rename it, for example to smoke-test.yaml
```

## Upgrading from 2.26.0 or earlier

Later releases change how the scheduler behaves in four ways:
Expand Down
3 changes: 3 additions & 0 deletions writing-workflows/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ dagu start --only report pipeline.yaml # Run one step on its own
dagu history pipeline # List recent runs
```

To check failure branches, retries, and handlers without running commands, write a [workflow test](/writing-workflows/workflow-tests) beside the DAG and run it with `dagu test pipeline.test.yaml`.

Start the server to inspect the same workflows in the Web UI:

```bash
Expand Down Expand Up @@ -254,6 +256,7 @@ Other built-in actions cover [HTTP requests](/step-types/http), [JavaScript tran
| Start a run for each file that arrives in a folder | [Watched Folders](/writing-workflows/watched-folders) |
| Keep a DAG running like a service | [Services](/writing-workflows/services) |
| Configure retries, timeouts, handlers, and failure behavior | [Durable Execution](/writing-workflows/durable-execution) and [Error Handling](/writing-workflows/error-handling) |
| Test how a DAG behaves with its commands mocked | [Workflow Tests](/writing-workflows/workflow-tests) |
| Run HTTP, SQL, SSH, Docker, Kubernetes, or other actions | [Built-in Actions](/step-types/shell) |
| Start from copyable workflows | [Examples](/writing-workflows/examples) |
| Look up every supported field | [YAML Specification](/writing-workflows/yaml-specification) |
Loading