|
| 1 | +--- |
| 2 | +title: Run Local Integration Tests |
| 3 | +weight: 30 |
| 4 | +--- |
| 5 | + |
| 6 | +# Run Local Integration Tests |
| 7 | + |
| 8 | +This guide covers the default local development workflow for running the TektonCD Operator integration test suite directly from the source tree. |
| 9 | + |
| 10 | +Use this document when you want to run tests from the local repository with: |
| 11 | + |
| 12 | +```bash |
| 13 | +cd testing |
| 14 | +make test |
| 15 | +``` |
| 16 | + |
| 17 | +Use [Run TektonCD Operator E2E Tests](./run_e2e.mdx) only when you specifically want the container-image-based workflow. |
| 18 | + |
| 19 | +## Scope |
| 20 | + |
| 21 | +This workflow is for contributors working in the `tektoncd-operator` repository itself. It matches the behavior implemented in [testing/Makefile] and [testing/main_test.go]. |
| 22 | + |
| 23 | +Key differences from the catalog playbook: |
| 24 | + |
| 25 | +- You still need a valid `KUBECONFIG` |
| 26 | +- You do not need to run a separate `prepare` helper before regular local verification |
| 27 | +- You need a local test config file before execution |
| 28 | +- You should use `TAGS` to narrow the test scope |
| 29 | +- The standard entrypoint is `cd testing && make test` |
| 30 | + |
| 31 | +## Prerequisites |
| 32 | + |
| 33 | +- Access to a Kubernetes cluster that already has the required external dependencies available for the scenarios you plan to run |
| 34 | +- A valid kubeconfig with enough permissions for the tested scenarios |
| 35 | +- Go toolchain available locally |
| 36 | +- Optional: `allure` for reading the generated test report |
| 37 | + |
| 38 | +## Step 1: Export Kubeconfig |
| 39 | + |
| 40 | +Before every local run, export the kubeconfig you want the suite to use: |
| 41 | + |
| 42 | +```bash |
| 43 | +export KUBECONFIG=/path/to/your/kubeconfig.yaml |
| 44 | +``` |
| 45 | + |
| 46 | +Verify the context before running tests: |
| 47 | + |
| 48 | +```bash |
| 49 | +kubectl config current-context |
| 50 | +kubectl get nodes |
| 51 | +``` |
| 52 | + |
| 53 | +## Step 2: Prepare Local Test Config |
| 54 | + |
| 55 | +The test suite reads external toolchain and registry settings from a config file. |
| 56 | + |
| 57 | +The default location is: |
| 58 | + |
| 59 | +```text |
| 60 | +testing/config.yaml |
| 61 | +``` |
| 62 | + |
| 63 | +You can either: |
| 64 | + |
| 65 | +- Place your local config at `testing/config.yaml` |
| 66 | +- Or keep it elsewhere and export `TESTING_CONFIG=/path/to/config.yaml` |
| 67 | + |
| 68 | +Example: |
| 69 | + |
| 70 | +```bash |
| 71 | +export TESTING_CONFIG=/path/to/local-testing-config.yaml |
| 72 | +``` |
| 73 | + |
| 74 | +The Makefile defaults to `./config.yaml` only when `TESTING_CONFIG` is not set. |
| 75 | + |
| 76 | +Important rules: |
| 77 | + |
| 78 | +- Do not commit credentials, tokens, kubeconfig files, or private toolchain settings |
| 79 | +- Treat feature files as the source of truth for which config keys are actually required |
| 80 | +- Different tags may require different sections under `registry` and `toolchains` |
| 81 | + |
| 82 | +## Step 3: Choose the Test Scope with TAGS |
| 83 | + |
| 84 | +The suite supports running the whole default bucket or a smaller subset. |
| 85 | + |
| 86 | +Common patterns: |
| 87 | + |
| 88 | +- One scenario tag |
| 89 | +- One feature-level tag |
| 90 | +- A comma-separated OR list of several scenario tags |
| 91 | + |
| 92 | +Examples: |
| 93 | + |
| 94 | +```bash |
| 95 | +export TAGS='@tektoncd-pipeline-gitops-repo-update-005' |
| 96 | +``` |
| 97 | + |
| 98 | +```bash |
| 99 | +export TAGS='@tektoncd-pipeline-gitops-repo-update' |
| 100 | +``` |
| 101 | + |
| 102 | +```bash |
| 103 | +export TAGS='@tektoncd-pipeline-gitops-repo-update-004,@tektoncd-pipeline-gitops-repo-update-005' |
| 104 | +``` |
| 105 | + |
| 106 | +Notes: |
| 107 | + |
| 108 | +- `make test` applies your `TAGS` on top of the common exclusions defined in the Makefile |
| 109 | +- By default, regular runs exclude `@automatable`, `@manual`, `@ui`, `@upgrade`, and `@prepare` |
| 110 | +- `make test` automatically handles both parallel and serial scenarios |
| 111 | + |
| 112 | +## Step 4: Run Tests |
| 113 | + |
| 114 | +The default local command is: |
| 115 | + |
| 116 | +```bash |
| 117 | +cd testing |
| 118 | +make test |
| 119 | +``` |
| 120 | + |
| 121 | +Recommended single-case workflow: |
| 122 | + |
| 123 | +```bash |
| 124 | +export KUBECONFIG=/path/to/your/kubeconfig.yaml |
| 125 | +export TAGS='@tektoncd-pipeline-gitops-repo-update-005' |
| 126 | +cd testing |
| 127 | +make test |
| 128 | +``` |
| 129 | + |
| 130 | +If your config file is not stored at the default location: |
| 131 | + |
| 132 | +```bash |
| 133 | +export KUBECONFIG=/path/to/your/kubeconfig.yaml |
| 134 | +export TESTING_CONFIG=/path/to/local-testing-config.yaml |
| 135 | +export TAGS='@tektoncd-pipeline-gitops-repo-update-005' |
| 136 | +cd testing |
| 137 | +make test |
| 138 | +``` |
| 139 | + |
| 140 | +For lower-noise debugging, you can temporarily force single-thread execution: |
| 141 | + |
| 142 | +```bash |
| 143 | +export GODOG_ARGS='--godog.concurrency=1 --godog.format=allure' |
| 144 | +cd testing |
| 145 | +make test |
| 146 | +``` |
| 147 | + |
| 148 | +If you need more attachments in the local Allure report: |
| 149 | + |
| 150 | +```bash |
| 151 | +export BDD_COLLECT_ARGS= |
| 152 | +cd testing |
| 153 | +make test |
| 154 | +``` |
| 155 | + |
| 156 | +## No Prepare Step for Regular Local Runs |
| 157 | + |
| 158 | +Do not copy the catalog repository workflow directly here. |
| 159 | + |
| 160 | +For normal local verification in this repository: |
| 161 | + |
| 162 | +- Do not run `common-integration-prepare.sh` |
| 163 | +- Do not run `make prepare-resources` unless you are explicitly validating resources labeled for prepare behavior |
| 164 | +- Start from kubeconfig, local config, tag selection, and `cd testing && make test` |
| 165 | + |
| 166 | +## Useful Commands |
| 167 | + |
| 168 | +Run only the parallel bucket: |
| 169 | + |
| 170 | +```bash |
| 171 | +cd testing |
| 172 | +make test-parallel |
| 173 | +``` |
| 174 | + |
| 175 | +Run only the serial bucket: |
| 176 | + |
| 177 | +```bash |
| 178 | +cd testing |
| 179 | +make test-serial |
| 180 | +``` |
| 181 | + |
| 182 | +Show the generated Allure report: |
| 183 | + |
| 184 | +```bash |
| 185 | +cd testing |
| 186 | +make report |
| 187 | +``` |
| 188 | + |
| 189 | +## How to Pick the Right Tag |
| 190 | + |
| 191 | +Start from the feature file that covers your change and locate: |
| 192 | + |
| 193 | +- The feature-level tag near the top of the file |
| 194 | +- The scenario tag above the exact case you want to run |
| 195 | + |
| 196 | +Example feature file: |
| 197 | + |
| 198 | +[pipeline.gitops-repo-update.feature] |
| 199 | + |
| 200 | +Typical workflow: |
| 201 | + |
| 202 | +1. Find the affected feature file in `testing/features` |
| 203 | +2. Run one scenario tag first |
| 204 | +3. Run the feature-level tag after the scenario passes |
| 205 | +4. Expand to the broader bucket only after the focused rerun is stable |
| 206 | + |
| 207 | +## Troubleshooting |
| 208 | + |
| 209 | +### Config placeholders render as `<no value>` |
| 210 | + |
| 211 | +- Your config file is missing one or more required keys |
| 212 | +- Check the exact placeholder path used by the feature file or referenced testdata |
| 213 | + |
| 214 | +### A step like `执行 "...脚本成功"` fails early |
| 215 | + |
| 216 | +- Treat it as environment or external dependency failure first |
| 217 | +- Verify the matching toolchain settings in your local config |
| 218 | + |
| 219 | +### `No scenarios` appears in the output |
| 220 | + |
| 221 | +- Your `TAGS` expression does not match any scenario |
| 222 | +- Start with one exact scenario tag instead of a complex expression |
| 223 | + |
| 224 | +### The wrong config file is being used |
| 225 | + |
| 226 | +- Verify `TESTING_CONFIG` |
| 227 | +- If unset, the suite uses `testing/config.yaml` |
| 228 | + |
| 229 | +### Tests are too noisy while debugging |
| 230 | + |
| 231 | +- Set `GODOG_ARGS='--godog.concurrency=1 --godog.format=allure'` |
| 232 | +- Narrow `TAGS` to one scenario |
| 233 | + |
| 234 | +## Recommended Team Workflow |
| 235 | + |
| 236 | +1. Export the target `KUBECONFIG` |
| 237 | +2. Prepare a local test config file |
| 238 | +3. Select one precise `TAGS` value |
| 239 | +4. Run `cd testing && make test` |
| 240 | +5. Inspect the first failing step before changing code |
| 241 | +6. Widen the scope only after the focused case passes |
0 commit comments