Skip to content

Commit c815613

Browse files
bonzofenixapp-autoscaler-ci-botrenovate[bot]geigerj0silvestre
authored
Add HTTP/XFCCAuth endpoint in the scheduler component (#3437)
* Adds cf_Server config for scalingengine Adds xfcc cf endpoint support to scaling engine Remove debug println WIP wip Fix warning Initial implementation of CF ServeR Add .trunk to .gitignore for Devbox configuration. Add .trunk to .gitignore for Devbox configuration. * Refactor configuration keys and update tests for cfServer in scheduler component * Update CFServerConfiguration property prefix to camelCase * Refactor configuration property names and update scheduler YAML - Rename cfServer to cf-server in configuration properties - Add launch.json for VSCode Java debugging setup - Remove destroyMethod annotation from CFServerConfig bean - Update application.yml to reflect new property names for cf-server * Remove validOrgGuid validation and refactor property names in application.yml * Updated VSCode settings and added HTTP configuration for scheduler • Changed VSCode Java build configuration setting from automatic to interactive • Added new CFHTTPConfiguration class to configure additional Tomcat connector for HTTP on port 8090 • Set server port to 8083 and added HTTP port configuration in application.yml * WIP: Integration test for api - scheduler cf http server endpoint * Add gorouter CA and client certificate generation to test scripts; update gorouterproxy to handle TLS and XFCC header; extend testhelpers with localhost SANs in certs. * Refactor XFCCAuthMiddleware and improve error handling • Implement NewXfccAuthMiddleware constructor for initializing middleware • Add XFCCAuthenticationMiddleware method to handle authentication within middleware • Enhance checkAuth method to include XFCC header parsing and certificate validation • Introduce parseXFCCHeader utility method for extracting attributes from XFCC header • Add getSpaceGuid and getOrgGuid methods to extract GUIDs from certificate • Optimize mapFrom method for parsing organizational units from certificates * Refactor XFCC auth middleware and update gorouterproxy tests • Extract CheckAuth function from xfccAuthMiddleware for standalone use with org and space parameters. • Replace instance method calls with standalone function calls in auth checks. • Update gorouterproxy tests to use the new CheckAuth function and pass org and space GUIDs directly. • Remove debug logging from mapFrom function. * Remove cf_server.port configuration from scheduler spec * Exclude 'vendor' and 'integration' directories from binaries search in Makefile * Fix function parameter and update GoRouterProxy command arguments - Correct the missing type for the `portToForward` parameter in `GoRouterProxy` function. - Update command arguments to include `--port` and `--forwardTo` flags in `GoRouterProxy`. - Add `GoRouterProxy` port to the `PreparePorts` function. - Prefix a test with `FWhen` to focus on a specific scheduler test. * Add build-gorouterproxy target and update tests for gorouterproxy - Introduce a new Makefile target `build-gorouterproxy` to compile the gorouterproxy component. - Mark `testsuite` as a PHONY target in the Makefile. - Update gorouterproxy tests to check for the new startup log message. - Add TLS certificate and key file flags to gorouterproxy and update the main function to use provided paths if available. - Include additional configuration for the Golang API server in the integration tests. - Implement AfterEach cleanup for stopping the Golang API server and gorouterproxy in integration tests. - Add GoRouterProxy to the list of compiled executables in the integration suite setup. - Allocate a new port for GolangAPICFServer in the integration test suite. * Increase max_connections to 1000 for PostgreSQL in Makefile * Enhance Makefile to pass GINKGO_OPTS in test-autoscaler-suite and run Postgres container detached with corrected max_connections config * WIP: Add SchedulerCFServer component and refactor integration tests - Introduce SchedulerCFServer component to handle CF server connections - Update integration tests to use temporary directories and URLs - Remove CFHTTPConfiguration class and adjust application.yml for scheduler - Refactor integration test code for clarity and consistency * chore: remove self-hosted image input and add devbox installation steps * 🤖🦾🛠️ scripts/asdf2devbox.py * Add build-gorouterproxy target to Makefile and include in build-all target * chore(deps): update github/codeql-action digest to 17a820b (#3471) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update google.golang.org/genproto digest to 29210b9 (#3472) * chore(deps): update google.golang.org/genproto digest to 29210b9 * 🤖🦾🛠️ go mod tidy & make package-specs --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update ghcr.io/cloudfoundry/app-autoscaler-release-tools:main docker digest to a850ee8 (#3470) * chore(deps): update ghcr.io/cloudfoundry/app-autoscaler-release-tools:main docker digest to a850ee8 * trigger new ci run --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: geigerj0 <[email protected]> * Refactor Golang API server test configuration and remove hardcoded paths • Extract default API server configuration into defaultGolangAPITestConfig function • Remove hardcoded file paths for API info, schema validation, and service catalog • Simplify PrepareGolangApiServerConfig by using the new default config function • Clean up commented-out password hash code and other unused variables • Update configuration structure to match new defaults and remove unnecessary URI settings * Refactor Golang API server configuration and tests • Refactor defaultGolangAPITestConfig to DefaultGolangAPITestConfig and add dbURI parameter. • Include Port in Server and BrokerServer configurations within DefaultGolangAPITestConfig. • Add Db and MetricsForwarder configurations to DefaultGolangAPITestConfig. • Simplify PrepareGolangApiServerConfig by removing explicit port parameters and using DefaultGolangAPITestConfig. • Rename writeYmlConfig to WriteYmlConfig and update its usages across test files. • Update test setup functions to reflect changes in configuration functions. • Remove redundant port and metrics forwarder URL parameters from test configurations. * feat: replace` swagger-cli` with `redocly` for OpenAPI validation # Issue Redocly CLI is the recommended replacement for the deprecated swagger-cli package # Fix See https://redocly.com/docs/cli/guides/migrate-from-swagger-cli * Update GitHub Actions workflow and Devbox configuration for Java linting - Remove container usage from the code-style job in GitHub Actions workflow - Add steps to install Devbox and make its shell environment available - Resolve merge conflict in devbox.json by including google-java-format - Add google-java-format to devbox.lock with support for multiple architectures - Create new Makefile in src/scheduler for Java formatting and checking * Remove echo statement from check-format target in scheduler Makefile * Fix go linting * Fix more linting errors * Add scheduler's HTTP port configuration and update references in templates and specs * Update scheduler port descriptions in spec to distinguish between HTTPS and HTTP ports * Update GoRouterProxy command initialization and add cfserver config to scheduler template * Simplify Java CI lint workflow by using container and removing devbox setup * Update GitHub Actions and dependencies - Update devbox-install-action to v0.12.0 across workflows - Update CodeQL actions to latest version - Add devbox installation step to java-ci-lint workflow - Upgrade loggregator-agent-release and tlsconfig in go.mod - Bump chi, ginkgo, gomega, grpc, and grpc-gateway versions - Update indirect dependencies in go.sum * Add makefile start scheduler task * Small fix on gorouter proxy * Add .DS_Store to .gitignore to exclude macOS folder metadata files * Add removal of scheduler target directory in clean-scheduler make target * Uses ginkgo from devbox for autoscaler tasks * Update Makefile to include build-gorouterproxy in integration target * Refactor VCAP configuration reader to remove error handling • Simplify NewVCAPConfigurationReader by removing error return value • Update calls to NewVCAPConfigurationReader to handle the new function signature without error checking • Adjust error message in NewVCAPConfigurationReader to include the error details when failing to read VCAP environment variables * Add JSON encoding support and fix public API server config retrieval in autoscaler API config * Add Scheduler TLS configuration setup in API config loading * Refactors GetDbVcapServices into testhelpers for further reusage * Add JSON tags to api config structs and implement FromJSON function • Implement FromJSON function to unmarshal JSON into config structs • Add JSON tags to all configuration structs to support JSON serialization and deserialization • Modify ToJSON function to return an error if marshaling fails • Add tests for ToJSON and FromJSON functions to ensure proper JSON handling • Fix incorrect YAML tag in cf.Config for Secret field * Improve gorouterproxy tests and request forwarding - Update gorouterproxy tests to forward path from original request. - Enhance request forwarding in main.go to include the original request method, headers, and body. - Add error logging for forwarding failures and ensure the XFCC header is not empty before forwarding. * Adds working integration test for api-scheduler when running in cf container * Fix formating * Update credentials key in VCAP_SERVICES for publicapiserver-config in api_test. * Fix typo * Rename cf-server to cfserver in scheduler config and update specs accordingly * Add CFHTTPConfiguration class to configure additional HTTP connector for Tomcat in Cloud Foundry Autoscaler Scheduler * Remove commented code * Uses DBURL when creating stubed api json configuration * Remove .vscode/settings.json from scheduler module * Adds missing Remove All * Remove SynchronizedAfterSuite cleanup block from integration tests * Remove unused logging * Fix typo * Ensure error handling for JSON conversion in config_test.go * Add nosec annotation to suppress G204 warning in GoRouterProxy command execution * Rename CFHTTPConfiguration class to CfHttpConfiguration and update references * Remove check on non empty xfcc space and org in scheduler xfcc filter * Improve policy deletion and retrieval error handling in API tests * Remove default HTTP port from scheduler spec and handle zero port configuration in CfHttpConfiguration * Change logging order in scheduler xfcc filter * Enable test case for retrieving policy with expected 404 response * Fix sonarque issue in gorouter proxy test * Update fly package from 7.12.0 to 7.12.1 across multiple architectures * Fix flaky test * Fix scheduler template spec * Remove unused PostConstruct import from XfccFilter in scheduler module * Remove httpcore dependency from scheduler module's pom.xml * Update credhub-cli from 2.9.29 to 2.9.42 and specify version for temurin-bin-21 * Improves scheduler cf_server property structure * review-commits * scheduler-> add unit tests for filtering logic * Removes cf configutil from helper logger - bubble up the errors to consumers of the cf config util. * Remove redundant devbox dependencies * Remove build-gorouterproxy from build-all target in Makefile * Fix java format * Amends Abbreviation in java class name classes must contain no more than '1' consecutive capital letters. * Update devbox lock * Update devbox.lock Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Remove unused dependencies from eventgenerator, operator, and scalingengine specs - Deleted autoscaler/configutil/* from eventgenerator, operator, and scalingengine - Removed autoscaler/vendor/github.com/cloud-gov/go-cfenv/* from eventgenerator and operator - Eliminated autoscaler/vendor/github.com/mitchellh/mapstructure/* from eventgenerator and scalingengine * Fix missing quote in json tag for TLSClientCerts in ScalingEngineConfig * Fix tabulation --------- Co-authored-by: app-autoscaler-ci-bot <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: geigerj0 <[email protected]> Co-authored-by: Silvestre Zabala <[email protected]> Co-authored-by: Arsalan Khan <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 255ea77 commit c815613

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1367
-328
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ keys/
6464
# <https://code.visualstudio.com/docs/editor/extension-marketplace#_workspace-recommended-extensions>
6565
!.vscode/extensions.json
6666

67+
.trunk
68+
6769

6870
# ==================== 📦 Devbox ====================
6971
.devbox
@@ -75,3 +77,7 @@ keys/
7577
/result-*
7678

7779
.direnv
80+
81+
# # macOS system file that stores folder metadata (safe to ignore)
82+
.DS_Store
83+

Makefile

+21-5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ clean-autoscaler:
7777
clean-scheduler:
7878
@echo " - cleaning scheduler test resources"
7979
@rm -rf src/scheduler/src/test/resources/certs
80+
@rm -rf src/scheduler/target
8081
clean-certs:
8182
@echo " - cleaning test certs"
8283
@rm -f test-certs/*
@@ -94,7 +95,7 @@ clean-acceptance:
9495
build: $(all_modules)
9596
build-tests: build-test
9697
build-test: $(addprefix test_,$(go_modules))
97-
build-all: generate-openapi-generated-clients-and-servers build build-test build-test-app ## Build all modules and tests
98+
build-all: generate-openapi-generated-clients-and-servers build build-test build-test-app
9899
db: target/db
99100
target/db:
100101
@echo "# building $@"
@@ -129,10 +130,12 @@ test-autoscaler: check-db_type init-db test-certs
129130
@echo ' - using DBURL=${DBURL} TEST=${TEST}'
130131
@make --directory='./src/autoscaler' test DBURL='${DBURL}' TEST='${TEST}'
131132
test-autoscaler-suite: check-db_type init-db test-certs
132-
@make --directory='./src/autoscaler' testsuite TEST='${TEST}' DBURL='${DBURL}'
133+
@make --directory='./src/autoscaler' testsuite TEST='${TEST}' DBURL='${DBURL}' GINKGO_OPTS='${GINKGO_OPTS}'
134+
133135
test-scheduler: check-db_type init-db test-certs
134136
@export DB_HOST=${DB_HOST}; \
135-
cd src && mvn test --no-transfer-progress -Dspring.profiles.include=${db_type} && cd ..
137+
make --directory='./src/scheduler' test DBURL="${DBURL}" db_type="${db_type}"
138+
136139
test-changelog:
137140
@make --directory='./src/changelog' test
138141
test-changeloglockcleaner: init-db test-certs
@@ -162,7 +165,8 @@ target/start-db-postgres_CI_false:
162165
--health-timeout 2s \
163166
--health-retries 10 \
164167
-d \
165-
postgres:${POSTGRES_TAG} >/dev/null;\
168+
postgres:${POSTGRES_TAG} \
169+
-c 'max_connections=1000' >/dev/null;\
166170
else echo " - $@ already up'"; fi;
167171
@touch $@
168172
target/start-db-postgres_CI_true:
@@ -218,7 +222,8 @@ stop-db: check-db_type
218222
@docker rm -f ${db_type} &> /dev/null || echo " - we could not stop and remove docker named '${db_type}'"
219223

220224
.PHONY: integration
221-
integration: generate-openapi-generated-clients-and-servers build init-db test-certs ## Run all integration tests
225+
integration: generate-openapi-generated-clients-and-servers build build-gorouterproxy init-db test-certs ## Run all integration tests
226+
222227
@echo " - using DBURL=${DBURL}"
223228
@make --directory='./src/autoscaler' integration DBURL="${DBURL}"
224229

@@ -248,6 +253,10 @@ $(addprefix lint_,$(go_modules)): lint_%:
248253
@echo " - linting: $(patsubst lint_%,%,$@)"
249254
@pushd src/$(patsubst lint_%,%,$@) >/dev/null && golangci-lint run --config ${lint_config} ${OPTS} --timeout 5m
250255

256+
lint-gorouterproxy:
257+
@echo " - linting: gorouterproxy"
258+
@pushd src/autoscaler/integration/gorouterproxy >/dev/null && golangci-lint run --config ${lint_config} $(OPTS) --timeout 5m
259+
251260
.PHONY: spec-test
252261
spec-test:
253262
bundle install
@@ -369,6 +378,9 @@ mta-build:
369378
build-test-app:
370379
@make --directory='./src/acceptance/assets/app/go_app' build
371380

381+
build-gorouterproxy:
382+
@make --directory='./src/autoscaler' build-gorouterproxy
383+
372384
.PHONY: deploy-test-app
373385
deploy-test-app:
374386
@make --directory='./src/acceptance/assets/app/go_app' deploy
@@ -457,6 +469,10 @@ go-get-u: $(addsuffix .go-get-u,$(go_modules))
457469
go get -u ./...
458470

459471

472+
start-scheduler:
473+
make --directory='./src/scheduler' start DBURL="${DBURL}"
474+
475+
460476
deploy-apps:
461477
echo " - deploying apps"
462478
DEBUG="${DEBUG}" ${CI_DIR}/autoscaler/scripts/deploy-apps.sh

devbox.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@
650650
}
651651
},
652652
"github:NixOS/nixpkgs/nixpkgs-unstable": {
653-
"resolved": "github:NixOS/nixpkgs/b1b43d32be000928cc71250ed77f4a0a5f2bc23a?lastModified=1739698114&narHash=sha256-8S9n69Dnpg8DhfFlP0YvMGmSOY2X4kImGSPWXYNpaHM%3D"
653+
"resolved": "github:NixOS/nixpkgs/632f04521e847173c54fa72973ec6c39a371211c?lastModified=1739863612&narHash=sha256-UbtgxplOhFcyjBcNbTVO8%2BHUHAl%2FWXFDOb6LvqShiZo%3D"
654654
},
655655
"glibcLocales@latest": {
656656
"last_modified": "2025-02-07T11:26:36Z",

jobs/scheduler/spec

+12-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ packages:
3636

3737
properties:
3838
autoscaler.scheduler.port:
39-
description: "Scheduler's port"
39+
description: "Scheduler's https port"
4040
default: 6102
41+
autoscaler.scheduler.http.port:
42+
description: "Scheduler's http port"
43+
default: 0
4144
autoscaler.scheduler.http_client_timeout:
4245
description: "Http client imeout for scheduler to communicate with other autoscaler components, in seconds"
4346
default: 60
@@ -57,6 +60,14 @@ properties:
5760
default: 3
5861
description: "Maximum number of notification sent to scaling engine for job re-schedule"
5962

63+
autoscaler.scheduler.cf_server.xfcc.valid_org_guid:
64+
description: approve org guid for xfcc endpoint
65+
default: ''
66+
67+
autoscaler.scheduler.cf_server.xfcc.valid_space_guid:
68+
description: approve space guid for xfcc endpoint
69+
default: ''
70+
6071
autoscaler.scheduler.scaling_engine.host:
6172
description: "URL where Scaling-engine is running"
6273
default: "scalingengine.service.cf.internal"

jobs/scheduler/templates/scheduler.yml.erb

+7
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,18 @@ scheduler:
164164
############################################################
165165
server:
166166
port: <%=p('autoscaler.scheduler.port') %>
167+
http:
168+
port: <%=p('autoscaler.scheduler.http.port') %>
167169
ssl:
168170
ciphers: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
169171
enabled-protocols: TLSv1.3
170172
bundle: "server"
171173
client-auth: NEED
172174

175+
cfserver:
176+
validOrgGuid: <%= p("autoscaler.scheduler.cf_server.xfcc.valid_org_guid") %>
177+
validSpaceGuid: <%= p("autoscaler.scheduler.cf_server.xfcc.valid_space_guid") %>
178+
179+
173180
#User added properties
174181
<%=p('autoscaler.scheduler.application.props')%>

packages/eventgenerator/spec

-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ files:
1212
- autoscaler/vendor/google.golang.org/protobuf/types/descriptorpb/*
1313
- autoscaler/cf/* # gosub
1414
- autoscaler/collection/* # gosub
15-
- autoscaler/configutil/* # gosub
1615
- autoscaler/db/* # gosub
1716
- autoscaler/db/sqldb/* # gosub
1817
- autoscaler/envelopeprocessor/* # gosub
@@ -45,7 +44,6 @@ files:
4544
- autoscaler/vendor/github.com/cenk/backoff/* # gosub
4645
- autoscaler/vendor/github.com/cenkalti/backoff/v4/* # gosub
4746
- autoscaler/vendor/github.com/cespare/xxhash/v2/* # gosub
48-
- autoscaler/vendor/github.com/cloud-gov/go-cfenv/* # gosub
4947
- autoscaler/vendor/github.com/facebookgo/clock/* # gosub
5048
- autoscaler/vendor/github.com/felixge/httpsnoop/* # gosub
5149
- autoscaler/vendor/github.com/go-logr/logr/* # gosub
@@ -84,7 +82,6 @@ files:
8482
- autoscaler/vendor/github.com/klauspost/compress/internal/snapref/* # gosub
8583
- autoscaler/vendor/github.com/klauspost/compress/zstd/* # gosub
8684
- autoscaler/vendor/github.com/klauspost/compress/zstd/internal/xxhash/* # gosub
87-
- autoscaler/vendor/github.com/mitchellh/mapstructure/* # gosub
8885
- autoscaler/vendor/github.com/munnerz/goautoneg/* # gosub
8986
- autoscaler/vendor/github.com/openzipkin/zipkin-go/idgenerator/* # gosub
9087
- autoscaler/vendor/github.com/openzipkin/zipkin-go/model/* # gosub

packages/operator/spec

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ files:
99
- autoscaler/vendor/*
1010
- autoscaler/operator/db/*
1111
- autoscaler/cf/* # gosub
12-
- autoscaler/configutil/* # gosub
1312
- autoscaler/db/* # gosub
1413
- autoscaler/db/sqldb/* # gosub
1514
- autoscaler/healthendpoint/* # gosub
@@ -30,7 +29,6 @@ files:
3029
- autoscaler/vendor/filippo.io/edwards25519/field/* # gosub
3130
- autoscaler/vendor/github.com/beorn7/perks/quantile/* # gosub
3231
- autoscaler/vendor/github.com/cespare/xxhash/v2/* # gosub
33-
- autoscaler/vendor/github.com/cloud-gov/go-cfenv/* # gosub
3432
- autoscaler/vendor/github.com/go-logr/logr/* # gosub
3533
- autoscaler/vendor/github.com/go-logr/logr/funcr/* # gosub
3634
- autoscaler/vendor/github.com/go-logr/stdr/* # gosub
@@ -64,7 +62,6 @@ files:
6462
- autoscaler/vendor/github.com/klauspost/compress/internal/snapref/* # gosub
6563
- autoscaler/vendor/github.com/klauspost/compress/zstd/* # gosub
6664
- autoscaler/vendor/github.com/klauspost/compress/zstd/internal/xxhash/* # gosub
67-
- autoscaler/vendor/github.com/mitchellh/mapstructure/* # gosub
6865
- autoscaler/vendor/github.com/munnerz/goautoneg/* # gosub
6966
- autoscaler/vendor/github.com/openzipkin/zipkin-go/idgenerator/* # gosub
7067
- autoscaler/vendor/github.com/openzipkin/zipkin-go/model/* # gosub

packages/scalingengine/spec

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ files:
99
- autoscaler/vendor/*
1010
- autoscaler/scalingengine/db/*
1111
- autoscaler/cf/* # gosub
12-
- autoscaler/configutil/* # gosub
1312
- autoscaler/db/* # gosub
1413
- autoscaler/db/sqldb/* # gosub
1514
- autoscaler/healthendpoint/* # gosub
@@ -36,7 +35,6 @@ files:
3635
- autoscaler/vendor/filippo.io/edwards25519/field/* # gosub
3736
- autoscaler/vendor/github.com/beorn7/perks/quantile/* # gosub
3837
- autoscaler/vendor/github.com/cespare/xxhash/v2/* # gosub
39-
- autoscaler/vendor/github.com/cloud-gov/go-cfenv/* # gosub
4038
- autoscaler/vendor/github.com/dlclark/regexp2/* # gosub
4139
- autoscaler/vendor/github.com/dlclark/regexp2/syntax/* # gosub
4240
- autoscaler/vendor/github.com/fatih/color/* # gosub
@@ -81,7 +79,6 @@ files:
8179
- autoscaler/vendor/github.com/klauspost/compress/zstd/internal/xxhash/* # gosub
8280
- autoscaler/vendor/github.com/mattn/go-colorable/* # gosub
8381
- autoscaler/vendor/github.com/mattn/go-isatty/* # gosub
84-
- autoscaler/vendor/github.com/mitchellh/mapstructure/* # gosub
8582
- autoscaler/vendor/github.com/munnerz/goautoneg/* # gosub
8683
- autoscaler/vendor/github.com/ogen-go/ogen/conv/* # gosub
8784
- autoscaler/vendor/github.com/ogen-go/ogen/http/* # gosub

scripts/generate_test_certs.sh

+9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ ${CERTSTRAP} --depot-path "${depot_path}" init --passphrase '' --common-name log
2121
mv -f "${depot_path}"/loggregatorCA.crt "${depot_path}"/loggregator-ca.crt
2222
mv -f "${depot_path}"/loggregatorCA.key "${depot_path}"/loggregator-ca.key
2323

24+
# CA to distribute to dummy gorouter ca certs
25+
${CERTSTRAP} --depot-path "${depot_path}" init --passphrase '' --common-name gorouterCA --years "20"
26+
mv -f "${depot_path}"/gorouterCA.crt "${depot_path}"/gorouter-ca.crt
27+
mv -f "${depot_path}"/gorouterCA.key "${depot_path}"/gorouter-ca.key
28+
2429
# CA to distribute to dummy syslog emitter certs
2530
${CERTSTRAP} --depot-path "${depot_path}" init --passphrase '' --common-name LogCacheSyslogServerCA --years "20"
2631
mv -f "${depot_path}"/LogCacheSyslogServerCA.crt "${depot_path}"/log-cache-syslog-server-ca.crt
@@ -96,6 +101,10 @@ ${CERTSTRAP} --depot-path "${depot_path}" sign log-cache --CA autoscaler-ca --ye
96101
${CERTSTRAP} --depot-path "${depot_path}" request-cert --passphrase '' --domain postgres,mysql --ip 127.0.0.1
97102
${CERTSTRAP} --depot-path "${depot_path}" sign postgres --CA autoscaler-ca --years "20"
98103

104+
# gorouter client certificate
105+
${CERTSTRAP} --depot-path "${depot_path}" request-cert --passphrase '' --domain gorouter --ip 127.0.0.1
106+
${CERTSTRAP} --depot-path "${depot_path}" sign gorouter --CA gorouter-ca --years "20"
107+
99108
# mTLS client certificate for local testing
100109
## certstrap with multiple OU not working at the moment. Pull request is created in the upstream. Therefore, using openssl at the moment
101110
## https://github.com/square/certstrap/pull/120

spec/jobs/scheduler/scheduler_spec.rb

+18-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@
1212
let(:properties) { YAML.safe_load(fixture("scheduler.yml").read) }
1313
let(:rendered_template) { YAML.safe_load(template.render(properties)) }
1414

15+
context "cf server" do
16+
it "default http port set to 0 - disabled" do
17+
expect(rendered_template["server"]["http"]["port"]).to eq(0)
18+
end
19+
20+
it "defaults xfcc valid org and space" do
21+
properties["autoscaler"]["scheduler"] = {}
22+
properties["autoscaler"]["scheduler"]["cf_server"] = {}
23+
properties["autoscaler"]["scheduler"]["cf_server"]["xfcc"] = {
24+
"valid_org_guid" => "some-valid-org-guid",
25+
"valid_space_guid" => "some-valid-space-guid"
26+
}
27+
28+
expect(rendered_template["cfserver"]["validOrgGuid"]).to eq(properties["autoscaler"]["scheduler"]["cf_server"]["xfcc"]["valid_org_guid"])
29+
expect(rendered_template["cfserver"]["validSpaceGuid"]).to eq(properties["autoscaler"]["scheduler"]["cf_server"]["xfcc"]["valid_space_guid"])
30+
end
31+
end
32+
1533
context "Health Configuration" do
1634
it "does set neither username nor password if not configured" do
1735
properties["autoscaler"]["scheduler"] = {
@@ -90,7 +108,6 @@
90108
it "verify database username and password have string types" do
91109
rendered_template = YAML.safe_load(template.render(properties))
92110

93-
print rendered_template
94111
expect(rendered_template["spring"]["datasource"]["username"]).to be_kind_of(String)
95112
expect(rendered_template["spring"]["datasource"]["username"]).not_to be_kind_of(Float)
96113
expect(rendered_template["spring"]["datasource"]["username"]).not_to eq(2222e123)

src/acceptance/api/api_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ var _ = Describe("AutoScaler Public API", func() {
8282
When("no scaling policy is set", func() {
8383

8484
BeforeEach(func() {
85-
_, status := deletePolicy()
86-
Expect(status).To(Or(Equal(200), Equal(404)))
85+
response, status := deletePolicy()
86+
Expect(status).To(Or(Equal(200), Equal(404)), fmt.Sprintf("failed to delete policy, received response: %s", string(response)))
8787
})
8888

8989
It("should fail with 404 when retrieve policy", func() {
90-
_, status := getPolicy()
91-
Expect(status).To(Equal(404))
90+
response, status := getPolicy()
91+
Expect(status).To(Equal(404), fmt.Sprintf("failed to get policy, received response: %s", string(response)))
9292
})
9393

9494
It("should succeed to create a valid policy", func() {

src/autoscaler/Makefile

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ EXTENSION_FILE := $(shell mktemp)
2222
export GOWORK=off
2323
BUILDFLAGS := -ldflags '-linkmode=external'
2424

25-
binaries=$(shell find . -name "main.go" -exec dirname {} \; | cut -d/ -f2 | sort | uniq | grep -v vendor)
25+
binaries=$(shell find . -name "main.go" -exec dirname {} \; | cut -d/ -f2 | sort | uniq | grep -Ev "vendor|integration")
2626
test_dirs=$(shell find . -name "*_test.go" -exec dirname {} \; | cut -d/ -f2 | sort | uniq)
2727
export GO111MODULE=on
2828

@@ -124,10 +124,16 @@ test: generate-fakes
124124
@echo "Running tests"
125125
APP_AUTOSCALER_TEST_RUN='true' ginkgo -p ${GINKGO_OPTS} ${TEST} --skip-package='integration'
126126

127-
testsuite:
127+
.PHONY: testsuite
128+
testsuite: build-gorouterproxy
128129
@echo " - using DBURL=${DBURL} TEST=${TEST}"
129130
APP_AUTOSCALER_TEST_RUN='true' ginkgo -p ${GINKGO_OPTS} ${TEST}
130131

132+
.PHONY: build-gorouterproxy
133+
build-gorouterproxy:
134+
@echo "# building gorouterproxy"
135+
@CGO_ENABLED=1 go build $(BUILDTAGS) $(BUILDFLAGS) -o build/gorouterproxy integration/gorouterproxy/main.go
136+
131137
.PHONY: integration
132138
integration: generate-fakes
133139
@echo "# Running integration tests"

src/autoscaler/api/cmd/api/api_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func getVcapServices() (result string) {
390390
}
391391

392392
result = `{
393-
"user-provided": [ { "name": "config", "tags": ["publicapiserver-config"], "credentials": { "publicapiserver": { } }}],
393+
"user-provided": [ { "name": "config", "tags": ["publicapiserver-config"], "credentials": { "publicapiserver-config": { } }}],
394394
"autoscaler": [ {
395395
"name": "some-service",
396396
"credentials": {

src/autoscaler/api/cmd/api/main.go

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ func main() {
3636
vcapConfiguration, err := configutil.NewVCAPConfigurationReader()
3737
if err != nil {
3838
_, _ = fmt.Fprintf(os.Stdout, "failed to read vcap configuration : %s\n", err.Error())
39-
os.Exit(1)
4039
}
4140

4241
conf, err = config.LoadConfig(path, vcapConfiguration)

0 commit comments

Comments
 (0)