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

fix(perf.tests) Use mTLS to send custom metrics #3445

Merged
merged 2 commits into from
Jan 15, 2025
Merged
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
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -399,18 +399,21 @@ cf-login: ## Login to OSS CF dev environment
@${CI_DIR}/autoscaler/scripts/cf-login.sh

.PHONY: setup-performance
setup-performance: build-test-app acceptance-tests-config
setup-performance: build-test-app
export NODES=1;\
export SUITES="setup_performance";\
export DEPLOYMENT_NAME="autoscaler-performance";\
${CI_DIR}/autoscaler/scripts/run-acceptance-tests.sh;\
make acceptance-tests-config;\
make --directory='./src/acceptance' run-acceptance-tests

.PHONY: run-performance
run-performance:
export NODES=1;\
export DEPLOYMENT_NAME="autoscaler-performance";\
export SUITES="run_performance";\
${CI_DIR}/autoscaler/scripts/run-acceptance-tests.sh;\
make acceptance-tests-config;\
make --directory='./src/acceptance' run-acceptance-tests


.PHONY: run-act
run-act:
Expand Down
3 changes: 2 additions & 1 deletion ci/autoscaler/scripts/run-acceptance-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ then
exit 1;
fi

if [[ ! -f "${autoscaler_dir}/src/acceptance/acceptance_config.json" ]]
if [[ ! -f "${autoscaler_acceptance_dir}/acceptance_config.json" ]]
then
echo 'FAILED: Did not find file acceptance_config.json.'
exit 1
Expand All @@ -40,4 +40,5 @@ if [ "${suites_to_run}" != "" ]; then
SKIP_TEARDOWN="${skip_teardown}" CONFIG="${PWD}/acceptance_config.json" DEBUG='true' ./bin/test -race -nodes="${nodes}" -trace $ginkgo_opts ${suites_to_run}
else
log 'Nothing to run!'
exit 1
fi
10 changes: 9 additions & 1 deletion ci/autoscaler/scripts/vars.source.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# NOTE: to turn on debug use DEBUG=true
# shellcheck disable=SC2155,SC2034
#
Expand Down Expand Up @@ -83,6 +83,11 @@ export CI_DIR="$(realpath -e "${CI_DIR}")"
debug "CI_DIR: ${CI_DIR}"
ci_dir="${CI_DIR}"

AUTOSCALER_ACCEPTANCE_DIR="${AUTOSCALER_ACCEPTANCE_DIR:-${root_dir}/src/acceptance}"
export AUTOSCALER_ACCEPTANCE_DIR="$(realpath -e "${AUTOSCALER_ACCEPTANCE_DIR}" )"
debug "AUTOSCALER_ACCEPTANCE_DIR: ${AUTOSCALER_ACCEPTANCE_DIR}"
autoscaler_acceptance_dir="${AUTOSCALER_ACCEPTANCE_DIR}"

export SERVICE_NAME="${DEPLOYMENT_NAME}"
debug "SERVICE_NAME: ${SERVICE_NAME}"
service_name="%{SERVICE_NAME"
Expand All @@ -109,6 +114,9 @@ debug "PERFORMANCE_SETUP_WORKERS: ${PERFORMANCE_SETUP_WORKERS}"
export PERFORMANCE_TEARDOWN=${PERFORMANCE_TEARDOWN:-true}
debug "PERFORMANCE_TEARDOWN: ${PERFORMANCE_TEARDOWN}"

export PERFORMANCE_UPDATE_EXISTING_ORG_QUOTA=${PERFORMANCE_UPDATE_EXISTING_ORG_QUOTA:-false}
debug "PERFORMANCE_UPDATE_EXISTING_ORG_QUOTA: ${PERFORMANCE_UPDATE_EXISTING_ORG_QUOTA}"

export CPU_UPPER_THRESHOLD=${CPU_UPPER_THRESHOLD:-100}
debug "CPU_UPPER_THRESHOLD: ${CPU_UPPER_THRESHOLD}"
cpu_upper_threshold=${CPU_UPPER_THRESHOLD}
Expand Down
2 changes: 1 addition & 1 deletion devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"bundix": "latest",
"coreutils": "latest",
"delve": "latest",
"fly": "7.10.0",
"fly": "7.12.0",
"gh": "latest",
"gnumake": "4.4",
"gnutar": "latest",
Expand Down
24 changes: 12 additions & 12 deletions devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -505,51 +505,51 @@
}
}
},
"fly@7.10.0": {
"last_modified": "2023-10-25T20:49:13Z",
"resolved": "github:NixOS/nixpkgs/75a52265bda7fd25e06e3a67dee3f0354e73243c#fly",
"fly@7.12.0": {
"last_modified": "2024-12-23T21:10:33Z",
"resolved": "github:NixOS/nixpkgs/de1864217bfa9b5845f465e771e0ecb48b30e02d#fly",
"source": "devbox-search",
"version": "7.10.0",
"version": "7.12.0",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/8izh5mrp88vpv2p22r5djhg1l3yijcir-fly-7.10.0",
"path": "/nix/store/v42agkj44lkkczrijyrnab5pa7yh2bad-fly-7.12.0",
"default": true
}
],
"store_path": "/nix/store/8izh5mrp88vpv2p22r5djhg1l3yijcir-fly-7.10.0"
"store_path": "/nix/store/v42agkj44lkkczrijyrnab5pa7yh2bad-fly-7.12.0"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/bjhdz4zxq77av8rlvg32agpd8aixh7bh-fly-7.10.0",
"path": "/nix/store/bnzbalznggbacy0xbq1ya9qyp6rj7s3r-fly-7.12.0",
"default": true
}
],
"store_path": "/nix/store/bjhdz4zxq77av8rlvg32agpd8aixh7bh-fly-7.10.0"
"store_path": "/nix/store/bnzbalznggbacy0xbq1ya9qyp6rj7s3r-fly-7.12.0"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/60jgzhcj2s4rchrmqc479gi46fkydjyc-fly-7.10.0",
"path": "/nix/store/gzigrvd80bpmbj6ncqhpv0jrrrf4ls17-fly-7.12.0",
"default": true
}
],
"store_path": "/nix/store/60jgzhcj2s4rchrmqc479gi46fkydjyc-fly-7.10.0"
"store_path": "/nix/store/gzigrvd80bpmbj6ncqhpv0jrrrf4ls17-fly-7.12.0"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/ddyvlw35d8skg4r7gv732g19ch7bwrh0-fly-7.10.0",
"path": "/nix/store/5nw561vp6bbq945lnfajw0l42jdkycjn-fly-7.12.0",
"default": true
}
],
"store_path": "/nix/store/ddyvlw35d8skg4r7gv732g19ch7bwrh0-fly-7.10.0"
"store_path": "/nix/store/5nw561vp6bbq945lnfajw0l42jdkycjn-fly-7.12.0"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/acceptance/app/custom_metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var _ = Describe("AutoScaler custom metrics", func() {
func sendMetricToAutoscaler(config *config.Config, appToScaleGUID string, metricProducerAppName string, metricThreshold int, mtls bool) func() (int, error) {
return func() (int, error) {
if mtls {
SendMetricMTLS(config, appToScaleGUID, metricProducerAppName, metricThreshold)
SendMetricMTLS(config, appToScaleGUID, metricProducerAppName, metricThreshold, 0)
} else {
SendMetric(config, metricProducerAppName, metricThreshold)
}
Expand Down
8 changes: 6 additions & 2 deletions src/acceptance/helpers/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ func SendMetric(cfg *config.Config, appName string, metric int) {
cfh.CurlApp(cfg, appName, fmt.Sprintf("/custom-metrics/test_metric/%d", metric), "-f")
}

func SendMetricMTLS(cfg *config.Config, appGuid string, appName string, metric int) {
func SendMetricMTLS(cfg *config.Config, appGuid string, appName string, metric int, timeOut time.Duration) string {
GinkgoHelper()
cfh.CurlApp(cfg, appName, fmt.Sprintf("/custom-metrics/mtls/test_metric/%d?appToScaleGuid=%s", metric, appGuid), "-f")
if timeOut == 0 {
timeOut = cfh.CURL_TIMEOUT
}
return cfh.CurlAppWithTimeout(cfg, appName, fmt.Sprintf("/custom-metrics/mtls/test_metric/%d?appToScaleGuid=%s",
metric, appGuid), timeOut, "-f")
}

func StartAppWithErr(appName string, timeout time.Duration) error {
Expand Down
4 changes: 2 additions & 2 deletions src/acceptance/run_performance/run_performance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func scaleOutApp(appName string, appGUID string, scaleOutApps *sync.Map,
// Q. why sending post request to autoscaler after every pollTime.
// A. It is observed that sometime cf does not pick the cf scale event. Therefore,
// sending the metric again(and again) is the way to go at the moment
cmdOutput := helpers.SendMetricWithTimeout(cfg, appName, 550, 5*time.Minute)
cmdOutput := helpers.SendMetricMTLS(cfg, appGUID, appName, 550, 5*time.Minute)
GinkgoWriter.Printf("worker %d - scale-out %s with App %s %s\n",
workerIndex, cmdOutput, appName, appGUID)
instances, err := helpers.RunningInstances(appGUID, 10*time.Minute)
Expand Down Expand Up @@ -354,7 +354,7 @@ func scaleInApp(appName string, appGUID string, scaleInApps *sync.Map, pendingSc
scaledInAppsCount *atomic.Int32, actualAppsToScaleCount int, workerIndex int, wg *sync.WaitGroup) func() {
return func() {
scaleIn := func() (int, error) {
cmdOutput := helpers.SendMetricWithTimeout(cfg, appName, 100, 5*time.Minute)
cmdOutput := helpers.SendMetricMTLS(cfg, appGUID, appName, 100, 5*time.Minute)
GinkgoWriter.Printf("worker %d - scale-in %s with App %s %s\n",
workerIndex, cmdOutput, appName, appGUID)
instances, err := helpers.RunningInstances(appGUID, 10*time.Minute)
Expand Down
Loading