Skip to content

Commit 2831239

Browse files
authored
Merge pull request #161 from vjt/main
Update README and fix start-literal test descriptor
2 parents c919523 + 5cd3711 commit 2831239

4 files changed

Lines changed: 88 additions & 35 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cmds/contest/contest
22
cmds/clients/contestcli/contestcli
33
cmds/contest-generator/contest-generator
4+
tools/migration/rdbms/rdbms
45
.*.swp
56
profile.out
67
.DS_Store

README.md

Lines changed: 84 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ go get -u github.com/linuxboot/contest/cmds/contest
7070

7171
This will download and build the `contest` sample program, and will add it to your Go binary path.
7272

73+
To build the sample server from a local checkout of the Git repo, e.g. for
74+
development purposes:
75+
76+
```
77+
cd cmds/contest
78+
go build .
79+
```
80+
7381
## Running the sample server
7482

7583
There is a sample server under [cmds/contest](cmds/contest). All it does is to
@@ -83,52 +91,96 @@ a different one or build your own.
8391
After building the sample server as explained in the [Building
8492
ConTest](#building-contest) section, run it with no arguments:
8593
```
86-
$ contest
87-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering target manager csvfiletargetmanager
88-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering target manager targetlist
89-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering test fetcher uri
90-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering test fetcher literal
91-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering test step echo
92-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering test step slowecho
93-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering test step example
94-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering test step cmd
95-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering test step sshcmd
96-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering test step randecho
97-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering test step terminalexpect
98-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering reporter targetsuccess
99-
[2020-02-10T20:37:10Z] INFO pkg/pluginregistry: Registering reporter noop
100-
[2020-02-10T20:37:10Z] INFO contest: Using database URI: contest:contest@tcp(localhost:3306)/contest?parseTime=true
101-
[2020-02-10T20:37:10Z] INFO contest: JobManager &{jobs:map[] jobRunner:0xc000021b10 jobsMu:{state:0 sema:0} jobsWg:{noCopy:{} state1:[0 0 0]} jobRequestManager:{JobRequestEmitter:{} JobRequestFetcher:{}} jobReportManager:{JobReportEmitter:{} JobReportFetcher:{}} frameworkEvManager:{FrameworkEventEmitter:{} FrameworkEventFetcher:{}} testEvManager:{} apiListener:0xd0dbc0 apiCancel:0xc000030660 pluginRegistry:0xc000072480}
102-
[2020-02-10T20:37:10Z] INFO listeners/httplistener: Started HTTP API listener on :8080
94+
$ cd cmds/contest
95+
$ go build .
96+
$ ./contest
97+
[2023-05-10T13:59:26.361+02:00 I pluginregistry.go:63] Registering target manager csvfiletargetmanager
98+
[2023-05-10T13:59:26.361+02:00 I pluginregistry.go:63] Registering target manager targetlist
99+
[2023-05-10T13:59:26.361+02:00 I pluginregistry.go:76] Registering test fetcher literal
100+
[2023-05-10T13:59:26.361+02:00 I pluginregistry.go:76] Registering test fetcher uri
101+
[2023-05-10T13:59:26.361+02:00 I pluginregistry.go:89] Registering test step cmd
102+
[2023-05-10T13:59:26.361+02:00 I pluginregistry.go:89] Registering test step cpucmd
103+
[2023-05-10T13:59:26.361+02:00 I pluginregistry.go:89] Registering test step echo
104+
[2023-05-10T13:59:26.362+02:00 I pluginregistry.go:89] Registering test step exec
105+
[2023-05-10T13:59:26.362+02:00 I pluginregistry.go:89] Registering test step gathercmd
106+
[2023-05-10T13:59:26.362+02:00 I pluginregistry.go:89] Registering test step randecho
107+
[2023-05-10T13:59:26.362+02:00 I pluginregistry.go:89] Registering test step sleep
108+
[2023-05-10T13:59:26.362+02:00 I pluginregistry.go:89] Registering test step sshcmd
109+
[2023-05-10T13:59:26.362+02:00 I pluginregistry.go:113] Registering reporter noop
110+
[2023-05-10T13:59:26.362+02:00 I pluginregistry.go:113] Registering reporter targetsuccess
111+
[2023-05-10T13:59:26.362+02:00 I server.go:207] Using database URI for primary storage: contest:contest@tcp(localhost:3306)/contest?parseTime=true
112+
[2023-05-10T13:59:26.370+02:00 I server.go:221] Storage version: 7
113+
[2023-05-10T13:59:26.370+02:00 I server.go:227] Using database URI for replica storage: contest:contest@tcp(localhost:3306)/contest?parseTime=true
114+
[2023-05-10T13:59:26.372+02:00 I server.go:241] Storage version: 7
115+
[2023-05-10T13:59:26.372+02:00 I server.go:269] Locker engine set to auto, using DBLocker
116+
[2023-05-10T13:59:26.375+02:00 D storage.go:52] consistency model check: <nil>
117+
[2023-05-10T13:59:26.375+02:00 I jobmanager.go:228] Found 0 zombie jobs for /yourservername
118+
[2023-05-10T13:59:26.375+02:00 D httplistener.go:253] Serving a listener
119+
[2023-05-10T13:59:26.376+02:00 I httplistener.go:230] Started HTTP API listener on :8080
103120
```
104121

105122
The server is informing us that it started the HTTP API listener on port 8080, after registering various types of plugins: target managers, test fetchers, test steps, and reporters.
106123

107-
ConTest also requires a database to store its state, events and other data.
108-
The schema is defined under [docker/mysql/initdb.sql](docker/mysql/initdb.sql)
109-
so you can create your own. We provide a docker image to bring up a database, so
110-
you can use it with the sample server. Just run
124+
## Database
125+
126+
ConTest requires a database to store its state, events and other data.
127+
128+
* DB name and default user are defined in [docker/mysql/initdb.sql](docker/mysql/initdb.sql)
129+
* DB schema is defined in [db/rdbms/schema/v0/create_contest_db.sql](db/rdbms/schema/v0/create_contest_db.sql)
130+
* DB migrations are defined in the [db/rdbms/migration directory](db/rdbms/migration)
131+
132+
### Using docker
133+
134+
We provide a docker image to bring up a database, so you can use it with the
135+
sample server. Just run
111136
```
112137
docker-compose up mysql
113138
```
114-
115139
from the top directory of ConTest's source code.
116140

141+
### Using a local mysql instance
142+
143+
If you don't want to run Docker, or if you have already a mysql instance you
144+
want to use, you can:
145+
146+
1. Either create a "contest" local database and a "contest" user as described
147+
in the `initdb.sql` script:
148+
149+
```
150+
mysql -u root -p < docker/mysql/initdb.sql
151+
```
152+
153+
2. Load the database schema
154+
155+
```
156+
mysql -u contest -p < db/rdbms/schema/v0/create_contest_db.sql
157+
```
158+
159+
3. Run all migrations
160+
161+
```
162+
cd tools/migration/rdbms
163+
go run . -dir ../../../db/rdbms/migration up
164+
```
165+
117166
Once the database is up, it will possible to submit test jobs through the client,
118167
as shown in the next section.
119168

120-
### Submitting jobs to the sample server
169+
170+
## Submitting jobs to the sample server
121171

122172
ConTest has no official CLI, because every user is different. However we provide
123173
a sample CLI based on cleartext HTTP that will communicate to the HTTP API. All
124174
you need to do is building the sample ConTest server as described above, and run
125-
the CLI tool under [cmds/clients/contestcli-http](cmds/clients/contestcli-http).
175+
the CLI tool under [cmds/clients/contestcli](cmds/clients/contestcli).
126176
The tool is very simple:
127177
```
128-
$ ./contestcli-http -h
129-
Usage of contestcli-http:
178+
$ cd cmds/clients/contestcli
179+
$ go build .
180+
$ ./contestcli -h
181+
Usage of contestcli:
130182
131-
contestcli-http [args] command
183+
contestcli [args] command
132184
133185
command: start, stop, status, retry, version
134186
start
@@ -144,17 +196,17 @@ command: start, stop, status, retry, version
144196
145197
args:
146198
-addr string
147-
ConTest server [scheme://]host:port[/basepath] to connect to (default "http://localhost:8080")
199+
ConTest server [scheme://]host:port[/basepath] to connect to (default "http://localhost:8080")
148200
-r string
149-
Identifier of the requestor of the API call (default "contestcli-http")
201+
Identifier of the requestor of the API call (default "contestcli")
150202
exit status 2
151203
```
152204

153205
To run a job, just feed a [job descriptor](#job-descriptors) to the client's `start` command, e.g. using
154-
[start-literal.json](cmds/clients/contestcli-http/start-literal.json):
206+
[start-literal.json](cmds/clients/contestcli/descriptors/start-literal.json):
155207

156208
```
157-
$ ./contestcli-http start < start-literal.json
209+
$ ./contestcli start < descriptors/start-literal.json
158210
159211
[..output showing the job descriptor...]
160212
@@ -320,7 +372,7 @@ A job descriptor has to declare:
320372
* how to report success or failure
321373

322374
An example of a job descriptor that runs a command over SSH to a target host
323-
is available at [cmds/clients/http/start.json](cmd/clients/http/start.json), reported below and
375+
is available at [cmds/clients/contestcli/descriptors/start.json](cmds/clients/contestcli/descriptors/start.json), reported below and
324376
commented for clarity:
325377
```
326378
{

cmds/clients/contestcli/descriptors/start-literal.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"Steps": [
2525
{
2626
"name": "cmd",
27-
"label": "some label",
27+
"label": "somelabel",
2828
"parameters": {
2929
"executable": [
3030
"echo"
@@ -56,4 +56,4 @@
5656
}
5757
]
5858
}
59-
}
59+
}

cmds/clients/contestcli/descriptors/start-literal.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ TestDescriptors:
1515
TestName: literal test
1616
Steps:
1717
- name: cmd
18-
label: some label
18+
label: somelabel
1919
parameters:
2020
executable: [echo]
2121
args: ["Title={{ Title .FQDN }}, ToUpper={{ ToUpper .FQDN }}"]

0 commit comments

Comments
 (0)