Commit f417cc1
authored
Implement POST /api/v1/relay (#3425)
* Implement POST /api/v1/relay
PBENCH-1143
This API integrates with the file-relay server by assuming that the client
(e.g., the `pbench-results-move` command) creates *two* separate files on the
relay. The main artifact is the tarball, identified only by the tarball's
computed SHA256 hash, as `http://relay.example.com/<name>/<sha256>`. However
the Pbench Server needs the MD5 for the formal `resource_id` and a *name* for
the dataset before we can begin "intake". We also want a mechanism to override
the default "private" access level, and to set metadata, so by convention we
add a second JSON file to which I'm referring as the "Relay configuration
file". This provides the dataset "metadata" we require, including the tarball
URI:
```json
{
"name": "tarball.tar.xz",
"md5": "myMD5",
"access": "private",
"metadata": ["server.origin:relay", "global.server.relay:webb"],
}
```
The Pbench Server will first `GET` the URI parameter, which it expects to be
the Relay Configuration File. It will then `GET` the `"uri"` parameter in the
configuration file.
To accomplish this, the old `Upload` code has been refactored into a base
class defining most of the logic, and two subclasses which provide "helper"
methods called `_prepare` and `_access` to encapsulate the operational
differences between the "push" and "pull" models. Essentially the `Upload`
class `_prepare` processes the URI and query parameters while the `Relay`
class `_prepare` does the first `GET` and processes the JSON configuration
parameters. The `_access` helpers return the content length and an `IO[byte]`
stream which is read and processed by the common code.
This has been tested manually by standing up an instance of the `relay` server
and I added unit tests to cover the distinct functions of the relay helper
methods while not duplicating the `upload` unit test cases that cover the
common code.1 parent 6d766a7 commit f417cc1
File tree
8 files changed
+881
-251
lines changed- lib/pbench
- client
- server/api
- resources
- test/unit/server
8 files changed
+881
-251
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
149 | 156 | | |
150 | 157 | | |
151 | 158 | | |
| |||
0 commit comments