# Applifecycle-backend-e2e-design
# Common flow
Given YAML(s), do I get something(the right things)?
## Breakdown
```graphviz
digraph {
compound=true
rankdir=LR
subgraph cluster_0 {
user [shape="underline"]
app [label="0.0: yamls"] [shape="box"]
exp [label="0.1: expectations"] [shape="box"]
}
subgraph cluster_1 {
cluster [label="cluster",shape="underline"]
res [label="result"][shape="box"]
}
app -> cluster [label="1.0: apply", color="red"]
res -> exp [label="1.1: compare", color="red"]
green [label="1.2: green?"]
exp -> green[color="green",style=dashed]
}
```
# Design
[Design Doc](https://docs.google.com/document/d/1YEnw_EYrcMzUAR4P2QrNvaQwCq_ogujKl2yoDL8giWo/edit)
## overview
```graphviz
graph {
compound=true
rankdir=LR
graph [ fontname="Source Sans Pro", fontsize=20 ];
node [ fontname="Source Sans Pro", fontsize=18];
edge [ fontname="Source Sans Pro", fontsize=12 ];
subgraph client {
c [label="client"] [shape=box]
}
subgraph kubeconfig {
cfgDir [label="configDir"] [shape=box]
}
subgraph testInfo {
testDir [label="testDir"] [shape=box]
}
c -- server [label="GET" ltail=session lhead=session]
server -- c [label="TRsponse" ltail=session lhead=session]
subgraph cluster1 {
concentrate=true
run [label="Runner"] [shape=box]
checker [label="Checker"] [shape=box]
cleaner [label="Cleaner"] [shape=box]
handlers [label="handlerFuncs"] [shape=box]
server [label="Server"]
configs [label="configs"] [shape=box]
testInfo [label=" testCases/expectations "] [shape=box]
clt [label="Client"][shape=box]
configs -- clt
}
server -- handlers
server -- configs
server -- testInfo
cfgDir -- configs
testDir -- testInfo
handlers -- run [label="CasesRunnerHandler"]
handlers -- checker [label="ExpectationCheckerHandler"]
run -- checker
run -- cleaner
subgraph cluster2 {
concentrate=true
k8s [label="k8s" shape=plaintext]
}
clt -- k8s [label="kubectl",weight="0.7"]
}
```
# API test server
1. parse the inputs
- json input for yaml link and expectation
2. handle the comparsion(), built-in and easy to expand
- matcher logics
3. out put the result, easy to format and be consumed
- standard http response
## Example
Then we can do something like this:
```
$ curl http://localhost:8765/run?id=release-001
```
Then the test server will response as:
```
{
"test_id": "release-001",
"name": "checked expectations",
"run_status": "succeed",
"error": "",
"details": [
{
"test_id": "release-001",
"target_cluster": "hub",
"desc": "should have a channel on hub",
"apiversion": "apps.open-cluster-management.io/v1",
"kind": "channel",
"name": "git",
"namespace": "ch-git",
"matcher": "byname",
"args": {}
}
]
}
```