-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add an oci registry for e2e test.
- Loading branch information
Showing
16 changed files
with
122 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ kpm | |
|
||
# e2e test cases dir | ||
!kpm/ | ||
scripts/pkg_in_reg/* |
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,7 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Usage: hack/run-e2e.sh | ||
# Example 1: hack/run-e2e.sh (run e2e test) | ||
# start registry at 'localhost:5001' | ||
# include account 'test' and password '1234' | ||
./scripts/reg.sh | ||
|
||
# set the kpm default registry and repository | ||
export KPM_REG="localhost:5001" | ||
export KPM_REPO="test" | ||
export OCI_REG_PLAIN_HTTP=on | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
@@ -14,6 +20,9 @@ GO111MODULE=on go install github.com/onsi/ginkgo/v2/[email protected] | |
LDFLAGS="-X kcl-lang.io/kpm/pkg/version.version=test_version" | ||
go build -ldflags "$LDFLAGS" -o ./bin/kpm | ||
|
||
# Prepare e2e test env | ||
./scripts/e2e_prepare.sh | ||
|
||
# Run e2e | ||
set +e | ||
ginkgo ./test/e2e/ | ||
|
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 @@ | ||
#!/bin/bash | ||
|
||
# Check kpm version | ||
version=$(./bin/kpm --version) | ||
if ! echo "$version" | grep -q "kpm version test_version"; then | ||
echo "Incorrect version: '$version'." | ||
exit 1 | ||
fi | ||
|
||
# pull the package 'k8s' from 'ghcr.io/kcl-lang/k8s' | ||
./scripts/pull_pkg.sh | ||
|
||
# push the package 'k8s' to 'localhost:5001/test' | ||
./scripts/push_pkg.sh |
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,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Check kpm version | ||
version=$(./bin/kpm --version) | ||
if ! echo "$version" | grep -q "kpm version test_version"; then | ||
echo "Incorrect version: '$version'." | ||
exit 1 | ||
fi | ||
|
||
# set the kpm default registry and repository | ||
export KPM_REG="ghcr.io" | ||
export KPM_REPO="kcl-lang" | ||
export OCI_REG_PLAIN_HTTP=off | ||
|
||
current_dir=$(pwd) | ||
|
||
mkdir -p ./scripts/pkg_in_reg/ | ||
|
||
cd ./scripts/pkg_in_reg/ | ||
|
||
$current_dir/bin/kpm pull k8s:1.14 | ||
$current_dir/bin/kpm pull k8s:1.27 | ||
|
||
cd "$current_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,30 @@ | ||
|
||
#!/usr/bin/env bash | ||
|
||
# Check kpm version | ||
|
||
version=$(./bin/kpm --version) | ||
if ! echo "$version" | grep -q "kpm version test_version"; then | ||
echo "Incorrect version: '$version'." | ||
exit 1 | ||
fi | ||
|
||
export KPM_REG="localhost:5001" | ||
export KPM_REPO="test" | ||
export OCI_REG_PLAIN_HTTP=on | ||
|
||
# Prepare the package on the registry | ||
current_dir=$(pwd) | ||
echo $current_dir | ||
|
||
$current_dir/bin/kpm login -u test -p 1234 localhost:5001 | ||
|
||
# Push the package k8s/1.14 to the registry | ||
cd ./scripts/pkg_in_reg/ghcr.io/kcl-lang/k8s/1.14 | ||
$current_dir/bin/kpm push | ||
|
||
cd "$current_dir" | ||
|
||
# Push the package k8s/1.17 to the registry | ||
cd ./scripts/pkg_in_reg/ghcr.io/kcl-lang/k8s/1.27 | ||
$current_dir/bin/kpm push |
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 @@ | ||
#!/bin/bash | ||
|
||
# create a directory to store user passwords | ||
mkdir -p ./scripts/registry_auth | ||
|
||
# use htpasswd to create an encrypted file | ||
htpasswd -Bbn test 1234 > ./scripts/registry_auth/htpasswd | ||
|
||
# check if there is a container named registry | ||
if [ "$(docker ps -aq -f name=registry)" ]; then | ||
# stop and remove the container named registry | ||
docker stop registry | ||
docker rm registry | ||
fi | ||
|
||
# start the Docker Registry with authentication | ||
docker run -p 5001:5000 \ | ||
--restart=always \ | ||
--name registry \ | ||
-v /var/lib/registry:/var/lib/registry \ | ||
-v $PWD/scripts/registry_auth/:/auth/ \ | ||
-e "REGISTRY_AUTH=htpasswd" \ | ||
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ | ||
-e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" \ | ||
-d registry |
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,2 @@ | ||
test:$2y$05$7jmePmQjojuLiR4tNrCHxuJtjcA2aQof6WflherD95nNhgDayGWou | ||
|
2 changes: 1 addition & 1 deletion
2
test/e2e/test_suites/kpm/no_args/kpm_pull_with_oci_url/test_suite.input
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 +1 @@ | ||
kpm pull oci://ghcr.io/kcl-lang/k8s | ||
kpm pull oci://localhost:5001/test/k8s |
6 changes: 3 additions & 3 deletions
6
test/e2e/test_suites/kpm/no_args/kpm_pull_with_oci_url/test_suite.stdout
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,4 +1,4 @@ | ||
kpm: start to pull 'oci://ghcr.io/kcl-lang/k8s'. | ||
kpm: start to pull 'oci://localhost:5001/test/k8s'. | ||
kpm: the lastest version '1.27' will be pulled. | ||
kpm: pulling '/kcl-lang/k8s:1.27' from 'ghcr.io/kcl-lang/k8s'. | ||
kpm: pulled 'oci://ghcr.io/kcl-lang/k8s' in '<workspace>/ghcr.io/kcl-lang/k8s' successfully. | ||
kpm: pulling '/test/k8s:1.27' from 'localhost:5001/test/k8s'. | ||
kpm: pulled 'oci://localhost:5001/test/k8s' in '<workspace>/localhost:5001/test/k8s' successfully. |
2 changes: 1 addition & 1 deletion
2
test/e2e/test_suites/kpm/no_args/kpm_pull_with_oci_url_tag/test_suite.input
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 +1 @@ | ||
kpm pull --tag 1.14 oci://ghcr.io/kcl-lang/k8s | ||
kpm pull --tag 1.14 oci://localhost:5001/test/k8s |
6 changes: 3 additions & 3 deletions
6
test/e2e/test_suites/kpm/no_args/kpm_pull_with_oci_url_tag/test_suite.stdout
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,3 +1,3 @@ | ||
kpm: start to pull 'oci://ghcr.io/kcl-lang/k8s' with tag '1.14'. | ||
kpm: pulling '/kcl-lang/k8s:1.14' from 'ghcr.io/kcl-lang/k8s'. | ||
kpm: pulled 'oci://ghcr.io/kcl-lang/k8s' in '<workspace>/ghcr.io/kcl-lang/k8s/1.14' successfully. | ||
kpm: start to pull 'oci://localhost:5001/test/k8s' with tag '1.14'. | ||
kpm: pulling '/test/k8s:1.14' from 'localhost:5001/test/k8s'. | ||
kpm: pulled 'oci://localhost:5001/test/k8s' in '<workspace>/localhost:5001/test/k8s/1.14' successfully. |
4 changes: 2 additions & 2 deletions
4
test/e2e/test_suites/kpm/no_args/kpm_pull_with_pkg_name/test_suite.stdout
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,4 +1,4 @@ | ||
kpm: start to pull 'k8s'. | ||
kpm: the lastest version '1.27' will be pulled. | ||
kpm: pulling 'kcl-lang/k8s:1.27' from 'ghcr.io/kcl-lang/k8s'. | ||
kpm: pulled 'k8s' in '<workspace>/ghcr.io/kcl-lang/k8s' successfully. | ||
kpm: pulling 'test/k8s:1.27' from 'localhost:5001/test/k8s'. | ||
kpm: pulled 'k8s' in '<workspace>/localhost:5001/test/k8s' successfully. |
4 changes: 2 additions & 2 deletions
4
test/e2e/test_suites/kpm/no_args/kpm_pull_with_pkg_name_tag/test_suite.stdout
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,3 +1,3 @@ | ||
kpm: start to pull 'k8s:1.27'. | ||
kpm: pulling 'kcl-lang/k8s:1.27' from 'ghcr.io/kcl-lang/k8s'. | ||
kpm: pulled 'k8s:1.27' in '<workspace>/ghcr.io/kcl-lang/k8s/1.27' successfully. | ||
kpm: pulling 'test/k8s:1.27' from 'localhost:5001/test/k8s'. | ||
kpm: pulled 'k8s:1.27' in '<workspace>/localhost:5001/test/k8s/1.27' successfully. |
2 changes: 1 addition & 1 deletion
2
test/e2e/test_suites/kpm/no_args/run_oci_with_invalid_ref/test_suite.stderr
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 +1 @@ | ||
kpm: failed to get package with 'invalid_tag' from 'ghcr.io/invalid_oci_repo'. | ||
kpm: failed to get package with 'invalid_tag' from 'localhost:5001/invalid_oci_repo'. |
2 changes: 1 addition & 1 deletion
2
test/e2e/test_suites/kpm/no_args/run_oci_with_invalid_ref/test_suite.stdout
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 +1 @@ | ||
kpm: pulling 'invalid_oci_repo:invalid_tag' from 'ghcr.io/invalid_oci_repo'. | ||
kpm: pulling 'invalid_oci_repo:invalid_tag' from 'localhost:5001/invalid_oci_repo'. |
2 changes: 1 addition & 1 deletion
2
test/e2e/test_suites/kpm/run_tar/run_tar_with_exist_not_tar/test_suite.stderr
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 +1 @@ | ||
kpm: failed to select latest version from 'ghcr.io/exist_but_not_tar'. | ||
kpm: failed to select latest version from 'localhost:5001/exist_but_not_tar'. |