-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add container-structure-test, documentation update
- Loading branch information
Showing
4 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Tests and scans documentation | ||
|
||
## Docker image - Snyk scan | ||
|
||
Docker image was scanned by Snyk: | ||
|
||
```sh | ||
docker scan http-api:latest | ||
``` | ||
|
||
output: | ||
|
||
```sh | ||
Package manager: apk | ||
Project name: docker-image|http-api | ||
Docker image: http-api | ||
Platform: linux/amd64 | ||
Base image: python:3.10.1-alpine3.15 | ||
Licenses: enabled | ||
|
||
✔ Tested 37 dependencies for known issues, no vulnerable paths found. | ||
|
||
According to our scan, you are currently using the most secure version of the selected base image | ||
``` | ||
|
||
## Docker image - container-structure-test | ||
|
||
Docker image tested by container-structure-test: | ||
|
||
```sh | ||
container-structure-test test --image http-api:latest --config tests/container.yml | ||
``` | ||
|
||
output: | ||
|
||
```sh | ||
====================================== | ||
====== Test file: container.yml ====== | ||
====================================== | ||
=== RUN: Command Test: Check python | ||
--- PASS | ||
duration: 757.87055ms | ||
stdout: Python 3.10.1 | ||
|
||
=== RUN: File Existence Test: /app/app.py | ||
--- PASS | ||
duration: 0s | ||
=== RUN: File Existence Test: /app/payload.py | ||
--- PASS | ||
duration: 0s | ||
=== RUN: File Existence Test: /app/requirements.txt | ||
--- PASS | ||
duration: 0s | ||
=== RUN: Metadata Test | ||
--- PASS | ||
duration: 0s | ||
|
||
======================================= | ||
=============== RESULTS =============== | ||
======================================= | ||
Passes: 5 | ||
Failures: 0 | ||
Duration: 757.87055ms | ||
Total tests: 5 | ||
``` | ||
|
||
|
||
## Helm test | ||
|
||
To run Helm test, execute: | ||
|
||
```sh | ||
helm test -n http-api http-api | ||
``` | ||
where `-n http-api` pointing to the namespace. | ||
|
||
output: | ||
|
||
```sh | ||
NAME: http-api | ||
LAST DEPLOYED: Fri Jan 7 18:02:22 2022 | ||
NAMESPACE: http-api | ||
STATUS: deployed | ||
REVISION: 9 | ||
TEST SUITE: http-api-test-connection | ||
Last Started: Fri Jan 7 18:05:49 2022 | ||
Last Completed: Fri Jan 7 18:05:58 2022 | ||
Phase: Succeeded | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Config for container-structure-test, see ..docs/tests.md | ||
|
||
schemaVersion: '2.0.0' | ||
commandTests: | ||
- name: 'Check python' | ||
command: 'python' | ||
args: ['--version'] | ||
expectedOutput: ['Python 3.*'] | ||
exitCode: 0 | ||
# TODO: check if possible to add timeout | ||
# - name: 'Check app' | ||
# setup: [['python', '/app/app.py']] | ||
# command: 'ps' | ||
# args: ['-aux'] | ||
fileExistenceTests: | ||
- name: '/app/app.py' | ||
path: '/app/app.py' | ||
shouldExist: true | ||
permissions: '-rw-rw-r--' | ||
uid: 0 | ||
gid: 0 | ||
- name: '/app/payload.py' | ||
path: '/app/payload.py' | ||
shouldExist: true | ||
permissions: '-rw-rw-r--' | ||
uid: 0 | ||
gid: 0 | ||
- name: '/app/requirements.txt' | ||
path: '/app/requirements.txt' | ||
shouldExist: true | ||
permissions: '-rw-rw-r--' | ||
uid: 0 | ||
gid: 0 | ||
metadataTest: | ||
labels: | ||
- key: 'org.opencontainers.image.authors' | ||
value: 'Rafal Zeidler' | ||
- key: 'org.opencontainers.image.version' | ||
value: '^[0-9]\.[0-9]\.[0-9]$' | ||
isRegex: true | ||
exposedPorts: ["5000"] | ||
entrypoint: [] | ||
cmd: ["python", "app.py"] | ||
workdir: "/app" | ||
user: "app" |