Skip to content

Commit c5dbf09

Browse files
committed
removing the irrelevant code, doc, and simplifying a bit
1 parent a688f38 commit c5dbf09

16 files changed

Lines changed: 113 additions & 952 deletions

File tree

‎agent/README.md‎

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# Atum Agent
22

33
`Atum Agent` module has two main parts:
4+
45
* `AtumAgent`: Retrieves the configurations and reports the measures.
56
* `AtumContext`: Provides a library for calculating control measures over a `Spark` `Dataframe`.
67

7-
88
## Usage
99

1010
Create multiple `AtumContext` with different control measures to be applied
1111

1212
### Option 1
13+
1314
```scala
1415
val atumContextInstanceWithRecordCount = AtumContext(processor = processor)
1516
.withMeasureAdded(RecordCount(MockMeasureNames.recordCount1))
@@ -19,6 +20,7 @@ val atumContextWithSalaryAbsMeasure = atumContextInstanceWithRecordCount
1920
```
2021

2122
### Option 2
23+
2224
Use `AtumPartitions` to get an `AtumContext` from the service using the `AtumAgent`.
2325

2426
```scala
@@ -30,6 +32,7 @@ val atumContext1 = AtumAgent.getOrCreateAtumContext(atumPartitions)
3032
```
3133

3234
### Option 3
35+
3336
Create a dedicated agent instance from a custom Typesafe config.
3437

3538
```scala
@@ -50,8 +53,10 @@ val atumContext = customAgent.getOrCreateAtumContext(atumPartitions)
5053
```
5154

5255
#### AtumPartitions
56+
5357
A list of key values that maintains the order of arrival of the items, the `AtumService`
5458
is able to deliver the correct `AtumContext` according to the `AtumPartitions` we give it.
59+
5560
```scala
5661
val atumPartitions = AtumPartitions(List(
5762
"name" -> "partition-name",
@@ -85,24 +90,13 @@ val child2 = AtumAgent.getOrCreateAtumSubContext(AtumPartitions("run" -> "2"), m
8590
val merged = AtumAgent.getOrCreateAtumSubContext(AtumPartitions("run" -> "3"), Seq(parentA, parentB), copyMeasureDefinitions = true)
8691
```
8792

88-
| Overload | `copyMeasureDefinitions` |
89-
|----------|--------------------------|
90-
| `AtumContext.subPartitionContext(subPartitions)` | `false` |
91-
| `AtumContext.subPartitionContext(subPartitions, mergeWithParent = true)` | `false` |
92-
| `AtumContext.subPartitionContext(subPartitions, mergeWithParent: Boolean, copyMeasureDefinitions: Boolean)` | explicit, no default |
93-
| `AtumAgent.getOrCreateAtumSubContext(subPartitions)(implicit parent)` | `false` |
94-
| `AtumAgent.getOrCreateAtumSubContext(subPartitions, mergeWithParent = true)(implicit parent)` | `false` |
95-
| `AtumAgent.getOrCreateAtumSubContext(subPartitions, mergeWithParent: Boolean, copyMeasureDefinitions: Boolean)(implicit parent)` | explicit, no default |
96-
| `AtumAgent.getOrCreateAtumSubContext(subPartitions, parentAtumContexts: Seq[AtumContext])` | `false` |
97-
| `AtumAgent.getOrCreateAtumSubContext(subPartitions, parentAtumContexts: Seq[AtumContext], copyMeasureDefinitions: Boolean)` | explicit, no default |
98-
9993
- There is no multi-parent `AtumContext` overload; use the `AtumAgent` overloads for several parents. An empty `Seq` of
10094
parents throws `IllegalArgumentException`; duplicated parents (same partitions) are collapsed to one.
10195
- `copyMeasureDefinitions = true` makes the server copy the parents' measure definitions **only when the child is newly
10296
created**; for an already existing child the flag does nothing. Additional data is never copied.
103-
- `AtumContext.subPartitionContext` throws `PartitioningUpdateException` when `mergeWithParent` is `true` and the keys of the
104-
parent and of `subPartitions` overlap. The 3-argument `AtumAgent.getOrCreateAtumSubContext` overload has no such
105-
key-overlap guard: it simply builds `parent ++ sub` (overlapping keys take the value of `sub`).
97+
- `AtumContext.subPartitionContext` throws `PartitioningUpdateException` when `mergeWithParent` is `true` and the keys
98+
of the parent and of `subPartitions` overlap. The 3-argument `AtumAgent.getOrCreateAtumSubContext` overload has no
99+
such key-overlap guard: it simply builds `parent ++ sub` (overlapping keys take the value of `sub`).
106100

107101
#### One POST per sub-context; errors and retries
108102

@@ -121,46 +115,6 @@ Creating a sub-context resolves each parent id first with one `GET` (in the give
121115
attempts, the `POST` included). That is safe because the server-side `POST` is idempotent; the retries can put the
122116
same `POST` on the wire more than once.
123117

124-
#### Version compatibility (multi-parent)
125-
126-
Always upgrade the server before the agents. A multi-parent capable agent sends `parentPartitioningIds`
127-
(`PartitioningSubmitV2DTO`, server API v2) when creating a partitioning. The agent uses only API v2; the deprecated
128-
v1 `PartitioningSubmitDTO` is not used by the agent.
129-
An older server ignores these unknown fields and silently drops the extra parents (or all of them, with no error).
130-
Multi-parent sub-contexts therefore require a server that includes the three database migrations
131-
(`flows/V0.10.0.1___link_to_parents.sql`, `runs/V0.10.0.2__create_partitioning_with_parents.sql`,
132-
`runs/V0.10.0.3__update_partitioning_parent.sql`) and the matching v2 endpoint support.
133-
134-
Single-parent behavior, public signatures, and decoding of previously produced JSON (field absent -> empty list)
135-
are unchanged for callers of `AtumAgent` and `AtumContext` (a scripted signature comparison against v0.10.0 found only added overloads and
136-
nothing removed); the exceptions for library users are listed in "Upgrading from v0.10.x" below. The *encoded* JSON of
137-
`PartitioningSubmitV2DTO` now carries exactly `parentPartitioningIds` and `copyMeasureDefinitions` (besides `partitioning`
138-
and `author`) and no longer the singular `parentPartitioningId`; `copyMeasureDefinitions` is `false` unless you use the
139-
opt-in overloads above. The full agent / server compatibility table is in
140-
[server/README.md](../server/README.md#compatibility-matrix).
141-
142-
#### Upgrading from v0.10.x
143-
144-
1. **Deploy the server before upgrading any agent.** A new agent against an old server loses its parents.
145-
2. **Measure definitions are no longer inherited unless you ask for it.** Code that relied on a new child inheriting its
146-
parent's measure definitions must either pass `copyMeasureDefinitions = true` through the overloads above, or add the
147-
measures explicitly: `childCtx.addMeasures(parentCtx.currentMeasures)`. `addMeasures` changes the child context in place
148-
and returns it; the definitions reach the server with the child's checkpoints.
149-
3. **`PartitioningSubmitV2DTO` changed shape.** It is now
150-
`PartitioningSubmitV2DTO(partitioning, parentPartitioningIds: Seq[Long], author, copyMeasureDefinitions = false)`:
151-
there is no `.parentPartitioningId` accessor any more, the constructor and `copy` take the new parameters, and only a
152-
3-argument `apply(partitioning, parentPartitioningId: Option[Long], author)` shim is kept.
153-
4. **`Dispatcher.createPartitioning` changed its signature.** The abstract method is now
154-
```scala
155-
protected[agent] def createPartitioning(partitioning: PartitioningCreateRequest): AtumContextDTO
156-
```
157-
where `PartitioningCreateRequest(partitioning, parentPartitionings: Seq[PartitioningDTO], authorIfNew, copyMeasureDefinitions = false)`
158-
(package `za.co.absa.atum.agent.model`) replaces the v0.10.0 parameter `PartitioningSubmitDTO`. **A custom `Dispatcher`
159-
subclass compiled against 0.10.0 fails at runtime with `AbstractMethodError` and has to be adapted and recompiled.**
160-
5. **Overload delegation changed.** In `AtumAgent.getOrCreateAtumSubContext` and `AtumContext.subPartitionContext` the
161-
1-argument and 2-argument overloads now call the 3-argument overload directly (in v0.10.0 the shorter ones went through
162-
each other), so a subclass or a mock that overrides only the shorter overloads is no longer reached by
163-
`AtumContext.subPartitionContext`.
164118

165119
Control measures can also be overwritten, added or removed.
166120

@@ -175,6 +129,7 @@ Control measures can also be overwritten, added or removed.
175129
```
176130

177131
Set a checkpoint on a `Dataframe` with an `AtumContext` associated.
132+
178133
```scala
179134
val dfPersons: DataFrame = ss.read
180135
.format("CSV")
@@ -184,10 +139,11 @@ val dfPersons: DataFrame = ss.read
184139
```
185140

186141
Another way is to use measures without an `AtumContext`.
142+
187143
```scala
188144
val sequenceOfMeasures = Seq(RecordCount("columnName"), RecordCount("other columnName"))
189145

190-
val dfPersons = ss.read
146+
val dfPersons = ss.read
191147
.format("CSV")
192148
.executeMeasures("checkpoint name")(sequenceOfMeasures)
193149
```

‎api-tests/README.md‎

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,36 @@
33
- [Pre-requisites](#prerequisites)
44
- [Setup](#setup)
55
- [Backup](#backup)
6-
- [Tests Creation Rules](#tests-creation-rules)
6+
- [Collection Types](#collection-types)
77
- [Terms](#terms)
88
- [Run Tests](#run-tests)
9-
- [Utils](#utils)
10-
- [Endpoints Coverage Measurement](#endpoints-coverage-measurement)
119

1210
## Prerequisites
11+
1312
- Postman v11.34.5 (used for creating and running Postman collections)
1413
- Node.js >= v16
1514
- Newman >= v6 (used for running Postman collections in CLI)
1615

1716
## Setup
18-
- Import the Postman collection `Atum-Service_LOCAL_env.postman_environment.json` into Postman.
19-
- This file will set up env variables.
17+
18+
- Import the Postman collection `Atum-Service_LOCAL_env.postman_environment.json` into Postman.
19+
- This file will set up env variables.
2020
- Import the Postman collections for `1-shot` test:
21-
- `1_shot/Atum-Service_1-Shot_test_flow.postman_collection.json` (the only collection in this directory)
22-
- A **flow** collection: its folders run in sequence from the top to the bottom, each folder is one named test with its own preparations.
23-
- Covers the health endpoints, the v2 partitioning, ancestors, additional data, checkpoint and flow endpoints, the deprecated v1 `createPartitioning` / `createCheckpoint` calls and, in the last folder, the consolidated POST and linking behaviour of v1.1 (see [Coverage of the v1.1 folder](#coverage-of-the-v11-folder)).
21+
- `1_shot/Atum-Service_1-Shot_test_flow.postman_collection.json` (the only collection in this directory)
22+
- A **flow** collection: its folders run in sequence from the top to the bottom, each folder is one named test
23+
with its own preparations.
24+
- Covers the health endpoints, the v2 partitioning, ancestors, additional data, checkpoint and flow endpoints,
25+
and the deprecated v1 `createPartitioning` / `createCheckpoint` calls.
2426

2527
## Backup
26-
- Export the Postman collections and replace the current ones in the project repository. (Rename to avoid spaces in the file name)
27-
- Why: To have a backup of the current state of the collections.
28+
29+
- Export the Postman collections and replace the current ones in the project repository. (Rename to avoid spaces in the
30+
file name)
31+
- Why: To have a backup of the current state of the collections.
2832
- Each collection is exported separately.
2933

3034
## Collection Types
35+
3136
Note: Each Postman collection run in sequence from the top to the bottom.
3237

3338
- **Flow**:
@@ -39,20 +44,23 @@ Note: Each Postman collection run in sequence from the top to the bottom.
3944
- split multiple tests related to one flow
4045

4146
## Terms
47+
4248
- `1-shot` category: Each REST API endpoint should be covered here only one call (ideally).
4349
- Why: To reach the goal of the minimalist test with coverage of all published application endpoints.
4450
- Goal: All requests have to pass without any error. Test should be defined with this goal.
4551

4652
## Run Tests
4753

4854
### Local Using Postman
55+
4956
- Open Postman.
5057
- Import the Postman env file.
5158
- Import the Postman collection.
5259
- Select the environment for the collection.
5360
- Run the collection.
5461

5562
### Local Using Newman
63+
5664
```yaml
5765
cd api-tests
5866

@@ -62,30 +70,23 @@ newman run ./1_shot/Atum-Service_1-Shot_test_flow.postman_collection.json \
6270
```
6371

6472
### Running locally (Newman against a local server)
65-
The collection creates (uniquely named) data, so run it only against a **local or test stack**, never against a shared or production host.
73+
74+
The collection creates (uniquely named) data, so run it only against a **local or test stack**, never against a shared
75+
or production host.
76+
6677
The environment file `Atum-Service_LOCAL_env.postman_environment.json` points to `host=http://localhost:8080`.
6778

68-
1. Start a PostgreSQL database and migrate it as described in [`database/README.md`](../database/README.md#resetting-a-development-database)
69-
(a database that already applied an earlier V0.10.0.x migration of the unreleased v1.1 work has to be reset first, `flywayClean` alone is not enough).
79+
1. Start a PostgreSQL database and migrate it as described in
80+
[`database/README.md`](../database/README.md#resetting-a-development-database) (a database that already applied an
81+
earlier V0.10.0.x migration of the unreleased v1.1 work has to be reset first, `flywayClean` alone is not enough).
7082
2. Start the server (see [`server/README.md`](../server/README.md)); `GET http://localhost:8080/health` has to answer `200`.
7183
3. Run Newman from this directory:
84+
7285
```yaml
7386
cd api-tests
7487

7588
newman run ./1_shot/Atum-Service_1-Shot_test_flow.postman_collection.json \
7689
--environment Atum-Service_LOCAL_env.postman_environment.json --reporters cli,json --insecure \
7790
--reporter-json-export 1_shot_test_run.json
7891
```
79-
The run is repeatable against the same database: the first request of the v1.1 folder always generates a fresh `v11_suffix` (`v11_<Date.now()>_<random>`) and clears every other `v11_*` variable, so an aborted earlier run (or a run started in the middle of the folder) cannot leak state into the next one, and every partitioning key of the folder is new. The original folders use `api_tests_<Date.now()>`.
80-
Requests of the v1.1 folder that need an id captured by an earlier request fail with an explicit "run the folder from its first request" error instead of a misleading assertion when started in the middle. The only fixed ids are the "unknown parent" probes (`9007199254740991`, and `9007199254740000+i` for the 101-id cap); they assume that no database sequence ever reaches that range.
81-
82-
### Coverage of the v1.1 folder
83-
The last folder, `Test: consolidated POST and linking (v1.1)`, is appended after the original folders and uses only its own collection variables (prefix `v11_`); it has 25 requests (the whole collection 49). It is an HTTP-contract smoke test with one happy path per behaviour; boundaries and edge cases (self-link, the 100-parent boundary, an absent copy flag, the PATCH copy-flag matrix, concurrency) are covered by the database and server tests.
84-
It checks:
85-
- `POST /api/v2/partitionings` of a new partitioning answers `201` with a `Location` header; the same POST again (even with another author) answers `200`, the same id, the same `Location` and the **stored** author.
86-
- A single new parent can be linked to an already existing partitioning through the same POST (`200`, same id and `Location`; the ancestors are exactly that parent); a **multi-parent POST** (a new child with two valid parents in one call) puts the child into the flows of both parents.
87-
- Flow membership is asserted as **exact sets** (the flow of a parent contains exactly the parent, its children and the expected descendants, nothing else), so a leak of an unrelated partitioning into a flow fails the run.
88-
- **No descendant propagation:** when a partitioning that already has a child is linked under a new parent with `PATCH`, the request is refused with `409` and nothing is written (the new parent's flow is checked to be unchanged, as an exact set).
89-
- `copyMeasureDefinitions: true` copies the parent measure definitions to a **new** child, `false` copies none; additional data is never copied by the POST.
90-
- Error contract, one request each: a cycle is rejected with `409` (POST of a partitioning under its own descendant); an unknown parent answers `404` and the child is not created; 101 distinct parents answer `400`; `PATCH /api/v2/partitionings/{id}/ancestors` without the required copy flags answers `400`. Error responses are asserted by status code and envelope shape (`requestId`, `message`), not by the wording of the message.
91-
- `GET /api/v2/partitionings/{id}/ancestors` answers `200` with the exact set of the direct parents.
92+

0 commit comments

Comments
 (0)