Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ config/settings.yml
releases/*.tgz
releases/**/*.tgz
ci/scripts/stemcell/*.tgz
ci/scripts/stemcell-bionic/*.tgz
ci/scripts/stemcell-jammy/*.tgz
dev_releases
blobs/*
.blobs
Expand Down
7 changes: 0 additions & 7 deletions acceptance-tests/acceptance_tests_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,3 @@ func checkNetOpErr(err error, expectString string) {
Expect(errors.As(tlsErr, &opErr)).To(BeTrue())
Expect(opErr.Err.Error()).To(ContainSubstring(expectString))
}

func writeLog(s string) {
ginkgoConfig, _ := GinkgoConfiguration()
for _, line := range strings.Split(s, "\n") {
fmt.Printf("node %d/%d: %s\n", ginkgoConfig.ParallelProcess, ginkgoConfig.ParallelTotal, line)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ import (
. "github.com/onsi/ginkgo/v2"
)

var _ = Describe("Bionic", func() {
It("Correctly proxies HTTP requests when using the Bionic stemcell", func() {
var _ = Describe("Jammy", func() {
It("Correctly proxies HTTP requests when using the Jammy stemcell", func() {

opsfileBionic := `---
# Configure Bionic stemcell
opsfileJammy := `---
# Configure Jammy stemcell
- type: replace
path: /stemcells/alias=default/os
value: ubuntu-bionic
value: ubuntu-jammy
`

haproxyBackendPort := 12000
haproxyInfo, _ := deployHAProxy(baseManifestVars{
haproxyBackendPort: haproxyBackendPort,
haproxyBackendServers: []string{"127.0.0.1"},
deploymentName: deploymentNameForTestNode(),
}, []string{opsfileBionic}, map[string]interface{}{}, true)
}, []string{opsfileJammy}, map[string]interface{}{}, true)

closeLocalServer, localPort := startDefaultTestServer()
defer closeLocalServer()
Expand Down
15 changes: 15 additions & 0 deletions acceptance-tests/log_helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package acceptance_tests

import (
"fmt"
"strings"

. "github.com/onsi/ginkgo/v2"
)

func writeLog(s string) {
ginkgoConfig, _ := GinkgoConfiguration()
for _, line := range strings.Split(s, "\n") {
fmt.Printf("node %d/%d: %s\n", ginkgoConfig.ParallelProcess, ginkgoConfig.ParallelTotal, line)
}
}
63 changes: 41 additions & 22 deletions acceptance-tests/run-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@
set -eu
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
source "${REPO_DIR}/ci/scripts/functions-ci.sh"
FOCUS=""
PARALLELISM=""
KEEP_RUNNING=""

usage() {
echo -e "Usage: $0 [-F <ginkgo focus target>] [-k]
echo -e "Usage: $0 [-F <ginkgo focus target>] [-P <ginkgo nodes>] [-k]

-F Focus on a particular test. Expects a Ginkgo test name. Keep bosh running afterwards.
-P Set Ginkgo parallel node count. Default is '-p' (smart parallelism).
-k Keep bosh container running. Useful for debug." 1>&2; exit 1;
}

while getopts ":F:k" o; do
while getopts ":F:P:k" o; do
case "${o}" in
F)
FOCUS=${OPTARG}
KEEP_RUNNING=true
;;
P)
PARALLELISM=${OPTARG}
;;
k)
KEEP_RUNNING=true
;;
Expand All @@ -35,7 +41,7 @@ docker_mac_check_cgroupsv1() {
SETTINGS=~/Library/Group\ Containers/group.com.docker/settings.json

cgroupsV1Enabled=$(jq '.deprecatedCgroupv1' "$SETTINGS")
if [ "$cgroupsV1Enabled" != "true" ]; then
if [ "$cgroupsV1Enabled" != "true" ]; then
echo "deprecatedCgroupv1 should be enabled in $SETTINGS. Otherwise the acceptance tests will not run on Docker for Mac."
echo "Check in the README.md for a convenient script to set deprecatedCgroupv1 and restart Docker."
exit 1
Expand All @@ -45,37 +51,50 @@ docker_mac_check_cgroupsv1() {
check_required_files() {
PIDS=""
REQUIRED_FILE_PATTERNS=(
ci/scripts/stemcell/bosh-stemcell-*-ubuntu-jammy-*.tgz!https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-jammy-go_agent
ci/scripts/stemcell-bionic/bosh-stemcell-*-ubuntu-bionic-*.tgz!https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-bionic-go_agent
ci/scripts/stemcell/bosh-stemcell-*-ubuntu-noble.tgz!https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-noble
ci/scripts/stemcell-jammy/bosh-stemcell-*-ubuntu-jammy-*.tgz!https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-jammy-go_agent
)

for entry in "${REQUIRED_FILE_PATTERNS[@]}"; do
pattern=$(cut -f1 -d! <<<"$entry")
url=$(cut -f2 -d! <<<"$entry")
folder=$(realpath "$(dirname "$REPO_DIR/$pattern")")
filepattern=$(basename "$pattern")
pattern=$folder/$filepattern

# shellcheck disable=SC2086
# glob resolution is desired here.
if [ -f $pattern ]; then
continue
fi

(
echo "$filepattern not found, downloading latest."
cd "$folder" && \
resolved=$(curl -s --write-out '\n%{redirect_url}' "$url" | tail -n1) && \
curl -s --remote-name --remote-header-name --location "$resolved" && \
echo "Downloaded '$url' successfully." && \
ls -1lh "$folder/"$filepattern
# Resolve the redirect URL to get the actual remote filename
resolved=$(curl -s --write-out '\n%{redirect_url}' "$url" | tail -n1 | tr -d '\n')
if [ -z "${resolved}" ]; then
echo "ERROR: could not resolve redirect URL for $url" >&2
exit 1
fi
remote_filename=$(basename "${resolved%%\?*}") # strip query string if any
echo "Remote file: ${remote_filename}" >&2

# Check what is already in the folder
existing=$(find "${folder}" -maxdepth 1 -name "${filepattern}" 2>/dev/null | head -1)

if [ -n "${existing}" ]; then
existing_filename=$(basename "${existing}")
if [ "${existing_filename}" = "${remote_filename}" ]; then
echo "${existing_filename} is up to date, skipping download." >&2
exit 0
fi
echo "Version changed: ${existing_filename} -> ${remote_filename}, deleting old file." >&2
rm -f "${existing}"
fi

echo "Downloading ${remote_filename} ..." >&2
cd "${folder}" && \
curl -s --remote-name --remote-header-name --location "${resolved}" && \
echo "Downloaded '${remote_filename}' successfully." >&2 && \
ls -1lh "${folder}/${remote_filename}" >&2
)&

PIDS="$PIDS $!"

done

# shellcheck disable=SC2086
# expansion is desired, as $PIDS is a list of PIDs. Wait on all of those PIDs.
wait $PIDS
}

Expand All @@ -93,9 +112,9 @@ if [ -n "$KEEP_RUNNING" ] ; then
echo
echo "*** KEEP_RUNNING enabled. Please clean up docker scratch after removing containers: ${DOCKER_SCRATCH}"
echo
docker run --privileged -v "$REPO_DIR":/repo -v "${DOCKER_SCRATCH}":/scratch/docker -e REPO_ROOT=/repo -e FOCUS="$FOCUS" -e KEEP_RUNNING="${KEEP_RUNNING}" haproxy-boshrelease-testflight bash -c "cd /repo/ci/scripts && ./acceptance-tests ; sleep infinity"
docker run --privileged -v "$REPO_DIR":/repo -v "${DOCKER_SCRATCH}":/scratch/docker -e REPO_ROOT=/repo -e FOCUS="${FOCUS}" -e PARALLELISM="${PARALLELISM}" -e KEEP_RUNNING="${KEEP_RUNNING}" haproxy-boshrelease-testflight bash -c "cd /repo/ci/scripts && ./acceptance-tests ; sleep infinity"
else
docker run --rm --privileged -v "$REPO_DIR":/repo -v "${DOCKER_SCRATCH}":/scratch/docker -e REPO_ROOT=/repo -e KEEP_RUNNING="" haproxy-boshrelease-testflight bash -c "cd /repo/ci/scripts && ./acceptance-tests"
docker run --rm --privileged -v "$REPO_DIR":/repo -v "${DOCKER_SCRATCH}":/scratch/docker -e REPO_ROOT=/repo -e KEEP_RUNNING="" -e PARALLELISM="${PARALLELISM}" haproxy-boshrelease-testflight bash -c "cd /repo/ci/scripts && ./acceptance-tests"
echo "Cleaning up docker scratch: ${DOCKER_SCRATCH}"
sudo rm -rf "${DOCKER_SCRATCH}"
fi
16 changes: 13 additions & 3 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
FROM bosh/docker-cpi:main
FROM ghcr.io/cloudfoundry/bosh/docker-cpi:latest

# Install all necessary tools for haproxy testflight and dependency autobump
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y wget jq git vim nano python3-pip && \
apt-get install -y wget jq git vim nano python3-pip python3-venv && \
apt-get clean

# Set bosh env at login
RUN echo "source /tmp/local-bosh/director/docker-env" >> /root/.bashrc
RUN echo "source /tmp/local-bosh/director/env" >> /root/.bashrc

RUN mkdir -p /usr/local/bosh-deployment/haproxy-boshrelease

# Copy ops files
COPY ops/bosh-scaled-out.yml /usr/local/bosh-deployment/haproxy-boshrelease/bosh-scaled-out.yml
COPY ops/bosh-timeouts.yml /usr/local/bosh-deployment/haproxy-boshrelease/bosh-timeouts.yml
COPY ops/compilation.yml /usr/local/bosh-deployment/haproxy-boshrelease/compilation.yml

# Install Python libraries needed for scripts
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:${PATH}"
COPY scripts/requirements.txt /requirements.txt
RUN /usr/bin/python3 -m pip install -r /requirements.txt
RUN pip install -r /requirements.txt

# Install go dependencies
ENV GOBIN=/usr/local/bin
Expand Down
3 changes: 3 additions & 0 deletions ci/ops/bosh-scaled-out.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- type: replace
path: /instance_groups/name=bosh/properties/director/workers?
value: 12
3 changes: 3 additions & 0 deletions ci/ops/bosh-timeouts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- type: replace
path: /instance_groups/name=bosh/properties/director/db/connection_wait_timeout?
value: 60
File renamed without changes.
20 changes: 11 additions & 9 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,23 @@ jobs:
- in_parallel:
- { get: git, trigger: true, passed: [unit-tests] }
- { get: stemcell }
- { get: stemcell-bionic }
- { get: stemcell-jammy }
- get: haproxy-boshrelease-testflight
- task: acceptance-tests
privileged: true
timeout: 4h
image: haproxy-boshrelease-testflight
config:
platform: linux
inputs:
- { name: git }
- { name: stemcell }
- { name: stemcell-bionic }
- { name: stemcell-jammy }
run:
path: ./git/ci/scripts/acceptance-tests
args: []
params:
REPO_ROOT: git
on_failure:
put: notify
params:
channel: "#haproxy-boshrelease"
Expand All @@ -152,7 +152,7 @@ jobs:
- do:
- { get: git-pull-requests, trigger: true, version: every }
- { get: stemcell }
- { get: stemcell-bionic }
- { get: stemcell-jammy }
- get: haproxy-boshrelease-testflight
- put: git-pull-requests
params:
Expand All @@ -163,13 +163,14 @@ jobs:
list_changed_files: true
- task: acceptance-tests
privileged: true
timeout: 4h
image: haproxy-boshrelease-testflight
config:
platform: linux
inputs:
- { name: git-pull-requests }
- { name: stemcell }
- { name: stemcell-bionic }
- { name: stemcell-jammy }
run:
path: ./git-pull-requests/ci/scripts/acceptance-tests
args: []
Expand Down Expand Up @@ -403,15 +404,15 @@ resources:
- "dependabot"
- "CFN-CI"

- name: stemcell-bionic
- name: stemcell-jammy
type: bosh-io-stemcell
source:
name: bosh-warden-boshlite-ubuntu-bionic-go_agent
name: bosh-warden-boshlite-ubuntu-jammy-go_agent

- name: stemcell
type: bosh-io-stemcell
source:
name: bosh-warden-boshlite-ubuntu-jammy-go_agent
name: bosh-warden-boshlite-ubuntu-noble

- name: version
type: semver
Expand Down Expand Up @@ -453,7 +454,7 @@ resources:
- name: docker-cpi-image
type: docker-image
source:
repository: bosh/docker-cpi
repository: ghcr.io/cloudfoundry/bosh/docker-cpi

- name: git-ci
type: git
Expand All @@ -463,6 +464,7 @@ resources:
paths:
- ci/Dockerfile
- ci/scripts/requirements.txt
- ci/ops/

- name: haproxy-boshrelease-testflight
type: docker-image
Expand Down
35 changes: 31 additions & 4 deletions ci/scripts/acceptance-tests
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,38 @@ echo "----- Running tests"
export PATH=$PATH:$GOPATH/bin
ginkgo version

PARALLELISM="-p"
if [ -n "$FOCUS" ]; then
echo "------------------------------------------------------------------"
if [ -n "${FOCUS:-}" ]; then
PARALLELISM="--nodes=1"
echo "FOCUS is set, thus PARALLELISM is set to '$PARALLELISM'"
elif [ -n "${PARALLELISM:-}" ]; then
PARALLELISM="--nodes=$PARALLELISM"
echo "PARALLELISM is set. Will run ginkgo with '$PARALLELISM'"
else
PARALLELISM="-p"
echo "PARALLELISM is not set. Using default '$PARALLELISM'"
fi
echo "------------------------------------------------------------------"

echo "------------------------------------------------------------------"
if [ "${VERBOSITY:-}" = "vv" ]; then
VERBOSITY_FLAG="-vv"
echo "VERBOSITY is set to 'vv'. Will run ginkgo with '$VERBOSITY_FLAG'"
else
VERBOSITY_FLAG="-v"
echo "VERBOSITY is not set or unrecognised. Using default '$VERBOSITY_FLAG'"
fi
echo "------------------------------------------------------------------"

echo "------------------------------------------------------------------"
if [ -n "${FLAKE_ATTEMPTS:-}" ]; then
echo "FLAKE_ATTEMPTS is set. Will run ginkgo with '--flake-attempts=$FLAKE_ATTEMPTS'"
else
FLAKE_ATTEMPTS=5
echo "FLAKE_ATTEMPTS is not set. Using default '$FLAKE_ATTEMPTS'"
fi
echo "------------------------------------------------------------------"

ginkgo -v "$PARALLELISM" -r --trace --show-node-events --randomize-all --flake-attempts 5 "${ADDITIONAL_ARGS[@]}"
ginkgo "$VERBOSITY_FLAG" "$PARALLELISM" -r --trace --show-node-events --randomize-all --flake-attempts "$FLAKE_ATTEMPTS" "${ADDITIONAL_ARGS[@]}"

keep_running_info
keep_running_info
14 changes: 7 additions & 7 deletions ci/scripts/functions-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ function bosh_release() {
}

function bosh_assets() {
stemcell_jammy_path="$START_DIR/stemcell/*.tgz"
stemcell_bionic_path="$START_DIR/stemcell-bionic/*.tgz"
stemcell_noble_path="$START_DIR/stemcell/*.tgz"
stemcell_jammy_path="$START_DIR/stemcell-jammy/*.tgz"

echo "----- Uploading Noble stemcell"
bosh -n upload-stemcell $stemcell_noble_path

echo "----- Uploading Jammy stemcell"
bosh -n upload-stemcell $stemcell_jammy_path

echo "----- Uploading Bionic stemcell"
bosh -n upload-stemcell $stemcell_bionic_path

echo "----- Uploading os-conf (used for tests only)"
bosh -n upload-release --sha1 386293038ae3d00813eaa475b4acf63f8da226ef \
https://bosh.io/d/github.com/cloudfoundry/os-conf-release?v=22.1.2
bosh -n upload-release --sha1 sha256:efcf30754ce4c5f308aedab3329d8d679f5967b2a4c3c453204c7cb10c7c5ed9 \
https://bosh.io/d/github.com/cloudfoundry/os-conf-release?v=23.0.0

export BOSH_PATH=$(command -v bosh)
export BASE_MANIFEST_PATH="$PWD/manifests/haproxy.yml"
Expand Down
Loading