You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52-5Lines changed: 52 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -145,14 +145,16 @@ combiner:
145
145
- node
146
146
```
147
147
148
-
### Testing layers and merged images
149
-
During a dazzle build one can test the individual layers and the final image.
148
+
## Testing Chunks and Combinations
149
+
150
+
During a dazzle build one can test the individual chunks and the combination images.
150
151
During the build dazzle will execute the layer tests for each individual layer, as well as the final image.
151
152
This makes finding and debugging issues created by the layer merge process tractable.
152
153
153
154
Each chunk gets its own set of tests found under `tests/chunk.yaml`.
154
155
155
156
For example:
157
+
156
158
```YAML
157
159
- desc: "it should demonstrate tests"
158
160
command: ["echo", "hello world"]
@@ -170,18 +172,63 @@ For example:
170
172
- MESSAGE=foobar
171
173
assert:
172
174
- stdout.trim() == "foobar"
175
+
- desc: "it should have right binary version"
176
+
entrypoint: [bash, -i, -c]
177
+
command: [foo -version]
178
+
assert:
179
+
- stderr.indexOf("1.8.0_312") != -1
180
+
173
181
```
174
182
175
-
### Assertions
183
+
Following fields are available in the test spec.
184
+
185
+
### `assert`
186
+
187
+
Field `assert` is used to add assertions on the test.
188
+
It accepts an array input.
176
189
All test assertions are written in [ES5 Javascript](https://github.com/robertkrimen/otto).
177
190
Three variables are available in an assertion:
191
+
178
192
- `stdout`contains the standard output produced by the command
179
193
- `stderr`contains the standard error output produced by the command
180
194
- `status`contains the exit code of the command/container.
181
195
182
196
The assertion itself must evaluate to a boolean value, otherwise the test fails.
183
197
184
-
### Testing approach
198
+
### `desc`
199
+
200
+
Field `desc` is used to add description of the test.
201
+
It accepts a string input.
202
+
203
+
### `command`
204
+
205
+
Field `command` contains the test command.
206
+
It accepts an array of string.
207
+
208
+
### `entrypoint`
209
+
210
+
Field `entrypoint` defines the entrypoint in the image.
211
+
This is especially handy when the default entrypoint of the image is not a shell.
212
+
It accepts an array of string.
213
+
214
+
### `skip`
215
+
216
+
Field `skip` is used to decide if the test should run.
217
+
It accepts a boolean input.
218
+
219
+
### `user`
220
+
221
+
Field `user` is used to define the user as whom the tests should run.
222
+
It accepts a string input.
223
+
224
+
225
+
### `env`
226
+
227
+
Field `env` is used to define the user as whom the tests should run.
228
+
It accepts an array of string.
229
+
Each string is a key value pair separated by `=`.
230
+
231
+
## Testing approach
185
232
While the test runner is standalone, the linux+amd64 version is embedded into the dazzle binary using [go.rice](https://github.com/GeertJohan/go.rice) and go generate - see [build.sh](./pkg/test/runner/build.sh).
186
233
TODO: use go:embed?
187
234
Note that if you make changes to code in the test runner you will need to re-embed the runner into the binary in order to use it via dazzle.
@@ -205,7 +252,7 @@ $ go run pkg/test/runner/main.go eyJEZXNjIjoiaXQgc2hvdWxkIGhhdmUgR28gaW4gdmVyc2l
205
252
go version go1.16.4 linux/amd64
206
253
```
207
254
208
-
### Integration tests
255
+
## Integration tests
209
256
There is an integration test for the build command in pkg/dazzle/build_test.go - TestProjectChunk_test_integration and a shell script to run it.
210
257
The integration test does an end-to-end check along with editing a test and re-running to ensure only the test image is updated.
0 commit comments