Speed up API tests (#624)

* Adjust API tests internal API

* Refactor API tests to take less time

 - sqlite: tests 15s, overall time: 1m
 - mysql: tests 15s, overall time: 59s

* Use retry func to survive in faulty places

* Use retry func while trying to ping SQL datastore

 - implements retry func specifically for SQL datastore ping
 - fmt fixes
 - using sqlx.Db.PingContext instead of sqlx.Db.Ping
 - propogate context to SQL datastore

* Simplify TestCanCauseTimeout retry loop

* Call retry with sane timeout

* Fix TestOversizedLog, use retry func

* Increase number of attempts

 2 test cases are really faulty in CI, so they need a lot more time to finish.

* Increase TestCanCauseTimeout timeout

* Use retry at TestMultiLog to speed it up

* Use retry at TestCanWriteLogs to speed it up

* Use retry at TestGetCallsSuccess to speed it up

* Use retry at TestCanGetAsyncState to speed it up

* Use retry at TestListCallsSuccess to speed it up

* Remove sleep calls

* Remove dup test case

* Cleaup Calls API test

* Build API tests binary once

 This patch lets CI to build API tests binary once and reuse that whenever it needs it

* Swap API tests checks

* Build API test binary by default

 dirty fix for CircleCI

* Use retry func to determine if datastore is alive in tests

* go install should also reduce build time

* Fix rebase issues
This commit is contained in:
Denis Makogon
2018-01-02 21:29:49 +02:00
committed by Reed Allman
parent cafc277325
commit 9d6f0b2a05
10 changed files with 785 additions and 773 deletions

View File

@@ -89,17 +89,19 @@ func assertRouteFields(t *testing.T, routeObject *models.Route, path, image, rou
}
func createRoute(ctx context.Context, fnclient *client.Fn, appName, image, routePath, routeType, routeFormat string, routeConfig map[string]string, headers map[string][]string) (*routes.PostAppsAppRoutesOK, error) {
func createRoute(ctx context.Context, fnclient *client.Fn, appName, image, routePath, routeType, routeFormat string, timeout, idleTimeout int32, routeConfig map[string]string, headers map[string][]string) (*routes.PostAppsAppRoutesOK, error) {
cfg := &routes.PostAppsAppRoutesParams{
App: appName,
Body: &models.RouteWrapper{
Route: &models.Route{
Config: routeConfig,
Headers: headers,
Image: image,
Path: routePath,
Type: routeType,
Format: routeFormat,
Config: routeConfig,
Headers: headers,
Image: image,
Path: routePath,
Type: routeType,
Format: routeFormat,
Timeout: &timeout,
IDLETimeout: &idleTimeout,
},
},
Context: ctx,
@@ -119,8 +121,8 @@ func createRoute(ctx context.Context, fnclient *client.Fn, appName, image, route
}
func CreateRoute(t *testing.T, ctx context.Context, fnclient *client.Fn, appName, routePath, image, routeType, routeFormat string, routeConfig map[string]string, headers map[string][]string) {
routeResponse, err := createRoute(ctx, fnclient, appName, image, routePath, routeType, routeFormat, routeConfig, headers)
func CreateRoute(t *testing.T, ctx context.Context, fnclient *client.Fn, appName, routePath, image, routeType, routeFormat string, timeout, idleTimeout int32, routeConfig map[string]string, headers map[string][]string) {
routeResponse, err := createRoute(ctx, fnclient, appName, image, routePath, routeType, routeFormat, timeout, idleTimeout, routeConfig, headers)
CheckRouteResponseError(t, err)
assertRouteFields(t, routeResponse.Payload.Route, routePath, image, routeType, routeFormat)