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

Test deployment URL in integration tests #152

Open
NimJay opened this issue Sep 16, 2024 · 0 comments
Open

Test deployment URL in integration tests #152

NimJay opened this issue Sep 16, 2024 · 0 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@NimJay
Copy link
Contributor

NimJay commented Sep 16, 2024

Background:

  • Currently, in the integration tests (configured in int.cloudbuild.yaml), we create two deployments of this Jump Start Solution (JSS):
    • a deployment using MySQL
    • a deployment using PostgreSQL

Feature request

  • As part of the verification step, we should also verify that the deployment URL serves a working app.
  • Just a simple HTTP GET request and confirming that the text "<title>Todo</title>" exists should suffice.
  • We should minimize the amount of duplicated code when implementing this. Both simple_example and mysql should use a shared helper function.

Additional info

func testDeploymentUrl(t *testing.T, assert *assert.Assertions, url string) error {
	for attemptNum := 1; attemptNum <= 60; attemptNum++ {

		response, err := http.Get(url)
		if err != nil {
			t.Logf("Deployment URL HTTP request error: %s\n", err)

		} else if 200 <= response.StatusCode && response.StatusCode <= 299 { // Got some 200 response
			responseBody, err := ioutil.ReadAll(response.Body)
			if err != nil {
				return err
			}
			responseBodyString := string(responseBody)
			assert.Containsf(responseBodyString, "<title>Todo</title>", "Couldn't find text '<title>Todo</title>' in deployment's response")
			return nil

		} else { // Got a non-200 response
			t.Logf("Deployment URL responded with status code: %d.\n", response.StatusCode)
		}

		// Wait before retrying
		time.Sleep(4 * time.Second)
	}

	t.Logf("Waited too long for deployment URL.\n")
        // TODO: Consider failing
	return nil
}
@NimJay NimJay added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

1 participant