Skip to content

Commit

Permalink
Moving pipelines to shepherd (#869)
Browse files Browse the repository at this point in the history
  • Loading branch information
Albertoimpl authored and spikymonkey committed Oct 3, 2023
1 parent 9fcb0f6 commit 0fb6499
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 48 deletions.
28 changes: 19 additions & 9 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
[*]
charset=utf-8
end_of_line=lf
insert_final_newline=true
indent_style=tab
indent_size=4
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4

[*.{yml,yaml,sh}]
indent_style=space
indent_size=2
[{*.yml,*.yaml}]
indent_style = space
indent_size = 2
ij_yaml_keep_indents_on_empty_lines = false
ij_yaml_keep_line_breaks = true

[*.sh]
indent_size = 2
indent_style = space

[{.asciidoctorconfig,*.ad,*.adoc,*.asciidoc}]
ij_asciidoc_formatting_enabled = true
ij_asciidoc_one_sentence_per_line = true

[*.java]
ij_java_class_count_to_use_import_on_demand = 100
ij_java_imports_layout = jakarta.**,|,java.**,|,*,|,org.springframework.**,|,$*
ij_java_imports_layout = jakarta.**, |, java.**, |, *, |, org.springframework.**, |, $*
ij_java_names_count_to_use_import_on_demand = 100
61 changes: 28 additions & 33 deletions ci/scripts/acceptance-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,38 @@

set -euo pipefail

readonly TOOLSMITH_ENV_INPUT="${TOOLSMITH_ENV_INPUT:?must be set}"
readonly DEFAULT_ORG="${DEFAULT_ORG:?must be set}"
readonly DEFAULT_SPACE="${DEFAULT_SPACE:?must be set}"
readonly SKIP_SSL_VALIDATION="${SKIP_SSL_VALIDATION:?must be set}"
readonly ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE:-true}"
readonly DEPLOYMENT_DIRECTORY="$(mktemp -d)"

declare API_HOST
readonly API_PORT=443
readonly USERNAME="admin"
declare PASSWORD
readonly METADATA_FILE="${METADATA_FILE:?must be set}"

declare CF_API_HOST
readonly CF_USERNAME="admin"
declare CF_PASSWORD

readonly CLIENT_ID="admin"
declare CLIENT_SECRET

readonly DEFAULT_ORG="test"
readonly DEFAULT_SPACE="development"

DEPLOYMENT_DIRECTORY="$(mktemp -d)"
readonly DEPLOYMENT_DIRECTORY

discover_environment() {
local env_name
env_name=$(cat "$TOOLSMITH_ENV_INPUT/name")
env_name=$(jq -r .name <"${METADATA_FILE}")

eval "$(bbl print-env --metadata-file "$TOOLSMITH_ENV_INPUT/metadata")"
eval "$(bbl print-env --metadata-file "${METADATA_FILE}")"

API_HOST="$(jq -r .cf.api_url <"$TOOLSMITH_ENV_INPUT/metadata")"
PASSWORD="$(credhub get -n "/bosh-${env_name}/cf/cf_admin_password" -q)"
CF_API_HOST="$(jq -r .cf.api_url <"${METADATA_FILE}")"
CF_PASSWORD="$(credhub get -n "/bosh-${env_name}/cf/cf_admin_password" -q)"
CLIENT_SECRET="$(credhub get -n "/bosh-${env_name}/cf/uaa_admin_client_secret" -q)"
}

prepare_cf_deployment() {
pushd "$DEPLOYMENT_DIRECTORY" > /dev/null
pushd "$DEPLOYMENT_DIRECTORY" >/dev/null

bosh --deployment cf manifest > manifest.yml
bosh --deployment cf manifest >manifest.yml

cat << EOF > ops.yml
cat <<EOF >ops.yml
- type: replace
path: /instance_groups/name=diego-cell/vm_type
value: large
Expand All @@ -46,18 +47,13 @@ EOF

bosh --non-interactive --deployment cf deploy --ops-file ops.yml manifest.yml

popd > /dev/null
popd >/dev/null
}

prepare_cf() {
local -r test_instances_org="$DEFAULT_ORG-instances"

local skip_ssl_validation=""
if [ "$SKIP_SSL_VALIDATION" = "true" ]; then
skip_ssl_validation="--skip-ssl-validation"
fi

cf login -a "$API_HOST" -u "$USERNAME" -p "$PASSWORD" -o system "$skip_ssl_validation"
cf login -a "$CF_API_HOST" -u "$CF_USERNAME" -p "$CF_PASSWORD" -o system --skip-ssl-validation

cf create-org "$DEFAULT_ORG"
cf create-space "$DEFAULT_SPACE" -o "$DEFAULT_ORG"
Expand All @@ -67,27 +63,26 @@ prepare_cf() {
}

run_tests() {
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_API_HOST="${API_HOST}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_API_PORT="${API_PORT}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_USERNAME="${USERNAME}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_PASSWORD="${PASSWORD}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_API_HOST="${CF_API_HOST}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_API_PORT=443
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_USERNAME="${CF_USERNAME}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_PASSWORD="${CF_PASSWORD}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_CLIENT_ID="${CLIENT_ID}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_CLIENT_SECRET="${CLIENT_SECRET}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_DEFAULT_ORG="${DEFAULT_ORG}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_DEFAULT_SPACE="${DEFAULT_SPACE}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_SKIP_SSL_VALIDATION="${SKIP_SSL_VALIDATION}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_SKIP_SSL_VALIDATION=true
export TESTS_BROKERAPPPATH=build/libs/spring-cloud-app-broker-acceptance-tests.jar
./gradlew -PacceptanceTests \
-PonlyShowStandardStreamsOnTestFailure="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE}" \
-PonlyShowStandardStreamsOnTestFailure=true \
:spring-cloud-app-broker-acceptance-tests:test
}

main() {
discover_environment

echo "Running tests against $API_HOST"
echo "Running tests against ${CF_API_HOST}"
echo

prepare_cf_deployment
prepare_cf

Expand Down
8 changes: 2 additions & 6 deletions ci/tasks/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ image_resource:
tag: ((ci-image-tag))
inputs:
- name: git-repo
- name: toolsmith-env
- name: cf-environment
run:
path: ci/scripts/acceptance-tests.sh
dir: git-repo
params:
TOOLSMITH_ENV_INPUT: ../toolsmith-env
DEFAULT_ORG: ((acceptance-test-default-org))
DEFAULT_SPACE: ((acceptance-test-default-space))
SKIP_SSL_VALIDATION: ((acceptance-test-skip-ssl-validation))
ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE: true
METADATA_FILE: ../cf-environment/metadata
87 changes: 87 additions & 0 deletions scripts/acceptance-tests-ide.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env bash

set -euo pipefail

readonly METADATA_FILE="${METADATA_FILE:?must be set}"

declare CF_API_HOST
readonly CF_USERNAME="admin"
declare CF_PASSWORD

readonly CLIENT_ID="admin"
declare CLIENT_SECRET

readonly DEFAULT_ORG="test"
readonly DEFAULT_SPACE="development"

DEPLOYMENT_DIRECTORY="$(mktemp -d)"
readonly DEPLOYMENT_DIRECTORY

discover_environment() {
local env_name
env_name=$(jq -r .name <"${METADATA_FILE}")

eval "$(bbl print-env --metadata-file "${METADATA_FILE}")"

CF_API_HOST="$(jq -r .cf.api_url <"${METADATA_FILE}")"
CF_PASSWORD="$(credhub get -n "/bosh-${env_name}/cf/cf_admin_password" -q)"
CLIENT_SECRET="$(credhub get -n "/bosh-${env_name}/cf/uaa_admin_client_secret" -q)"
}

prepare_cf_deployment() {
pushd "$DEPLOYMENT_DIRECTORY" >/dev/null

bosh --deployment cf manifest >manifest.yml

cat <<EOF >ops.yml
- type: replace
path: /instance_groups/name=diego-cell/vm_type
value: large
- type: replace
path: /instance_groups/name=router/vm_type
value: large
- type: replace
path: /instance_groups/name=api/vm_type
value: large
EOF

bosh --non-interactive --deployment cf deploy --ops-file ops.yml manifest.yml

popd >/dev/null
}

prepare_cf() {
local -r test_instances_org="$DEFAULT_ORG-instances"

cf login -a "$CF_API_HOST" -u "$CF_USERNAME" -p "$CF_PASSWORD" -o system --skip-ssl-validation

cf create-org "$DEFAULT_ORG"
cf create-space "$DEFAULT_SPACE" -o "$DEFAULT_ORG"

cf create-org "$test_instances_org"
cf create-space "$DEFAULT_SPACE" -o "$test_instances_org"
}

print_values() {
cat <<EOF
SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_API_HOST=${CF_API_HOST}
SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_API_PORT=443
SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_USERNAME=${CF_USERNAME}
SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_PASSWORD=${CF_PASSWORD}
SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_CLIENT_ID=${CLIENT_ID}
SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_CLIENT_SECRET=${CLIENT_SECRET}
SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_DEFAULT_ORG=${DEFAULT_ORG}
SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_DEFAULT_SPACE=${DEFAULT_SPACE}
SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_SKIP_SSL_VALIDATION=true
TESTS_BROKERAPPPATH=build/libs/spring-cloud-app-broker-acceptance-tests.jar
EOF
}

main() {
discover_environment
prepare_cf_deployment
prepare_cf
print_values
}

main

0 comments on commit 0fb6499

Please sign in to comment.