Uploaded image for project: 'AeroGear'
  1. AeroGear
  2. AEROGEAR-2251

Automated integration tests for each of the metrics endpoints

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • None

      Right now the aerogear-app-metrics service has plenty of unit tests and some basic integration tests for the dao (database) package. Those integration tests might be useful for this ticket. They can be found here:

      https://github.com/aerogear/aerogear-app-metrics/tree/master/pkg/dao

      Notice the build tags at the top of the tests in the dao library. // +build integration These ensure the integration tests are not run unless we explicitly pass an extra flag. You can see how this works in the make test-integrate and make test-integrate-cover commands in the Makefile

      This style should also be used with this ticket. There is already This will allow the tests to run in CI without any additional work.

      The outcome of this task is to create tests that spin up the server and test the behaviour of the metrics service in full against a postgres instance. The goal is to cover the "happy scenarios" and all of the expected error scenarios.

      The following PRs (already merged) had manual verification steps which outline a good number of potential request scenarios and the expected behaviour.

      The tests should probably do the following:

      • Create a new package in the pkg folder called 'test'
      • Add the test file(s) in this folder
      • Make sure to use the // +build integration flag at the top of the test file(s).
      • Initialize the app business logic and router in the same way that cmd/metrics-api/metrics-api.go does it.
      • Insert the router into a httptest.Server using the built in httptest library
      • Create a matrix of client payloads and expected responses to run a suite of tests against the server
      • Potentially implement some mechanism to actually verify the records in the database?

      There doesn't need to be any clever stuff to start the database. The database will be available in CI and the tests should automatically run as long as the // +build integration was included.

            phajidec@redhat.com Paolo Bueno (Inactive)
            davmarti@redhat.com David Martin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: