-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test framework #28
Merged
Merged
Test framework #28
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b9366d3
test: Add compose-based dev&test environment
mike-sul 0252aa7
test: Add test fixtures and base e2e test
mike-sul 12a8f4d
test: Add tests for two edge cases
mike-sul 8bba07d
ci: Add github workflow to run all tests
mike-sul 6eca275
readme: Update README with info about dev&test env
mike-sul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Tests | ||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Build and run all tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: build | ||
run: docker compose --env-file=test/compose/.env.test -f test/compose/docker-compose.yml run composectl make | ||
- name: test | ||
run: docker compose --env-file=test/compose/.env.test -f test/compose/docker-compose.yml run composectl make test-e2e | ||
- name: teardown test env | ||
run: docker compose --env-file=test/compose/.env.test -f test/compose/docker-compose.yml down |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea | ||
bin/ | ||
.cache |
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
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
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,9 @@ | ||
down() { | ||
docker compose --env-file=test/compose/.env.test -f test/compose/docker-compose.yml down --remove-orphans | ||
# remove the docker runtime and compose app store volumes | ||
docker volume rm compose_docker-runtime compose_reset-apps | ||
} | ||
|
||
trap down EXIT | ||
|
||
docker compose --env-file=test/compose/.env.test -f test/compose/docker-compose.yml run composectl $@ |
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,9 @@ | ||
SRC_DIR=$PWD | ||
BIN_DIR=$SRC_DIR/bin | ||
TEST_DIR=$SRC_DIR/test | ||
CPS_DIR=$TEST_DIR/compose | ||
|
||
REG_DIR=$CPS_DIR/registry | ||
REG_CERT_DIR=$REG_DIR/certs | ||
# This must be relative to SRC_DIR path | ||
REG_CERT=test/compose/registry/certs/registry.crt |
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,13 @@ | ||
FROM golang:1.22-alpine | ||
|
||
ARG REG_CERT=test/compose/registry/certs/registry.crt | ||
ARG SRC_DIR=$PWD | ||
|
||
RUN apk add make curl docker docker-compose git | ||
|
||
COPY $REG_CERT /etc/ssl/certs/registry.crt | ||
RUN cat /etc/ssl/certs/registry.crt >> /etc/ssl/certs/ca-certificates.crt | ||
WORKDIR /build | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
RUN git config --global --add safe.directory $SRC_DIR |
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,42 @@ | ||
services: | ||
registry: | ||
image: ghcr.io/foundriesio/docker-distribution:2.8.3-fio | ||
volumes: | ||
- ${REG_CERT_DIR}:/certs | ||
- ${REG_DIR}/config.yml:/etc/docker/registry/config.yml | ||
|
||
dockerd: | ||
image: ghcr.io/foundriesio/moby:25.0.3_fio | ||
command: ["dockerd", "-D", "-H", "unix:///var/run/docker/docker.sock"] | ||
privileged: true | ||
volumes: | ||
- docker-runtime:/var/run/docker | ||
- ${REG_DIR}/daemon.json:/etc/docker/daemon.json:ro | ||
- reset-apps:/var/sota/reset-apps | ||
|
||
composectl: | ||
build: | ||
context: ${SRC_DIR} | ||
dockerfile: ${CPS_DIR}/Dockerfile | ||
args: | ||
REG_CERT: ${REG_CERT} | ||
SRC_DIR: ${SRC_DIR} | ||
volumes: | ||
- ${SRC_DIR}:${SRC_DIR} | ||
- ${BIN_DIR}:${SRC_DIR}/bin | ||
- docker-runtime:/var/run/docker | ||
- reset-apps:/var/sota/reset-apps | ||
working_dir: ${SRC_DIR} | ||
depends_on: | ||
- registry | ||
- dockerd | ||
environment: | ||
- GOCACHE=${SRC_DIR}/.cache | ||
- DOCKER_HOST=unix:///var/run/docker/docker.sock | ||
- COMPOSECTL_EXE=${BIN_DIR}/composectl | ||
- SRC_DIR=${SRC_DIR} | ||
- STOREROOT=/var/sota/reset-apps | ||
|
||
volumes: | ||
docker-runtime: | ||
reset-apps: |
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,3 @@ | ||
#!/bin/bash | ||
|
||
openssl req -new -x509 -nodes -days 36500 -config openssl.cnf -keyout registry.key -out registry.crt |
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,25 @@ | ||
[ req ] | ||
default_bits = 4096 | ||
distinguished_name = req_distinguished_name | ||
req_extensions = req_ext | ||
x509_extensions = v3_req | ||
prompt = no | ||
|
||
[ req_distinguished_name ] | ||
C = US | ||
ST = State | ||
L = City | ||
O = Organization | ||
CN = registry | ||
|
||
[ req_ext ] | ||
subjectAltName = @alt_names | ||
|
||
[ v3_req ] | ||
subjectAltName = @alt_names | ||
|
||
[ alt_names ] | ||
DNS.1 = registry | ||
DNS.2 = localhost | ||
IP.1 = 127.0.0.1 | ||
|
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,31 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIFZDCCA0ygAwIBAgIUD6KzUJQJR7CPdPYnPZxOiAyNdckwDQYJKoZIhvcNAQEL | ||
BQAwVjELMAkGA1UEBhMCVVMxDjAMBgNVBAgMBVN0YXRlMQ0wCwYDVQQHDARDaXR5 | ||
MRUwEwYDVQQKDAxPcmdhbml6YXRpb24xETAPBgNVBAMMCHJlZ2lzdHJ5MCAXDTI0 | ||
MDkxOTA5NTYyM1oYDzIxMjQwODI2MDk1NjIzWjBWMQswCQYDVQQGEwJVUzEOMAwG | ||
A1UECAwFU3RhdGUxDTALBgNVBAcMBENpdHkxFTATBgNVBAoMDE9yZ2FuaXphdGlv | ||
bjERMA8GA1UEAwwIcmVnaXN0cnkwggIi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trbRzlS5VbrC30iMvcCfslcXsbl/gcCZbcJh3h | ||
y0Ju4xP26o4xK+mW1mbCBXZJ6rByzs3B8Pn1l5K9dbKxvb6c4yw/GuTDuzzHkgG+ | ||
wBTfoqkxk/nnU4l+jgl2qT4DjCZBnonk4Abj9UP4ZPB0qLCrR7h/lfex1rOZ5Het | ||
7Wl2aJtA19zuIAE4qMuQfgtcB8NLTrj6dWUCCmfJdhKjad+dA8uKgXYmT/NYYuvp | ||
wr/g/Kjf7DaPs8SN+zP+MXEX6rXPCxYi5NQfpJ8bEC8o3TWLTrfWNAdkJNYS4vCf | ||
P/QXl40YeIhjtMkyyY3LH1+yLRMc6uWd+YG9H6t7mP6+pYnIZ8uCgR2yXQQcDYDt | ||
q4seLCcyvkOrt0eDqth4VDS1SweDyIodYPDMA9mwsBjY3AT5m0nbvhZf4vGwxDhK | ||
elQdZQYmUjzxgz9kKjyzDPYscTZXGQramIBsskcmAsYuByYND7Nvow== | ||
-----END CERTIFICATE----- |
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,52 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQC7U1ouHJ/2wJt2 | ||
q19gzt/rfCStH74Elwti0hQ0+Bpg97P2ooD2GixYzWHxY5oeVoAAswVA8A0RWTOL | ||
w9qIijdWTsG32CUBSaAjdnD6TeawxsayUwUq9xZYweQJrGUYzsGs6fBMRjriPGLV | ||
cOw9TArEPmXMucd2W7qRrWBMrLvCXzcaETFy57uM5AQGmEBnvXcGdOlEjN4VNv/g | ||
retSkVVX93f/Efw8MWrN+ABXXthEoKAv+iriPrfeU0JWkx6tFr3SS7/Xg6XbRAHN | ||
WhxSfkSY8SGTv+1qeDpSv3YUBkzPcxbWWej1FCaonwmRxIk8x1ysF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3ITWvTTS2KuHrpG7YM/m5IFtYpo00TAsieSFQWZTKexgeUXx | ||
fn39adipZE9sWQJ+95khyJtrcYVrRXKr2YswpJUCggEAaHh5OIezGJxIQRtdTlTU | ||
vWFOqwYuB1HT/fRhs3MH0ukO16ParT7fHLPl7tVMHD6RY6AVaYwUXeVL6LiF8+l2 | ||
CJwja/znlZTVRZMx6/7KAA8dCW1IBqYO8W91Xhf2BziIRNTwhriJapdgHarnFC7+ | ||
MXr1tZ0y4bVacqqnN6JsiyC/19ufTNIeTmW/W1nsbbKbJ68uk21qWI5DHHlIqaUd | ||
TVhw+cCRzPzel7clKA8ea5lIW7dGc/m+dPtXlr1pc/javBG8t3Vzv0sCmxLe8BjS | ||
q2sS/LTl2M21SqfJLaZ8hXPoY8XO8XQ1LSsjWX78qct9MfsgD4Yx/1L2YGSEo+fj | ||
sQKCAQEAwijX7Qy6f11mcl5vzR8HGJ+fGgmdy9j3zgdnQ66kvIVz4TlIEY5XYUe+ | ||
99acyhF+VcOID6Mmk1CMv/vHUMKBjIUKqjUGshvv+KdBkqI+4Py+V2wnCn200eun | ||
eb2X07V+BoBKM1y/v0SsuShi6MvdxNsG4cujtn5aUHSdWf5t712cMW8liWewPqFT | ||
OuJnu3Vk5O5x6VDJtEzO9Vg1h9Jgg3TimzHrvrpLKUhQNKtcfkBYVCHklnqNhabn | ||
dT17WUw5rF5yVZf+NxJsNsIBgfT/PEr36E+KjKeRMndleGhlS+lbs8WeCw+1pk8A | ||
cz11Y7m1L6FbApCu066rZJn9BmA2Hw== | ||
-----END PRIVATE KEY----- |
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,14 @@ | ||
version: 0.1 | ||
log: | ||
level: debug | ||
fields: | ||
service: registry | ||
environment: development | ||
storage: | ||
filesystem: | ||
rootdirectory: /var/lib/registry | ||
http: | ||
addr: :5000 | ||
tls: | ||
certificate: /certs/registry.crt | ||
key: /certs/registry.key |
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,3 @@ | ||
{ | ||
"insecure-registries": ["registry:5000"] | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might include the script to generate this. You have the conf file. I remember using something like this from moby once and losing 15 minutes needing to generate a cert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the script b9366d3#diff-f54df8e08c3b21fa819dac5c97750f3835e5ae32da8e4e02d18e6eab35a01608