-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for the following cases: 1. The same image is used by more than one compose service. 2. There are more than one version of the same app in the app store. Signed-off-by: Mike Sul <[email protected]>
- Loading branch information
Showing
3 changed files
with
102 additions
and
1 deletion.
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,29 @@ | ||
#!/bin/sh | ||
|
||
DIR="$(dirname "$(realpath "$0")")" | ||
REGISTRY_URL="registry:5000" | ||
IMAGE_NAME="factory/runner-image" | ||
IMAGE_TAG="v0.1" | ||
IMAGE_URI="${REGISTRY_URL}/${IMAGE_NAME}:${IMAGE_TAG}" | ||
|
||
SRC_IMAGE="ghcr.io/foundriesio/busybox:1.36" | ||
|
||
# Check if the image exists in the registry | ||
check_image() { | ||
local response=$(curl -s -o /dev/null -w "%{http_code}" \ | ||
"https://${REGISTRY_URL}/v2/${IMAGE_NAME}/manifests/${IMAGE_TAG}") | ||
|
||
if [[ "$response" == "200" || "$response" == "302" ]]; then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
|
||
if ! check_image; then | ||
docker pull ${SRC_IMAGE} | ||
docker tag ${SRC_IMAGE} ${IMAGE_URI} | ||
docker push ${IMAGE_URI} | ||
else | ||
echo "Image ${IMAGE_URI} exists in the registry." | ||
fi |
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,69 @@ | ||
package e2e_tests | ||
|
||
import ( | ||
f "github.com/foundriesio/composeapp/test/fixtures" | ||
"testing" | ||
) | ||
|
||
func TestAppImageMultiUse(t *testing.T) { | ||
appComposeDef := ` | ||
services: | ||
srvs-01: | ||
image: registry:5000/factory/runner-image:v0.1 | ||
command: sh -c "while true; do sleep 60; done" | ||
ports: | ||
- 8080:80 | ||
srvs-02: | ||
image: registry:5000/factory/runner-image:v0.1 | ||
command: sh -c "while true; do sleep 60; done" | ||
` | ||
app := f.NewApp(t, appComposeDef) | ||
app.Publish(t) | ||
|
||
app.Pull(t) | ||
defer app.Remove(t) | ||
|
||
app.Install(t) | ||
defer app.Uninstall(t) | ||
|
||
app.Run(t) | ||
defer app.Stop(t) | ||
app.CheckRunning(t) | ||
} | ||
|
||
func TestAppMultipleVersionsInStore(t *testing.T) { | ||
appComposeDef := ` | ||
services: | ||
srvs-01: | ||
image: registry:5000/factory/runner-image:v0.1 | ||
command: sh -c "while true; do sleep 60; done" | ||
environment: | ||
- VERSION = 0.1 | ||
` | ||
appComposeDef02 := ` | ||
services: | ||
srvs-01: | ||
image: registry:5000/factory/runner-image:v0.1 | ||
command: sh -c "while true; do sleep 60; done" | ||
environment: | ||
- VERSION = 0.2 | ||
` | ||
app := f.NewApp(t, appComposeDef) | ||
app.Publish(t) | ||
|
||
app02 := f.NewApp(t, appComposeDef02, app.Name) | ||
app02.Publish(t) | ||
|
||
app.Pull(t) | ||
defer app.Remove(t) | ||
|
||
app02.Pull(t) | ||
defer app02.Remove(t) | ||
|
||
app.Install(t) | ||
defer app.Uninstall(t) | ||
|
||
app.Up(t) | ||
defer app.Stop(t) | ||
app.CheckRunning(t) | ||
} |