-
Notifications
You must be signed in to change notification settings - Fork 14
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
add configurable TEST_APP_DATABASE + mysql option #51
Changes from 27 commits
8304bc1
19e13e3
8100198
e1fde03
976cf39
09cfa9d
a7a0283
e1f7ba5
9450dc0
0866984
0353016
244d192
061141b
279adb6
73474ec
c619f7e
4dd3b0e
c04839e
87c22a9
1a67b26
0fc72d7
41e1f27
6c895d8
1a09638
b93ec12
9193d9b
7fb953a
d9c17d5
e90d14a
786394a
ab32540
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
policy/generated/* | ||
pg/schema.sql | ||
openshift/postgres.yml | ||
test_app_summon/secrets.yml | ||
test_app_summon/summon* | ||
tmp.* | ||
output/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,14 +21,16 @@ pushd test_app_summon | |
|
||
# retrieve the summon binaries | ||
id=$(docker create test-app-builder) | ||
docker cp $id:/usr/local/lib/summon/summon-conjur ./ | ||
docker cp $id:/usr/local/bin/summon ./ | ||
docker cp $id:/usr/local/lib/summon/summon-conjur ./tmp.summon-conjur | ||
docker cp $id:/usr/local/bin/summon ./tmp.summon | ||
docker rm -v $id | ||
fi | ||
|
||
|
||
for app_type in "${APPS[@]}"; do | ||
# prep secrets.yml | ||
sed -e "s#{{ TEST_APP_NAME }}#test-summon-$app_type-app#g" ./secrets.template.yml > secrets.yml | ||
# NOTE: generated files are prefixed with the test app namespace to allow for parallel CI | ||
sed "s#{{ TEST_APP_NAME }}#test-summon-$app_type-app#g" ./secrets.template.yml > "tmp.$TEST_APP_NAMESPACE_NAME.secrets.yml" | ||
|
||
dockerfile="Dockerfile" | ||
if [[ "$PLATFORM" == "openshift" ]]; then | ||
|
@@ -37,6 +39,7 @@ pushd test_app_summon | |
|
||
echo "Building test app image" | ||
docker build \ | ||
--build-arg namespace=$TEST_APP_NAMESPACE_NAME\ | ||
-t test-app:$CONJUR_NAMESPACE_NAME \ | ||
-f $dockerfile . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use long-form options |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ init_registry_creds() { | |
if [[ "$PLATFORM" == "kubernetes" ]]; then | ||
if [[ "${DOCKER_EMAIL}" != "" ]]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change to single
|
||
announce "Creating image pull secret." | ||
|
||
kubectl delete --ignore-not-found secret dockerpullsecret | ||
|
||
kubectl create secret docker-registry dockerpullsecret \ | ||
|
@@ -38,16 +38,16 @@ init_registry_creds() { | |
fi | ||
elif [[ "$PLATFORM" == "openshift" ]]; then | ||
announce "Creating image pull secret." | ||
|
||
$cli delete --ignore-not-found secrets dockerpullsecret | ||
|
||
$cli secrets new-dockercfg dockerpullsecret \ | ||
--docker-server=${DOCKER_REGISTRY_PATH} \ | ||
--docker-username=_ \ | ||
--docker-password=$($cli whoami -t) \ | ||
--docker-email=_ | ||
$cli secrets add serviceaccount/default secrets/dockerpullsecret --for=pull | ||
|
||
$cli secrets add serviceaccount/default secrets/dockerpullsecret --for=pull | ||
fi | ||
} | ||
|
||
|
@@ -84,20 +84,34 @@ deploy_app_backend() { | |
statefulset/summon-init-pg \ | ||
statefulset/summon-sidecar-pg \ | ||
statefulset/secretless-pg \ | ||
statefulset/summon-init-mysql \ | ||
statefulset/summon-sidecar-mysql \ | ||
statefulset/secretless-mysql \ | ||
secret/test-app-backend-certs | ||
|
||
echo "Create secrets for test app backend" | ||
$cli --namespace $TEST_APP_NAMESPACE_NAME \ | ||
create secret generic \ | ||
test-app-backend-certs \ | ||
--from-file=server.crt=./etc/ca.pem \ | ||
--from-file=server.key=./etc/ca-key.pem | ||
|
||
echo "Deploying test app backend" | ||
test_app_pg_docker_image=$(platform_image test-app-pg) | ||
sed -e "s#{{ TEST_APP_PG_DOCKER_IMAGE }}#$test_app_pg_docker_image#g" ./$PLATFORM/postgres.yml | | ||
sed -e "s#{{ TEST_APP_NAMESPACE_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | | ||
ensure_env_database | ||
case "${TEST_APP_DATABASE}" in | ||
postgres) | ||
echo "Create secrets for test app backend" | ||
$cli --namespace $TEST_APP_NAMESPACE_NAME \ | ||
create secret generic \ | ||
test-app-backend-certs \ | ||
--from-file=server.crt=./etc/ca.pem \ | ||
--from-file=server.key=./etc/ca-key.pem | ||
|
||
echo "Deploying test app backend" | ||
test_app_pg_docker_image=$(platform_image test-app-pg) | ||
sed "s#{{ TEST_APP_PG_DOCKER_IMAGE }}#$test_app_pg_docker_image#g" ./$PLATFORM/tmp.${TEST_APP_NAMESPACE_NAME}.postgres.yml | | ||
sed "s#{{ TEST_APP_NAMESPACE_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | | ||
$cli create -f - | ||
;; | ||
mysql) | ||
echo "Deploying test app backend" | ||
test_app_mysql_docker_image="mysql/mysql-server:5.7" | ||
sed "s#{{ TEST_APP_DATABASE_DOCKER_IMAGE }}#$test_app_mysql_docker_image#g" ./$PLATFORM/tmp.${TEST_APP_NAMESPACE_NAME}.mysql.yml | sed "s#{{ TEST_APP_NAMESPACE_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | $cli create -f - | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'd add linebreaks after the pipes for readability |
||
;; | ||
esac | ||
|
||
} | ||
|
||
########################### | ||
|
@@ -116,18 +130,18 @@ deploy_sidecar_app() { | |
|
||
sleep 5 | ||
|
||
sed -e "s#{{ TEST_APP_DOCKER_IMAGE }}#$test_sidecar_app_docker_image#g" ./$PLATFORM/test-app-summon-sidecar.yml | | ||
sed -e "s#{{ AUTHENTICATOR_CLIENT_IMAGE }}#$authenticator_client_image#g" | | ||
sed -e "s#{{ IMAGE_PULL_POLICY }}#$IMAGE_PULL_POLICY#g" | | ||
sed -e "s#{{ CONJUR_VERSION }}#$CONJUR_VERSION#g" | | ||
sed -e "s#{{ CONJUR_ACCOUNT }}#$CONJUR_ACCOUNT#g" | | ||
sed -e "s#{{ CONJUR_AUTHN_LOGIN_PREFIX }}#$conjur_authn_login_prefix#g" | | ||
sed -e "s#{{ CONJUR_APPLIANCE_URL }}#$conjur_appliance_url#g" | | ||
sed -e "s#{{ CONJUR_AUTHN_URL }}#$conjur_authenticator_url#g" | | ||
sed -e "s#{{ TEST_APP_NAMESPACE_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | | ||
sed -e "s#{{ AUTHENTICATOR_ID }}#$AUTHENTICATOR_ID#g" | | ||
sed -e "s#{{ CONFIG_MAP_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | | ||
sed -e "s#{{ CONJUR_VERSION }}#'$CONJUR_VERSION'#g" | | ||
sed "s#{{ TEST_APP_DOCKER_IMAGE }}#$test_sidecar_app_docker_image#g" ./$PLATFORM/test-app-summon-sidecar.yml | | ||
sed "s#{{ AUTHENTICATOR_CLIENT_IMAGE }}#$authenticator_client_image#g" | | ||
sed "s#{{ IMAGE_PULL_POLICY }}#$IMAGE_PULL_POLICY#g" | | ||
sed "s#{{ CONJUR_VERSION }}#$CONJUR_VERSION#g" | | ||
sed "s#{{ CONJUR_ACCOUNT }}#$CONJUR_ACCOUNT#g" | | ||
sed "s#{{ CONJUR_AUTHN_LOGIN_PREFIX }}#$conjur_authn_login_prefix#g" | | ||
sed "s#{{ CONJUR_APPLIANCE_URL }}#$conjur_appliance_url#g" | | ||
sed "s#{{ CONJUR_AUTHN_URL }}#$conjur_authenticator_url#g" | | ||
sed "s#{{ TEST_APP_NAMESPACE_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | | ||
sed "s#{{ AUTHENTICATOR_ID }}#$AUTHENTICATOR_ID#g" | | ||
sed "s#{{ CONFIG_MAP_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | | ||
sed "s#{{ CONJUR_VERSION }}#'$CONJUR_VERSION'#g" | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. beautiful sed! |
||
$cli create -f - | ||
|
||
if [[ "$PLATFORM" == "openshift" ]]; then | ||
|
@@ -153,18 +167,18 @@ deploy_init_container_app() { | |
|
||
sleep 5 | ||
|
||
sed -e "s#{{ TEST_APP_DOCKER_IMAGE }}#$test_init_app_docker_image#g" ./$PLATFORM/test-app-summon-init.yml | | ||
sed -e "s#{{ AUTHENTICATOR_CLIENT_IMAGE }}#$authenticator_client_image#g" | | ||
sed -e "s#{{ IMAGE_PULL_POLICY }}#$IMAGE_PULL_POLICY#g" | | ||
sed -e "s#{{ CONJUR_VERSION }}#$CONJUR_VERSION#g" | | ||
sed -e "s#{{ CONJUR_ACCOUNT }}#$CONJUR_ACCOUNT#g" | | ||
sed -e "s#{{ CONJUR_AUTHN_LOGIN_PREFIX }}#$conjur_authn_login_prefix#g" | | ||
sed -e "s#{{ CONJUR_APPLIANCE_URL }}#$conjur_appliance_url#g" | | ||
sed -e "s#{{ CONJUR_AUTHN_URL }}#$conjur_authenticator_url#g" | | ||
sed -e "s#{{ TEST_APP_NAMESPACE_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | | ||
sed -e "s#{{ AUTHENTICATOR_ID }}#$AUTHENTICATOR_ID#g" | | ||
sed -e "s#{{ CONFIG_MAP_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | | ||
sed -e "s#{{ CONJUR_VERSION }}#'$CONJUR_VERSION'#g" | | ||
sed "s#{{ TEST_APP_DOCKER_IMAGE }}#$test_init_app_docker_image#g" ./$PLATFORM/test-app-summon-init.yml | | ||
sed "s#{{ AUTHENTICATOR_CLIENT_IMAGE }}#$authenticator_client_image#g" | | ||
sed "s#{{ IMAGE_PULL_POLICY }}#$IMAGE_PULL_POLICY#g" | | ||
sed "s#{{ CONJUR_VERSION }}#$CONJUR_VERSION#g" | | ||
sed "s#{{ CONJUR_ACCOUNT }}#$CONJUR_ACCOUNT#g" | | ||
sed "s#{{ CONJUR_AUTHN_LOGIN_PREFIX }}#$conjur_authn_login_prefix#g" | | ||
sed "s#{{ CONJUR_APPLIANCE_URL }}#$conjur_appliance_url#g" | | ||
sed "s#{{ CONJUR_AUTHN_URL }}#$conjur_authenticator_url#g" | | ||
sed "s#{{ TEST_APP_NAMESPACE_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | | ||
sed "s#{{ AUTHENTICATOR_ID }}#$AUTHENTICATOR_ID#g" | | ||
sed "s#{{ CONFIG_MAP_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | | ||
sed "s#{{ CONJUR_VERSION }}#'$CONJUR_VERSION'#g" | | ||
$cli create -f - | ||
|
||
if [[ "$PLATFORM" == "openshift" ]]; then | ||
|
@@ -194,13 +208,27 @@ deploy_secretless_app() { | |
|
||
sleep 5 | ||
|
||
sed -e "s#{{ CONJUR_VERSION }}#$CONJUR_VERSION#g" ./$PLATFORM/test-app-secretless.yml | | ||
sed -e "s#{{ SECRETLESS_IMAGE }}#$secretless_image#g" | | ||
sed -e "s#{{ CONJUR_AUTHN_URL }}#$conjur_authenticator_url#g" | | ||
sed -e "s#{{ CONJUR_AUTHN_LOGIN_PREFIX }}#$conjur_authn_login_prefix#g" | | ||
sed -e "s#{{ CONFIG_MAP_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | | ||
sed -e "s#{{ CONJUR_ACCOUNT }}#$CONJUR_ACCOUNT#g" | | ||
sed -e "s#{{ CONJUR_APPLIANCE_URL }}#$conjur_appliance_url#g" | | ||
ensure_env_database | ||
case "${TEST_APP_DATABASE}" in | ||
postgres) | ||
PORT=5432 | ||
PROTOCOL=postgresql | ||
;; | ||
mysql) | ||
PORT=3306 | ||
PROTOCOL=mysql | ||
;; | ||
esac | ||
secretless_db_url="$PROTOCOL://localhost:$PORT/test_app" | ||
|
||
sed "s#{{ CONJUR_VERSION }}#$CONJUR_VERSION#g" ./$PLATFORM/test-app-secretless.yml | | ||
sed "s#{{ SECRETLESS_IMAGE }}#$secretless_image#g" | | ||
sed "s#{{ SECRETLESS_DB_URL }}#$secretless_db_url#g" | | ||
sed "s#{{ CONJUR_AUTHN_URL }}#$conjur_authenticator_url#g" | | ||
sed "s#{{ CONJUR_AUTHN_LOGIN_PREFIX }}#$conjur_authn_login_prefix#g" | | ||
sed "s#{{ CONFIG_MAP_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | | ||
sed "s#{{ CONJUR_ACCOUNT }}#$CONJUR_ACCOUNT#g" | | ||
sed "s#{{ CONJUR_APPLIANCE_URL }}#$conjur_appliance_url#g" | | ||
$cli create -f - | ||
|
||
if [[ "$PLATFORM" == "openshift" ]]; then | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,16 @@ announce "Validating that the deployments are functioning as expected." | |
|
||
set_namespace $TEST_APP_NAMESPACE_NAME | ||
|
||
echo "Waiting for pods to become available" | ||
|
||
while [[ $(pods_not_ready "test-app-summon-init") ]] || | ||
[[ $(pods_not_ready "test-app-summon-sidecar") ]] || | ||
[[ $(pods_not_ready "test-app-secretless") ]]; do | ||
printf "." | ||
sleep 1 | ||
done | ||
echo "" | ||
|
||
if [[ "$PLATFORM" == "openshift" ]]; then | ||
echo "Waiting for deployments to become available" | ||
|
||
|
@@ -51,23 +61,28 @@ if [[ "$PLATFORM" == "openshift" ]]; then | |
init_url="localhost:8081" | ||
sidecar_url="localhost:8082" | ||
secretless_url="localhost:8083" | ||
|
||
# Pause for the port-forwarding to complete setup | ||
sleep 10 | ||
else | ||
echo "Waiting for services to become available" | ||
while [ -z "$(service_ip "test-app-summon-init")" ] || | ||
[ -z "$(service_ip "test-app-summon-sidecar")" ] || | ||
[ -z "$(service_ip "test-app-secretless")" ]; do | ||
printf "." | ||
sleep 1 | ||
sleep 3 | ||
done | ||
|
||
init_url=$(service_ip test-app-summon-init):8080 | ||
sidecar_url=$(service_ip test-app-summon-sidecar):8080 | ||
secretless_url=$(service_ip test-app-secretless):8080 | ||
fi | ||
|
||
echo "Waiting for urls to be ready" | ||
until $(curl -s --connect-timeout 3 $init_url > /dev/null) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's change |
||
$(curl -s --connect-timeout 3 $sidecar_url > /dev/null) && | ||
$(curl -s --connect-timeout 3 $secretless_url > /dev/null); do | ||
printf "." | ||
sleep 3 | ||
done | ||
|
||
echo -e "\nAdding entry to the init app\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
curl \ | ||
-d '{"name": "Mr. Init"}' \ | ||
|
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.
use long-form flag