Skip to content
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

dockolith POC #1331

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c8ed138
first pass
jaredperreault-okta Oct 24, 2022
7c5fc04
testing on bacon
jaredperreault-okta Oct 25, 2022
92960da
fixes bacon.yml
jaredperreault-okta Oct 25, 2022
0629593
removes dockolith
jaredperreault-okta Oct 25, 2022
b79b335
fixes e2e dockolith
jaredperreault-okta Oct 26, 2022
010a3e5
fixes bacon
jaredperreault-okta Oct 26, 2022
53a0a8b
fixes bacon
jaredperreault-okta Oct 26, 2022
6fd703c
fixes e2e to run on dockolith
jaredperreault-okta Oct 28, 2022
89f336e
fixes bacon
jaredperreault-okta Oct 28, 2022
787e901
fixes bacon
jaredperreault-okta Oct 28, 2022
f61f84e
fixes hidden linter errors
jaredperreault-okta Oct 29, 2022
c5f9f33
pr feedback
jaredperreault-okta Nov 3, 2022
3324428
fixes bacon
jaredperreault-okta Nov 3, 2022
fbfd653
fixes bacon
jaredperreault-okta Nov 3, 2022
21eb8ee
fix for bacon
jaredperreault-okta Nov 3, 2022
31543d9
fixes e2e tests, turns on headless mode on bacon
jaredperreault-okta Nov 3, 2022
ac9aa87
install chrome on bacon
jaredperreault-okta Nov 3, 2022
fe4ce8f
fixes linter issues
jaredperreault-okta Nov 4, 2022
1152e6f
skip tests
jaredperreault-okta Nov 4, 2022
f46a7c4
fixes e2e-monolith
jaredperreault-okta Nov 4, 2022
e05500c
feedback
jaredperreault-okta Nov 8, 2022
7d8330e
adds buildversion override
jaredperreault-okta Dec 6, 2022
dc2472c
update buildversion
jaredperreault-okta Dec 7, 2022
a71ff29
bumps dockolith version
jaredperreault-okta Dec 19, 2022
ac29ceb
updates to monolith version with test baselines
jaredperreault-okta Dec 21, 2022
d893c1e
new build version
jaredperreault-okta Jan 12, 2023
8ec1bd4
fixes org setup
jaredperreault-okta Jan 17, 2023
8554753
fixes embedded login error
jaredperreault-okta Jan 17, 2023
dd280c8
disable https
jaredperreault-okta Jan 17, 2023
f4b2610
disable cucumber tests for dockolith
jaredperreault-okta Jan 17, 2023
e0a7c45
fixes failing cucumber suite
jaredperreault-okta Jan 18, 2023
2248fde
new buildversion
jaredperreault-okta Jan 20, 2023
92f4d70
debug bacon
jaredperreault-okta Jan 20, 2023
b6e5b17
new build version
jaredperreault-okta Jan 20, 2023
456f668
new buildversion
jaredperreault-okta Jan 20, 2023
464b770
bumps java version
jaredperreault-okta Jan 21, 2023
3698d3d
new build version
jaredperreault-okta Jan 23, 2023
db028ee
new build version
jaredperreault-okta Jan 23, 2023
993d3b2
buildversion
jaredperreault-okta Jan 23, 2023
09c9e97
update queue name
jaredperreault-okta Jan 23, 2023
70327e9
new build
jaredperreault-okta Jan 23, 2023
964c23f
removes java install
jaredperreault-okta Jan 23, 2023
52c638e
updates dockolith
jaredperreault-okta Mar 10, 2023
fae241d
fixes bacon
jaredperreault-okta Mar 10, 2023
2313845
fixes bacon
jaredperreault-okta Mar 10, 2023
f2542c9
fixes scripts
jaredperreault-okta Mar 10, 2023
ff6d9fb
bacon wont finish
jaredperreault-okta Mar 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .bacon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ test_suites:
script_name: verify-registry-install
criteria: MERGE
queue_name: small

- name: e2e-monolith
script_path: ../okta-auth-js/scripts/e2e
sort_order: '14'
timeout: '30'
script_name: e2e-dockolith
criteria: OPTIONAL
queue_name: ci-queue-prodJenga-Monolith-Build
# Sauce labs tests are flaky due to the free account we are currently using
# Re-enable this task on bacon once we have an paid account
# - name: e2e-saucelabs
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ build2/reports/e2e/*
!build2/reports/e2e/.gitkeep
test/SpecRunner.html
npm-debug.log
testenv
testenv*
testenv.yml
junit.xml
junit-results.xml
yarn-error.*
coverage
dist
.bacon.env
scripts/dockolith
dockolith

!.gitkeep
42 changes: 42 additions & 0 deletions scripts/e2e/e2e-dockolith.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

LOCAL_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)

export CI=true
# export SKIP_SETUP_BUILD=1
source $LOCAL_DIR/../setup-dockolith.sh

create_log_group "E2E Setup"
export DBUS_SESSION_BUS_ADDRESS=/dev/null
export TEST_SUITE_TYPE="junit"
export TEST_RESULT_FILE_DIR="${REPO}/build2/reports/e2e"

# NOTE: exports which are used to control test and/or test app behavior have been
# moved to test/support/monolith/create-e2e-env.ts (output via testenv.local)

# re-export testenv
set -a
source $LOCAL_DIR/../../testenv
set +a

export TEST_NAME=@okta/test.app
finish_log_group $?

create_log_group "E2E Test Run"
if ! yarn test:e2e; then
echo "Cucumber tests failed! Exiting..."
exit ${TEST_FAILURE}
fi
finish_log_group $?

# Skip cucumber tests for now
# create_log_group "E2E Cucumber Test Run"
# if ! yarn test:e2e:cucumber; then
# echo "Cucumber tests failed! Exiting..."
# exit ${TEST_FAILURE}
# fi
# finish_log_group $?

echo ${TEST_SUITE_TYPE} > ${TEST_SUITE_TYPE_FILE}
echo ${TEST_RESULT_FILE_DIR} > ${TEST_RESULT_FILE_DIR_FILE}
exit ${PUBLISH_TYPE_AND_RESULT_DIR}
8 changes: 8 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ source ${OKTA_HOME}/${REPO}/scripts/setup.sh
export TEST_SUITE_TYPE="checkstyle"
export TEST_RESULT_FILE_DIR="${REPO}/build2"

create_log_group "test:types"
if ! yarn test:types; then
echo "tsd failed! Exiting..."
exit ${PUBLISH_TYPE_AND_RESULT_DIR_BUT_ALWAYS_FAIL}
fi
finish_log_group $?

create_log_group "lint_report"
if ! yarn lint:report; then
# run `yarn lint` so the linting errors appear in the bacon logs
yarn lint
echo "lint failed! Exiting..."
exit ${PUBLISH_TYPE_AND_RESULT_DIR_BUT_ALWAYS_FAIL}
fi
finish_log_group $?

# TODO: fix types in @okta/test.app
# JIRA: https://oktainc.atlassian.net/browse/OKTA-529625
Expand All @@ -22,13 +28,15 @@ fi
# exit ${TEST_FAILURE}
# fi

create_log_group "verify:package"
mkdir -p ${TEST_RESULT_FILE_DIR}
if ! yarn verify:package 2> ${TEST_RESULT_FILE_DIR}/verify-package-error.log; then
echo "verify package failed! Exiting..."
value=`cat ${TEST_RESULT_FILE_DIR}/verify-package-error.log`
log_custom_message "Verification Failed" "${value}"
exit ${PUBLISH_TYPE_AND_RESULT_DIR_BUT_ALWAYS_FAIL}
fi
finish_log_group $?

echo ${TEST_SUITE_TYPE} > ${TEST_SUITE_TYPE_FILE}
echo ${TEST_RESULT_FILE_DIR} > ${TEST_RESULT_FILE_DIR_FILE}
Expand Down
11 changes: 11 additions & 0 deletions scripts/monolith/create-e2e-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -xe

# Creates a test org and outputs environment variables to a file named "testenv.local" in the project root

#yarn workspace @okta/test.support monolith:create-env
pushd ./test/support
yarn ts-node ./monolith/create-e2e-env.ts
popd

cat testenv.local >> testenv
echo "updated testenv"
23 changes: 23 additions & 0 deletions scripts/monolith/install-dockolith.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash -e

if [[ -z ${DOCKOLITH_BRANCH} ]]; then
export DOCKOLITH_BRANCH=master
fi

pushd ./scripts
rm -rf dockolith
echo "Cloning dockolith from branch: ${DOCKOLITH_BRANCH}"
git clone --depth 1 -b $DOCKOLITH_BRANCH https://github.com/okta/dockolith.git

# build dockolith target
pushd ./dockolith
yarn
yarn build
popd
popd

# Yarn "add" always modifies package.json https://github.com/yarnpkg/yarn/issues/1743
# Make a backup of package.json and restore it after install
cp package.json package.json.bak
yarn add -DW --no-lockfile file:./scripts/dockolith
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is where the build happens. Can add --ignore-scripts option to skip the build step

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding --ignore-scripts here prevents dockolith from building

mv package.json.bak package.json
48 changes: 48 additions & 0 deletions scripts/monolith/start-dockolith.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash -xe

if [ -z "${DOCKOLITH_CI}" ]; then # Local
# remove all running containers and networks before running
source ${DOCKOLITH_HOME}/scripts/smoke-docker.sh

# clear all tmp files
rm -rf ${DOCKOLITH_TMP}
fi

source ${DOCKOLITH_HOME}/scripts/lib/dockolith/setup-dockolith.sh

dockolith::setup;

create_log_group "Setup"
dockolith::setup;
finish_log_group $?

#Set the spring config profiles. this determines which config files are loaded
# http://localhost:8100/okta/ci,ci_test_shared_credentials
# web credentials for CCS in bootstrap-ci.properties
# special "widget" profile is used to load locally built widget version
export MONOLITH_PROFILES_ACTIVE="ci_test_shared_credentials,ci,widget"

create_log_group "Start Tomcat"
dockolith::start_tomcat;
finish_log_group $?

create_log_group "Verify Webapp"
export DOCKER_HOST_CONTAINER_IP=$(docker inspect --format='{{.NetworkSettings.Networks.monolith_network.IPAddress}}' mono_dockerhost)
update_hosts_entry $DOCKER_HOST_CONTAINER_IP cdn.okta1.com
update_hosts_entry $DOCKER_HOST_CONTAINER_IP rain.okta1.com
update_hosts_entry $DOCKER_HOST_CONTAINER_IP backdoorentry.okta1.com

curl http://backdoorentry.okta1.com:1802
finish_log_group $?


create_log_group "Bootstrap"
export METRIC_TO_LOG=bootstrap_db
if ! log_metric_wrapper dockolith::bootstrap;
then
echo "bootstrap failed!"
# move_logs_tmp_api
# log_extra_dir_as_zip ${TMP_LOGS_LOCATION} run_logs.zip
exit ${BUILD_FAILURE}
fi
finish_log_group $?
4 changes: 3 additions & 1 deletion scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash -xe
#!/bin/bash -ex

set +x # ignore generic installation logs from setup/yarn add @okta/ci*
source ${OKTA_HOME}/${REPO}/scripts/setup.sh

REGISTRY="${ARTIFACTORY_URL}/api/npm/npm-topic"
Expand All @@ -10,6 +11,7 @@ export TEST_SUITE_TYPE="build"
export PATH="${PATH}:$(yarn global bin)"
yarn global add @okta/ci-append-sha
yarn global add @okta/ci-pkginfo
set -x

if [ -n "${action_branch}" ];
then
Expand Down
156 changes: 156 additions & 0 deletions scripts/setup-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#!/bin/bash -e

DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
for f in $(ls $DIR/utils); do source $DIR/utils/$f; done

# if running on bacon
if [ -n "${TEST_SUITE_ID}" ]; then
# Add yarn to the $PATH so npm cli commands do not fail
export PATH="${PATH}:$(yarn global bin)"
# Install required node version
export NVM_DIR="/root/.nvm"

setup_service node "${1:-v14.18.0}"
# Use the cacert bundled with centos as okta root CA is self-signed and cause issues downloading from yarn
setup_service yarn 1.21.1 /etc/pki/tls/certs/ca-bundle.crt

else
# bacon defines OKTA_HOME and REPO, define these relative to this file
export OKTA_HOME=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd)
export REPO="."
export TEST_SUITE_TYPE_FILE=/dev/null
export TEST_RESULT_FILE_DIR_FILE=/dev/null

### (known) Bacon exit codes
# success
export SUCCESS=0
export PUBLISH_TYPE_AND_RESULT_DIR=0
export PUBLISH_TYPE_AND_RESULT_DIR_BUT_SUCCEED_IF_NO_RESULTS=0
# failure
export FAILURE=1
export FAILED_SETUP=1
export TEST_FAILURE=1
export PUBLISH_TYPE_AND_RESULT_DIR_BUT_ALWAYS_FAIL=1
export PUBLISH_ARTIFACTORY_FAILURE=1

# bacon commands
get_secret () {
# ensures the env var is set
if [ -z "$(echo "$2")" ]; then
echo "$2 is not defined. Exiting..."
exit 1
fi
}

get_vault_secret_key () {
get_secret $1 $3
}

junit () {
echo 'noop'
}

create_log_group () {
set +x
echo "~*~*~~*~*~ $1 ~*~*~~*~*~ "
set -x
}

finish_log_group () {
set +x
echo "~*~*~~*~*~ *~*~* ~*~*~~*~*~"
set -x
}

set -x # when running locally, might as well see all the commands being ran
fi

cd ${OKTA_HOME}/${REPO}

function artifactory_siw_install () {
REGISTRY="https://artifacts.aue1d.saasure.com/artifactory/npm-topic/@okta/okta-signin-widget/-/@okta"

ssl=$(npm config get strict-ssl)
npm config set strict-ssl false
pkg_uri="${REGISTRY}/okta-signin-widget-${WIDGET_VERSION}.tgz"
if ! yarn add -DW --force --ignore-scripts $pkg_uri &>/dev/null; then
echo "WIDGET_VERSION could not be installed via artifactory: ${WIDGET_VERSION}"
exit ${FAILED_SETUP}
fi
npm config set strict-ssl $ssl
echo $pkg_uri
}

function npm_siw_install () {
if ! yarn add -DW --force --ignore-scripts @okta/okta-signin-widget@${WIDGET_VERSION} ; then
echo "WIDGET_VERSION could not be installed via npm: ${WIDGET_VERSION}"
exit ${FAILED_SETUP}
fi
}

function verify_workspace_versions () {
PKG=$1

onError () {
echo "ADDITIONAL WIDGET INSTALL DETECTED (check $1)"
yarn why $PKG
exit ${FAILED_SETUP}
}

LOCAL_INSTALLS=$(find . -type d -path "*/node_modules/$PKG" | wc -l)
if [ $LOCAL_INSTALLS -gt 1 ]
then
onError 1
fi

# parses `yarn why` output to generate an json array of installed versions
INSTALLED_VERSIONS=$(yarn why --json $PKG | jq -r -s 'map(select(.type == "info") | select(.data | strings | contains("Found"))) | map(.data[11:-1]) | map(split("@")[-1]) | unique')

if [ $(echo $INSTALLED_VERSIONS | jq length) -ne 1 ]
then
onError 2
fi

if [ $(echo $INSTALLED_VERSIONS | jq .[0] | tr -d \" ) != $WIDGET_VERSION ]
then
onError 3
fi
}

function setup::install() {
# Install dependences. --ignore-scripts will prevent chromedriver from attempting to install
if ! yarn install --frozen-lockfile --ignore-scripts; then
echo "yarn install failed! Exiting..."
exit ${FAILED_SETUP}
fi

if [ ! -z "$WIDGET_VERSION" ]; then
echo "Installing WIDGET_VERSION: ${WIDGET_VERSION}"

SHA=$(echo $WIDGET_VERSION | cut -d "-" -f 2)
# cut -d "-" ran on '7.0.0' returns '7.0.0', ensure a SHA exists on the version string
if [ "$WIDGET_VERSION" = "$SHA" ]; then
# no sha found, install from npm
INSTALLED_VERSION=$(npm_siw_install)
else
# sha found, install from artifactory
INSTALLED_VERSION=$(artifactory_siw_install)
fi

install_beta_pkg @okta/okta-signin-widget "$INSTALLED_VERSION"

verify_workspace_versions @okta/okta-signin-widget
echo "WIDGET_VERSION installed: ${WIDGET_VERSION}"
fi
}

function setup::build() {
if [ -z "$SKIP_SETUP_BUILD" ]; then
if ! yarn build; then
echo "build failed! Exiting..."
exit ${TEST_FAILURE}
fi
else
echo '`SKIP_SETUP_BUILD` set, skipping build...'
fi
}
Loading