|
| 1 | + |
| 2 | +The `influxdb3 test schedule_plugin` command tests a schedule plugin. Use this command to verify plugin behavior without creating a trigger. |
| 3 | + |
| 4 | +## Usage |
| 5 | + |
| 6 | +<!--pytest.mark.skip--> |
| 7 | + |
| 8 | +```bash |
| 9 | +influxdb3 test schedule_plugin [OPTIONS] --database <DATABASE_NAME> <FILENAME> |
| 10 | +``` |
| 11 | + |
| 12 | +## Arguments |
| 13 | + |
| 14 | +- **FILENAME**: Path to the plugin file. Use the absolute path or the path relative to the current working directory, such as `<plugin-dir>/<plugin-file-name>.py`. |
| 15 | + |
| 16 | +## Options |
| 17 | + |
| 18 | +| Option | Flag | Description | |
| 19 | +| :----- | :-------------------- | :-------------------------------------------------------------------------------------------- | |
| 20 | +| `-H` | `--host` | URL of the running {{< product-name >}} server <br>(default: `http://127.0.0.1:8181`) | |
| 21 | +| `-d` | `--database` | _({{< req >}})_ Name of the database you want to test the plugin against | |
| 22 | +| | `--token` | _({{< req >}})_ Authentication token | |
| 23 | +| | `--input-arguments` | JSON map of key/value pairs to pass as plugin input arguments (for example, `'{"key":"val"}'`)| |
| 24 | +| | `--schedule` | Cron schedule to simulate when testing the plugin <br>(default: `* * * * *`) | |
| 25 | +| | `--cache-name` | Optional cache name to associate with the test | |
| 26 | +| | `--tls-ca` | Path to a custom TLS certificate authority for self-signed certs | |
| 27 | +| `-h` | `--help` | Show basic help information | |
| 28 | +| | `--help-all` | Show all available help options | |
| 29 | + |
| 30 | + |
| 31 | +### Option environment variables |
| 32 | + |
| 33 | +You can use the following environment variables to set command options: |
| 34 | + |
| 35 | +| Environment Variable | Corresponding Option | |
| 36 | +| :------------------------ | :------------------- | |
| 37 | +| `INFLUXDB3_HOST_URL` | `--host` | |
| 38 | +| `INFLUXDB3_DATABASE_NAME` | `--database` | |
| 39 | +| `INFLUXDB3_AUTH_TOKEN` | `--token` | |
| 40 | +| `INFLUXDB3_TLS_CA` | `--tls-ca` | |
| 41 | + |
| 42 | +## Examples |
| 43 | + |
| 44 | +In the examples below, replace the following: |
| 45 | + |
| 46 | +- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}: Your target database |
| 47 | +- {{% code-placeholder-key %}}`AUTH_TOKEN`{{% /code-placeholder-key %}}: Your authentication token |
| 48 | +- {{% code-placeholder-key %}}`PLUGIN_DIR`{{% /code-placeholder-key %}}: |
| 49 | + the path to the plugin directory you provided when starting the server |
| 50 | +- {{% code-placeholder-key %}}`FILENAME`{{% /code-placeholder-key %}}: |
| 51 | + Plugin file name |
| 52 | + |
| 53 | +{{% code-placeholders "(DATABASE|PLUGIN_DIR|FILENAME|AUTH_TOKEN)" %}} |
| 54 | + |
| 55 | +### Test a schedule plugin |
| 56 | + |
| 57 | +<!--pytest.mark.skip--> |
| 58 | + |
| 59 | +```bash |
| 60 | +influxdb3 test schedule_plugin \ |
| 61 | + --database DATABASE_NAME \ |
| 62 | + --token AUTH_TOKEN \ |
| 63 | + PLUGIN_DIR/FILENAME.py |
| 64 | +``` |
| 65 | + |
| 66 | +### Test with input arguments and a custom cron schedule |
| 67 | + |
| 68 | +You can pass input arguments to your plugin as key-value pairs and specify a custom cron schedule (using Quartz cron syntax with six fields): |
| 69 | + |
| 70 | +<!--pytest.mark.skip--> |
| 71 | + |
| 72 | +```bash |
| 73 | +influxdb3 test schedule_plugin \ |
| 74 | + --host http://localhost:8182 \ |
| 75 | + --database DATABASE_NAME \ |
| 76 | + --token AUTH_TOKEN \ |
| 77 | + --input-arguments threshold=10,unit=seconds \ |
| 78 | + --schedule "0 0 * * * ?" \ |
| 79 | + PLUGIN_DIR/FILENAME.py |
| 80 | +``` |
| 81 | +- Pass plugin parameters using `--input-arguments` as comma-separated key=value pairs. |
| 82 | +- Use `--schedule` to set the plugin’s execution time with a Quartz cron expression. For example, "0 0 * * * ?" runs the plugin at the start of every hour. |
| 83 | + |
| 84 | +{{% /code-placeholders %}} |
0 commit comments