Skip to content

Commit

Permalink
Fix failing acceptance test
Browse files Browse the repository at this point in the history
- Make sure bpm is co-located with uaa in two-db-instances.yml opsfile
- Refactor two-db-instances.yml opsfile to only edit the relevant parts instead of having copy/pasted code in it
- Add `--progress --trace` options to ginko in CI job for better output
- Remove the BeforeEach from acceptance_tests_suite_test.go to make it easier to reason about the tests in uaa-release_test.go

[#164965110]
  • Loading branch information
cfryanr committed Apr 15, 2019
1 parent b3534d4 commit 8eef10e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 133 deletions.
2 changes: 1 addition & 1 deletion ci/tasks/test-acceptance.sh
Expand Up @@ -37,5 +37,5 @@ bosh deploy /tmp/uaa-deployment.yml \
--var=system_domain="$(hostname --fqdn)"

pushd "$GOPATH/src/acceptance_tests"
ginkgo -v -keepGoing -randomizeAllSpecs -randomizeSuites -race -r .
ginkgo -v --progress --trace -keepGoing -randomizeAllSpecs -randomizeSuites -race -r .
popd
5 changes: 3 additions & 2 deletions scripts/configure-test-runner.sh
Expand Up @@ -39,8 +39,9 @@ cd /root/uaa-release
set +x

echo
echo "Run 'ginkgo -v -keepGoing -r .' to run acceptance tests"
echo "Run 'refresh' to redeploy uaa to restore to a good deployment"
echo "Run 'ginkgo -v --progress --trace -r .' to run acceptance tests"
echo " - Optionally add '-keepGoing' to keep going after a failure"
echo "Run 'refresh' to delete/deploy uaa to restore to a good deployment"
echo "Run 'exit' when you are finished"

bash
5 changes: 0 additions & 5 deletions src/acceptance_tests/acceptance_tests_suite_test.go
Expand Up @@ -51,10 +51,6 @@ var _ = BeforeSuite(func() {
})
})

var _ = BeforeEach(func() {
deployUAA()
})

func setBoshEnvironmentVariables() {
var envFound bool

Expand Down Expand Up @@ -158,7 +154,6 @@ func getInstanceInfos(boshBinary string) []instanceInfo {
return out
}


func getUaaIP() (string, bool) {
instanceInfos := getInstanceInfos(boshBinaryPath)
for _, instanceInfo := range instanceInfos {
Expand Down
105 changes: 16 additions & 89 deletions src/acceptance_tests/opsfiles/two-db-instances.yml
@@ -1,8 +1,22 @@
- type: remove
path: /instance_groups/name=uaa
path: /instance_groups/name=uaa/jobs/name=uaa_postgres

- type: replace
path: /instance_groups/-
path: /instance_groups/name=uaa/jobs/name=uaa/properties/uaadb
value:
databases:
- name: uaa
tag: uaa
db_scheme: mysql
port: 3306
tls: disabled
roles:
- name: uaaadmin
password: admin
tag: admin

- type: replace
path: /instance_groups/0:before
value:
name: database
azs:
Expand Down Expand Up @@ -54,93 +68,6 @@
client:
tls: ((dns_api_client_tls))

- type: replace
path: /instance_groups/-
value:
name: uaa
azs:
- z1
instances: 1
vm_type: default
stemcell: default
networks:
- name: default
jobs:
- name: uaa
release: uaa
properties:
encryption:
active_key_label: 'key-1'
encryption_keys:
- label: 'key-1'
passphrase: 'MY-PASSPHRASE'
- label: 'key-2'
passphrase: 'MY-PASSPHRASE-TWO'
login:
defaultIdentityProvider: 'uaa'
saml:
activeKeyId: key1
keys:
key1:
key: "((uaa_login_saml.private_key))"
passphrase: password
certificate: "((uaa_login_saml.certificate))"
uaa:
clients:
admin:
authorized-grant-types: client_credentials
scope: uaa.none
authorities: uaa.admin,clients.read,clients.write,clients.secret,scim.read,scim.write,clients.admin
secret: "((uaa_admin_client_secret))"
jwt:
policy:
active_key_id: key-1
keys:
key-1:
signingKey: "((uaa_jwt_signing_key.private_key))"
scim:
user:
override: true
users:
- name: admin
password: "((cf_admin_password))"
groups:
- uaa.admin
- name: marissa
password: koala
groups:
- uaa.user
sslCertificate: "((uaa_ssl.certificate))"
sslPrivateKey: "((uaa_ssl.private_key))"
url: https://uaa.((system_domain))
uaadb:
databases:
- name: uaa
tag: uaa
db_scheme: mysql
port: 3306
tls: disabled
roles:
- name: uaaadmin
password: admin
tag: admin
- name: bosh-dns
release: bosh-dns
properties:
cache:
enabled: true
health:
enabled: true
server:
tls: ((dns_healthcheck_server_tls))
client:
tls: ((dns_healthcheck_client_tls))
api:
server:
tls: ((dns_api_server_tls))
client:
tls: ((dns_api_client_tls))

- type: replace
path: /releases/-
value:
Expand Down
73 changes: 37 additions & 36 deletions src/acceptance_tests/uaa-release_test.go
Expand Up @@ -43,6 +43,7 @@ var _ = Describe("UaaRelease", func() {
})

DescribeTable("uaa truststore", func(addedOSConfCertificates int, optFiles ...string) {
deployUAA()
numCertificatesBeforeDeploy := getNumOfOSCertificates()
deployUAA(optFiles...)
numCertificatesAfterDeploy := getNumOfOSCertificates()
Expand All @@ -62,7 +63,7 @@ var _ = Describe("UaaRelease", func() {

},
Entry("with os-conf not adding certs", 0, "./opsfiles/os-conf-0-certificate.yml"),
Entry("with and with os-conf + ca_cert property adding certificates", 11, "./opsfiles/os-conf-1-certificate.yml", "./opsfiles/load-more-ca-certs.yml"),
Entry("with os-conf + ca_cert property adding certificates", 11, "./opsfiles/os-conf-1-certificate.yml", "./opsfiles/load-more-ca-certs.yml"),
)

Context("UAA consuming the `database` link", func() {
Expand Down Expand Up @@ -179,41 +180,41 @@ var _ = Describe("uaa-rotator-errand", func() {
})

var _ = Describe("setting a custom UAA port", func() {
BeforeEach(func() {
deployUAA("./opsfiles/non-default-localhost-http-port.yml", "./opsfiles/non-default-ssl-port.yml")
})

Context("with custom http and https port", func() {
It("health_check should check the health on the correct port", func() {
assertUAAIsHealthy("/var/vcap/jobs/uaa/bin/health_check")

transCfg := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: transCfg}

uaaDomainName := "uaa.localhost"
By("setting a local domain name: uaa.localhost to point to localhost", func() {
addLocalDNS(uaaDomainName)
})

uaaHealthzEndpoint := fmt.Sprintf("https://%s:9443/healthz", uaaDomainName)
By(fmt.Sprintf("calling /healthz endpoint %s should return health", uaaHealthzEndpoint), func() {
healthzResp, err := client.Get(uaaHealthzEndpoint)
Expect(err).NotTo(HaveOccurred())
Expect(healthzResp.StatusCode).To(Equal(http.StatusOK))
Eventually(gbytes.BufferReader(healthzResp.Body)).Should(gbytes.Say("ok"))
})

uaaHealthzEndpoint = fmt.Sprintf("http://%s:9443/healthz", uaaDomainName)
By(fmt.Sprintf("calling /healthz endpoint %s should fail", uaaHealthzEndpoint), func() {
healthzResp, err := client.Get(uaaHealthzEndpoint)
Expect(err).NotTo(HaveOccurred())
Expect(healthzResp.StatusCode).To(Equal(http.StatusBadRequest))
Eventually(gbytes.BufferReader(healthzResp.Body)).Should(gbytes.Say(`Bad Request(\s)*This combination of host and port requires TLS.`))
})
})
})
BeforeEach(func() {
deployUAA("./opsfiles/non-default-localhost-http-port.yml", "./opsfiles/non-default-ssl-port.yml")
})

Context("with custom http and https port", func() {
It("health_check should check the health on the correct port", func() {
assertUAAIsHealthy("/var/vcap/jobs/uaa/bin/health_check")

transCfg := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: transCfg}

uaaDomainName := "uaa.localhost"
By("setting a local domain name: uaa.localhost to point to localhost", func() {
addLocalDNS(uaaDomainName)
})

uaaHealthzEndpoint := fmt.Sprintf("https://%s:9443/healthz", uaaDomainName)
By(fmt.Sprintf("calling /healthz endpoint %s should return health", uaaHealthzEndpoint), func() {
healthzResp, err := client.Get(uaaHealthzEndpoint)
Expect(err).NotTo(HaveOccurred())
Expect(healthzResp.StatusCode).To(Equal(http.StatusOK))
Eventually(gbytes.BufferReader(healthzResp.Body)).Should(gbytes.Say("ok"))
})

uaaHealthzEndpoint = fmt.Sprintf("http://%s:9443/healthz", uaaDomainName)
By(fmt.Sprintf("calling /healthz endpoint %s should fail", uaaHealthzEndpoint), func() {
healthzResp, err := client.Get(uaaHealthzEndpoint)
Expect(err).NotTo(HaveOccurred())
Expect(healthzResp.StatusCode).To(Equal(http.StatusBadRequest))
Eventually(gbytes.BufferReader(healthzResp.Body)).Should(gbytes.Say(`Bad Request(\s)*This combination of host and port requires TLS.`))
})
})
})
})

func assertUAAIsHealthy(healthCheckPath string) {
Expand Down

0 comments on commit 8eef10e

Please sign in to comment.