ChickenBenny opened a new issue, #77731:
URL: https://github.com/apache/airflow/issues/77731

   ### Description
   
   Move the current `go-sdk/example/` and `go-sdk/dags/go_examples.py` to e2e 
fixtures unchanged, then
   rewrite the examples around one familiar scenario (an online shop), checked 
by the e2e tests only with a
   smoke test. This is the split the Java SDK already uses: `java-sdk/example` 
for users,
   `airflow-e2e-tests/java-test-bundle` and `java-native-bundle` for the tests.
   
   | Layer | Asserts |
   |---|---|
   | e2e fixtures (the current examples, moved unchanged) | exact values, edge 
cases |
   | examples (rewritten) | smoke only: the Dags parse, runs succeed, the 
expected branch runs |
   
   Proposed examples, all running with no manual setup (Variables and 
Connections fall back to defaults):
   
   - **Native Dag** `go_example_daily_sales`: fetch orders per region in a task 
group, summarize, `If` there
     were orders write the report else alert, `Switch` to a weekly digest on 
Mondays, trigger a restock Dag.
   - **Dynamic Dags** `go_example_sync_inventory_<store>`: one Dag per store 
listed in `dags.yaml`.
   - **Python + Go stub tasks** `go_example_fraud_review`: Python fetches 
orders, Go scores them with a
     worker pool that stops on cancellation and checkpoints with task state, 
Python notifies.
   
   They keep covering what the current examples cover: inputs and literals, 
task groups, `If`/`Switch`,
   trigger rules, `TriggerDagRun`, Dag run conf, YAML-generated Dags, XCom 
between Python and Go, struct
   binding, Variables, Connections and task state. Binding corner cases and 
similar edge cases stay in the
   fixtures only.
   
   Planned PRs:
   
   - [ ] Move the current examples to fixtures with no behaviour change: Dag 
IDs and assertions stay, only
      paths change (compose, k8s, pack test, selective checks, docs).
   - [ ] Rewrite the native and dynamic examples, deploy them next to the 
fixtures in the go_sdk e2e mode, add
      a smoke test.
   - [ ]  Rewrite the stub-task example, after checking that a stub task still 
reaches the right handler binary
      when the fixture and the example handler bundles are deployed together.
   
   Open questions:
   
   1. **Where should the fixtures live?**
      - (a) `go-sdk/e2e/`, in the go-sdk module: `go test ./...` (race, 32-bit) 
and `go vet` cover the
        fixtures with no CI change, and `go tool airflow-go-pack` works as is.
      - (b) `airflow-e2e-tests/go-test-bundle/`, its own module like the Java 
fixtures and
        `kubernetes-tests/lang_sdk/go_example`: it can only use the public API, 
but needs its own CI job,
        a `replace` onto `go-sdk` and a mod-tidy check.
   
      I lean towards (a) for the CI coverage, but am happy to follow the Java 
layout for consistency.
   2. **Retry in the example:** `Retries: 2` on the Go scoring task, never 
failing by default, plus a
      `simulate_crash_after_batch` conf key that stops the first try so the 
next one resumes from task
      state. Is an opt-in failure fine in an example, or should retries stay in 
the fixtures only?
   
   
   ### Use case/motivation
   
   The examples are what a Go developer reads to learn how their code fits into 
Airflow. Today they are
   also the fixtures of the go_sdk, yaml_dag and lang_sdk_xcom e2e modes, the 
k8s lang_sdk tests and
   `pack_integration_test.go`, which assert on their exact task IDs, XCom 
values and logs.
   
   So the examples are written for the tests: tasks such as `north`/`south`, 
`countRows` or
   `s3://bucket/out` show every feature but not what a Dag would use it for, 
and renaming a task breaks a
   test. Running them by hand also needs a Connection (`test_http`) and three 
Variables created first,
   which the e2e environment provides but a new user does not.
   
   I would like a user to be able to read an example as a small, realistic 
pipeline and run it as is, while
   the e2e tests keep their precise fixtures.
   
   ### Related issues
   
   None found. The open Lang-SDK PRs #74031, #74032, #74137, #74138, #74139 and 
#70571 change the same
   files (`example/bundle`, the e2e conftest, the pack test, the stub-task 
handler lookup), so PR 1 can wait
   for them to land if that is easier.
   
   Possible follow-ups, not part of this issue: `ExampleXxx` functions for 
single APIs (shown on
   pkg.go.dev), and the same split for the TypeScript SDK, whose example is 
also its fixture.
   
   ### Are you willing to submit a PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to