-
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 23 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,12 @@ | ||
policy/generated/* | ||
pg/schema.sql | ||
openshift/*.postgres.yml | ||
openshift/*.mysql.yml | ||
kubernetes/*.postgres.yml | ||
kubernetes/*.mysql.yml | ||
openshift/postgres.yml | ||
test_app_summon/secrets.yml | ||
openshift/mysql.yml | ||
kubernetes/postgres.yml | ||
kubernetes/mysql.yml | ||
test_app_summon/*.secrets.yml | ||
test_app_summon/summon* | ||
output/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,11 @@ pushd test_app_summon | |
docker rm -v $id | ||
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 flag |
||
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 -e "s#{{ TEST_APP_NAME }}#test-summon-$app_type-app#g" ./secrets.template.yml > "$TEST_APP_NAMESPACE_NAME.secrets.yml" | ||
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. same here |
||
|
||
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 | | ||
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 -e "s#{{ TEST_APP_PG_DOCKER_IMAGE }}#$test_app_pg_docker_image#g" ./$PLATFORM/${TEST_APP_NAMESPACE_NAME}.postgres.yml | | ||
sed -e "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 -e "s#{{ TEST_APP_DATABASE_DOCKER_IMAGE }}#$test_app_mysql_docker_image#g" ./$PLATFORM/${TEST_APP_NAMESPACE_NAME}.mysql.yml | sed -e "s#{{ TEST_APP_NAMESPACE_NAME }}#$TEST_APP_NAMESPACE_NAME#g" | $cli create -f - | ||
;; | ||
esac | ||
|
||
} | ||
|
||
########################### | ||
|
@@ -194,8 +208,22 @@ deploy_secretless_app() { | |
|
||
sleep 5 | ||
|
||
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 -e "s#{{ CONJUR_VERSION }}#$CONJUR_VERSION#g" ./$PLATFORM/test-app-secretless.yml | | ||
sed -e "s#{{ SECRETLESS_IMAGE }}#$secretless_image#g" | | ||
sed -e "s#{{ SECRETLESS_DB_URL }}#$secretless_db_url#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" | | ||
|
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" | ||
while ! $(curl -s --connect-timeout 3 $init_url > /dev/null) || | ||
doodlesbykumbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
! $(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"}' \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,29 +9,59 @@ pipeline { | |
} | ||
|
||
stages { | ||
stage('Deploy Demos') { | ||
// Postgres Tests | ||
stage('Deploy Demos Postgres') { | ||
parallel { | ||
stage('GKE and v4 Conjur') { | ||
stage('GKE, v4 Conjur, Postgres') { | ||
steps { | ||
sh 'cd ci && summon -e gke ./test gke 4' | ||
sh 'cd ci && summon -e gke ./test gke 4 postgres' | ||
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. any reason we don't use bash here? |
||
} | ||
} | ||
|
||
stage('GKE and v5 Conjur') { | ||
stage('GKE, v5 Conjur, Postgres') { | ||
steps { | ||
sh 'cd ci && summon -e gke ./test gke 5' | ||
sh 'cd ci && summon -e gke ./test gke 5 postgres' | ||
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 longform flag |
||
} | ||
} | ||
|
||
stage('OpenShift v3.9 and v4 Conjur') { | ||
stage('OpenShift v3.9, v4 Conjur, Postgres') { | ||
steps { | ||
sh 'cd ci && summon -e oc ./test oc 4' | ||
sh 'cd ci && summon -e oc ./test oc 4 postgres' | ||
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. same in all cases here... |
||
} | ||
} | ||
|
||
stage('OpenShift v3.9 and v5 Conjur') { | ||
stage('OpenShift v3.9, v5 Conjur, Postgres') { | ||
steps { | ||
sh 'cd ci && summon -e oc ./test oc 5' | ||
sh 'cd ci && summon -e oc ./test oc 5 postgres' | ||
} | ||
} | ||
} | ||
} | ||
|
||
// MySQL Tests | ||
stage('Deploy Demos MySQL') { | ||
parallel { | ||
stage('GKE, v4 Conjur, MySQL') { | ||
steps { | ||
sh 'cd ci && summon -e gke ./test gke 4 mysql' | ||
} | ||
} | ||
|
||
stage('GKE, v5 Conjur, MySQL') { | ||
steps { | ||
sh 'cd ci && summon -e gke ./test gke 5 mysql' | ||
} | ||
} | ||
|
||
stage('OpenShift v3.9, v4 Conjur, MySQL') { | ||
steps { | ||
sh 'cd ci && summon -e oc ./test oc 4 mysql' | ||
} | ||
} | ||
|
||
stage('OpenShift v3.9, v5 Conjur, MySQL') { | ||
steps { | ||
sh 'cd ci && summon -e oc ./test oc 5 mysql' | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# Usage: | ||
# summon -e [platform] ./test [platform] [conjur version] | ||
# summon -e [platform] ./test [platform] [conjur version] [database] | ||
doodlesbykumbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# platform: gke or oc | ||
# conjur version: 4 or 5 | ||
# database: postgres or mysql | ||
|
||
set -euo pipefail | ||
IFS=$'\n\t' | ||
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. This appears to remove the space from the default value. We should add a note about why we're doing this... I know this isn't new code, just noticed it now and the answer isn't clear to me... 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 have no idea why we're doing that either |
||
|
@@ -31,30 +32,14 @@ trap finish EXIT | |
function printUsage() { | ||
echo "---" | ||
echo "Usage:" | ||
echo "summon -e [platform] ./test [platform] [conjur version]" | ||
echo "summon -e [platform] ./test [platform] [conjur version] [database]" | ||
echo "platform: gke or oc" | ||
echo "conjur version: 4 or 5" | ||
echo "database: postgres or mysql" | ||
|
||
exit 1 | ||
} | ||
|
||
# Parse input arguments | ||
if [ $# -ne 2 ]; then | ||
echo "Invalid number of arguments." | ||
printUsage | ||
fi | ||
|
||
TEST_PLATFORM="$1" | ||
CONJUR_VERSION="$2" | ||
|
||
export TEST_PLATFORM | ||
export CONJUR_VERSION | ||
|
||
# sensible default for OPENSHIFT_URL port | ||
if [[ ! -z "${OPENSHIFT_URL}" ]] && [[ "${OPENSHIFT_URL}" != *: ]]; then | ||
OPENSHIFT_URL="${OPENSHIFT_URL}:8443" | ||
fi | ||
|
||
function main() { | ||
announce 'Checking arguments' | ||
checkArguments | ||
|
@@ -71,7 +56,7 @@ function main() { | |
|
||
function deployConjur() { | ||
pushd .. | ||
git clone [email protected]:cyberark/kubernetes-conjur-deploy kubernetes-conjur-deploy-$UNIQUE_TEST_ID | ||
git clone --single-branch --branch kt/hot-fixes [email protected]:cyberark/kubernetes-conjur-deploy kubernetes-conjur-deploy-$UNIQUE_TEST_ID | ||
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. why do we clone the 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. we'll pull it out later. there were some fixes necessary to move forward - cyberark/kubernetes-conjur-deploy#49 |
||
popd | ||
|
||
runDockerCommand "cd kubernetes-conjur-deploy-$UNIQUE_TEST_ID && ./start" | ||
|
@@ -143,6 +128,7 @@ function runDockerCommand() { | |
-e CONJUR_ADMIN_PASSWORD \ | ||
-e AUTHENTICATOR_ID \ | ||
-e TEST_APP_NAMESPACE_NAME \ | ||
-e TEST_APP_DATABASE \ | ||
-e PLATFORM \ | ||
-e DOCKER_REGISTRY_URL \ | ||
-e DOCKER_REGISTRY_PATH \ | ||
|
@@ -190,4 +176,23 @@ function checkArguments() { | |
printUsage | ||
} | ||
|
||
# Parse input arguments | ||
if [ $# -ne 3 ]; then | ||
doodlesbykumbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo "Invalid number of arguments." | ||
printUsage | ||
fi | ||
|
||
TEST_PLATFORM="$1" | ||
CONJUR_VERSION="$2" | ||
TEST_APP_DATABASE="$3" | ||
|
||
export TEST_PLATFORM | ||
export CONJUR_VERSION | ||
export TEST_APP_DATABASE | ||
|
||
# sensible default for OPENSHIFT_URL port | ||
if [[ ! -z "${OPENSHIFT_URL}" ]] && [[ "${OPENSHIFT_URL}" != *: ]]; then | ||
doodlesbykumbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
OPENSHIFT_URL="${OPENSHIFT_URL}:8443" | ||
fi | ||
|
||
main |
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.
If
openshift
andkubernetes
are locations for ephemeral config files, i think we should but the under a directory with a clear name indicating that. something liketmp/openshift
andtmp/kubernetes
or similar. and / or add the entire folder to .gitignore.as is, i'd expect these folders to be meaningful.... so it's confusing.
EDIT: also, i see below that there are tons of other yml files you created which appear not to be ephermeral, so now i'm even more confused....
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.
I'm only renaming (by adding namespace), these existed before this PR.
Having a single folder called tmp would be a nice thing to have. I'd need to modify the build of
test_app_summon
since it looks for it's build context specifically inside the./test_app_summon
folder to make this work.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.
How about prepending
tmp
to these files so they becometmp.*
? This would be much easier to introduce than the tmp folder