Merge pull request #314 from fnproject/302

Implementing force delete for apps
This commit is contained in:
Reed Allman
2017-09-13 10:01:59 -07:00
committed by GitHub
16 changed files with 85 additions and 94 deletions

View File

@@ -51,10 +51,11 @@ func NewFuncLogger(ctx context.Context, appName, path, image, reqID string, logD
// we don't need to log per line to db, but we do need to limit it // we don't need to log per line to db, but we do need to limit it
limitw := newLimitWriter(MB, &dbWriter{ limitw := newLimitWriter(MB, &dbWriter{
Buffer: dbuf, Buffer: dbuf,
db: logDB, db: logDB,
ctx: ctx, ctx: ctx,
reqID: reqID, reqID: reqID,
appName: appName,
}) })
// TODO / NOTE: we want linew to be first because limitw may error if limit // TODO / NOTE: we want linew to be first because limitw may error if limit
@@ -177,15 +178,16 @@ func (li *lineWriter) Close() error {
type dbWriter struct { type dbWriter struct {
*bytes.Buffer *bytes.Buffer
db models.LogStore db models.LogStore
ctx context.Context ctx context.Context
reqID string reqID string
appName string
} }
func (w *dbWriter) Close() error { func (w *dbWriter) Close() error {
span, ctx := opentracing.StartSpanFromContext(context.Background(), "agent_log_write") span, ctx := opentracing.StartSpanFromContext(context.Background(), "agent_log_write")
defer span.Finish() defer span.Finish()
return w.db.InsertLog(ctx, w.reqID, w.String()) return w.db.InsertLog(ctx, w.appName, w.reqID, w.String())
} }
func (w *dbWriter) Write(b []byte) (int, error) { func (w *dbWriter) Write(b []byte) (int, error) {

View File

@@ -100,22 +100,22 @@ func (m *metricds) GetCalls(ctx context.Context, filter *models.CallFilter) ([]*
return m.ds.GetCalls(ctx, filter) return m.ds.GetCalls(ctx, filter)
} }
func (m *metricds) InsertLog(ctx context.Context, callID string, callLog string) error { func (m *metricds) InsertLog(ctx context.Context, appName, callID, callLog string) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "ds_insert_log") span, ctx := opentracing.StartSpanFromContext(ctx, "ds_insert_log")
defer span.Finish() defer span.Finish()
return m.ds.InsertLog(ctx, callID, callLog) return m.ds.InsertLog(ctx, appName, callID, callLog)
} }
func (m *metricds) GetLog(ctx context.Context, callID string) (*models.CallLog, error) { func (m *metricds) GetLog(ctx context.Context, appName, callID string) (*models.CallLog, error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "ds_get_log") span, ctx := opentracing.StartSpanFromContext(ctx, "ds_get_log")
defer span.Finish() defer span.Finish()
return m.ds.GetLog(ctx, callID) return m.ds.GetLog(ctx, appName, callID)
} }
func (m *metricds) DeleteLog(ctx context.Context, callID string) error { func (m *metricds) DeleteLog(ctx context.Context, appName, callID string) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "ds_delete_log") span, ctx := opentracing.StartSpanFromContext(ctx, "ds_delete_log")
defer span.Finish() defer span.Finish()
return m.ds.DeleteLog(ctx, callID) return m.ds.DeleteLog(ctx, appName, callID)
} }
// instant & no context ;) // instant & no context ;)

View File

@@ -138,8 +138,8 @@ func (v *validator) GetCall(ctx context.Context, appName, callID string) (*model
return v.Datastore.GetCall(ctx, appName, callID) return v.Datastore.GetCall(ctx, appName, callID)
} }
func (v *validator) DeleteLog(ctx context.Context, callID string) error { func (v *validator) DeleteLog(ctx context.Context, appName, callID string) error {
return v.Datastore.DeleteLog(ctx, callID) return v.Datastore.DeleteLog(ctx, appName, callID)
} }
// GetDatabase returns the underlying sqlx database implementation // GetDatabase returns the underlying sqlx database implementation

View File

@@ -60,6 +60,8 @@ func (m *mock) UpdateApp(ctx context.Context, app *models.App) (*models.App, err
} }
func (m *mock) RemoveApp(ctx context.Context, appName string) error { func (m *mock) RemoveApp(ctx context.Context, appName string) error {
m.batchDeleteCalls(ctx, appName)
m.batchDeleteRoutes(ctx, appName)
for i, a := range m.Apps { for i, a := range m.Apps {
if a.Name == appName { if a.Name == appName {
m.Apps = append(m.Apps[:i], m.Apps[i+1:]...) m.Apps = append(m.Apps[:i], m.Apps[i+1:]...)
@@ -157,6 +159,28 @@ func (m *mock) GetCalls(ctx context.Context, filter *models.CallFilter) ([]*mode
return m.Calls, nil return m.Calls, nil
} }
func (m *mock) batchDeleteCalls(ctx context.Context, appName string) error {
newCalls := []*models.Call{}
for _, c := range m.Calls {
if c.AppName != appName {
newCalls = append(newCalls, c)
}
}
m.Calls = newCalls
return nil
}
func (m *mock) batchDeleteRoutes(ctx context.Context, appName string) error {
newRoutes := []*models.Route{}
for _, c := range m.Routes {
if c.AppName != appName {
newRoutes = append(newRoutes, c)
}
}
m.Routes = newRoutes
return nil
}
// GetDatabase returns nil here since shouldn't really be used // GetDatabase returns nil here since shouldn't really be used
func (m *mock) GetDatabase() *sqlx.DB { func (m *mock) GetDatabase() *sqlx.DB {
return nil return nil

View File

@@ -61,6 +61,7 @@ var tables = [...]string{`CREATE TABLE IF NOT EXISTS routes (
`CREATE TABLE IF NOT EXISTS logs ( `CREATE TABLE IF NOT EXISTS logs (
id varchar(256) NOT NULL PRIMARY KEY, id varchar(256) NOT NULL PRIMARY KEY,
app_name varchar(256) NOT NULL,
log text NOT NULL log text NOT NULL
);`, );`,
} }
@@ -220,9 +221,18 @@ func (ds *sqlStore) UpdateApp(ctx context.Context, newapp *models.App) (*models.
} }
func (ds *sqlStore) RemoveApp(ctx context.Context, appName string) error { func (ds *sqlStore) RemoveApp(ctx context.Context, appName string) error {
query := ds.db.Rebind(`DELETE FROM apps WHERE name = ?`) res, err := ds.db.ExecContext(ctx, ds.db.Rebind(
_, err := ds.db.ExecContext(ctx, query, appName) `DELETE FROM apps WHERE name = ?;
return err DELETE FROM logs WHERE app_name=?;
DELETE FROM calls WHERE app_name=?;
DELETE FROM routes WHERE app_name=?;`), appName, appName, appName, appName)
if err != nil {
return err
}
if _, err := res.RowsAffected(); err != nil {
return models.ErrAppsNotFound
}
return nil
} }
func (ds *sqlStore) GetApp(ctx context.Context, name string) (*models.App, error) { func (ds *sqlStore) GetApp(ctx context.Context, name string) (*models.App, error) {
@@ -589,15 +599,15 @@ func (ds *sqlStore) GetCalls(ctx context.Context, filter *models.CallFilter) ([]
return res, nil return res, nil
} }
func (ds *sqlStore) InsertLog(ctx context.Context, callID, callLog string) error { func (ds *sqlStore) InsertLog(ctx context.Context, appName, callID, callLog string) error {
query := ds.db.Rebind(`INSERT INTO logs (id, log) VALUES (?, ?);`) query := ds.db.Rebind(`INSERT INTO logs (id, app_name, log) VALUES (?, ?, ?);`)
_, err := ds.db.ExecContext(ctx, query, callID, callLog) _, err := ds.db.ExecContext(ctx, query, callID, appName, callLog)
return err return err
} }
func (ds *sqlStore) GetLog(ctx context.Context, callID string) (*models.CallLog, error) { func (ds *sqlStore) GetLog(ctx context.Context, appName, callID string) (*models.CallLog, error) {
query := ds.db.Rebind(`SELECT log FROM logs WHERE id=?`) query := ds.db.Rebind(`SELECT log FROM logs WHERE id=? AND app_name=?`)
row := ds.db.QueryRowContext(ctx, query, callID) row := ds.db.QueryRowContext(ctx, query, callID, appName)
var log string var log string
err := row.Scan(&log) err := row.Scan(&log)
@@ -609,14 +619,15 @@ func (ds *sqlStore) GetLog(ctx context.Context, callID string) (*models.CallLog,
} }
return &models.CallLog{ return &models.CallLog{
CallID: callID, CallID: callID,
Log: log, Log: log,
AppName: appName,
}, nil }, nil
} }
func (ds *sqlStore) DeleteLog(ctx context.Context, callID string) error { func (ds *sqlStore) DeleteLog(ctx context.Context, appName, callID string) error {
query := ds.db.Rebind(`DELETE FROM logs WHERE id=?`) query := ds.db.Rebind(`DELETE FROM logs WHERE id=? AND app_name=?`)
_, err := ds.db.ExecContext(ctx, query, callID) _, err := ds.db.ExecContext(ctx, query, callID, appName)
return err return err
} }

View File

@@ -27,12 +27,12 @@ func (m *mock) SetDatastore(ctx context.Context, ds models.Datastore) {
m.ds = ds m.ds = ds
} }
func (m *mock) InsertLog(ctx context.Context, callID string, callLog string) error { func (m *mock) InsertLog(ctx context.Context, appName, callID, callLog string) error {
m.Logs[callID] = &models.CallLog{CallID: callID, Log: callLog} m.Logs[callID] = &models.CallLog{CallID: callID, Log: callLog}
return nil return nil
} }
func (m *mock) GetLog(ctx context.Context, callID string) (*models.CallLog, error) { func (m *mock) GetLog(ctx context.Context, appName, callID string) (*models.CallLog, error) {
logEntry := m.Logs[callID] logEntry := m.Logs[callID]
if logEntry == nil { if logEntry == nil {
return nil, errors.New("Call log not found") return nil, errors.New("Call log not found")
@@ -41,7 +41,7 @@ func (m *mock) GetLog(ctx context.Context, callID string) (*models.CallLog, erro
return m.Logs[callID], nil return m.Logs[callID], nil
} }
func (m *mock) DeleteLog(ctx context.Context, callID string) error { func (m *mock) DeleteLog(ctx context.Context, appName, callID string) error {
delete(m.Logs, callID) delete(m.Logs, callID)
return nil return nil
} }

View File

@@ -44,7 +44,7 @@ func Test(t *testing.T, fnl models.LogStore, ds models.Datastore) {
if err != nil { if err != nil {
t.Fatalf("Test InsertCall(ctx, &call): unexpected error `%v`", err) t.Fatalf("Test InsertCall(ctx, &call): unexpected error `%v`", err)
} }
err = fnl.InsertLog(ctx, call.ID, "test") err = fnl.InsertLog(ctx, call.AppName, call.ID, "test")
if err != nil { if err != nil {
t.Fatalf("Test InsertLog(ctx, call.ID, logText): unexpected error during inserting log `%v`", err) t.Fatalf("Test InsertLog(ctx, call.ID, logText): unexpected error during inserting log `%v`", err)
} }
@@ -56,11 +56,11 @@ func Test(t *testing.T, fnl models.LogStore, ds models.Datastore) {
if err != nil { if err != nil {
t.Fatalf("Test InsertCall(ctx, &call): unexpected error `%v`", err) t.Fatalf("Test InsertCall(ctx, &call): unexpected error `%v`", err)
} }
err = fnl.InsertLog(ctx, call.ID, logText) err = fnl.InsertLog(ctx, call.AppName, call.ID, logText)
if err != nil { if err != nil {
t.Fatalf("Test InsertLog(ctx, call.ID, logText): unexpected error during inserting log `%v`", err) t.Fatalf("Test InsertLog(ctx, call.ID, logText): unexpected error during inserting log `%v`", err)
} }
logEntry, err := fnl.GetLog(ctx, call.ID) logEntry, err := fnl.GetLog(ctx, call.AppName, call.ID)
if !strings.Contains(logEntry.Log, logText) { if !strings.Contains(logEntry.Log, logText) {
t.Fatalf("Test GetLog(ctx, call.ID, logText): unexpected error, log mismatch. "+ t.Fatalf("Test GetLog(ctx, call.ID, logText): unexpected error, log mismatch. "+
"Expected: `%v`. Got `%v`.", logText, logEntry.Log) "Expected: `%v`. Got `%v`.", logText, logEntry.Log)
@@ -73,16 +73,16 @@ func Test(t *testing.T, fnl models.LogStore, ds models.Datastore) {
if err != nil { if err != nil {
t.Fatalf("Test InsertCall(ctx, &call): unexpected error `%v`", err) t.Fatalf("Test InsertCall(ctx, &call): unexpected error `%v`", err)
} }
err = fnl.InsertLog(ctx, call.ID, logText) err = fnl.InsertLog(ctx, call.AppName, call.ID, logText)
if err != nil { if err != nil {
t.Fatalf("Test InsertLog(ctx, call.ID, logText): unexpected error during inserting log `%v`", err) t.Fatalf("Test InsertLog(ctx, call.ID, logText): unexpected error during inserting log `%v`", err)
} }
logEntry, err := fnl.GetLog(ctx, call.ID) logEntry, err := fnl.GetLog(ctx, call.AppName, call.ID)
if !strings.Contains(logEntry.Log, logText) { if !strings.Contains(logEntry.Log, logText) {
t.Fatalf("Test GetLog(ctx, call.ID, logText): unexpected error, log mismatch. "+ t.Fatalf("Test GetLog(ctx, call.ID, logText): unexpected error, log mismatch. "+
"Expected: `%v`. Got `%v`.", logText, logEntry.Log) "Expected: `%v`. Got `%v`.", logText, logEntry.Log)
} }
err = fnl.DeleteLog(ctx, call.ID) err = fnl.DeleteLog(ctx, call.AppName, call.ID)
if err != nil { if err != nil {
t.Fatalf("Test DeleteLog(ctx, call.ID): unexpected error during deleting log `%v`", err) t.Fatalf("Test DeleteLog(ctx, call.ID): unexpected error during deleting log `%v`", err)
} }

View File

@@ -23,8 +23,9 @@ const (
var possibleStatuses = [...]string{"delayed", "queued", "running", "success", "error", "cancelled"} var possibleStatuses = [...]string{"delayed", "queued", "running", "success", "error", "cancelled"}
type CallLog struct { type CallLog struct {
CallID string `json:"call_id"` CallID string `json:"call_id"`
Log string `json:"log"` Log string `json:"log"`
AppName string `json:"app_name"`
} }
// Call is a representation of a specific invocation of a route. // Call is a representation of a specific invocation of a route.

View File

@@ -28,7 +28,6 @@ type Datastore interface {
// RemoveApp removes the App named appName. Returns ErrDatastoreEmptyAppName if appName is empty. // RemoveApp removes the App named appName. Returns ErrDatastoreEmptyAppName if appName is empty.
// Returns ErrAppsNotFound if an App is not found. // Returns ErrAppsNotFound if an App is not found.
// TODO remove routes automatically? #528
RemoveApp(ctx context.Context, appName string) error RemoveApp(ctx context.Context, appName string) error
// GetRoute looks up a matching Route for appName and the literal request route routePath. // GetRoute looks up a matching Route for appName and the literal request route routePath.

View File

@@ -11,13 +11,13 @@ type LogStore interface {
// InsertLog will insert the log at callID, overwriting if it previously // InsertLog will insert the log at callID, overwriting if it previously
// existed. // existed.
InsertLog(ctx context.Context, callID string, callLog string) error InsertLog(ctx context.Context, appName, callID string, callLog string) error
// GetLog will return the log at callID, an error will be returned if the log // GetLog will return the log at callID, an error will be returned if the log
// cannot be found. // cannot be found.
GetLog(ctx context.Context, callID string) (*CallLog, error) GetLog(ctx context.Context, appName, callID string) (*CallLog, error)
// DeleteLog will remove the log at callID, it will not return an error if // DeleteLog will remove the log at callID, it will not return an error if
// the log does not exist before removal. // the log does not exist before removal.
DeleteLog(ctx context.Context, callID string) error DeleteLog(ctx context.Context, appName, callID string) error
} }

View File

@@ -15,30 +15,7 @@ func (s *Server) handleAppDelete(c *gin.Context) {
app := &models.App{Name: c.MustGet(api.AppName).(string)} app := &models.App{Name: c.MustGet(api.AppName).(string)}
routes, err := s.Datastore.GetRoutesByApp(ctx, app.Name, &models.RouteFilter{}) err := s.FireBeforeAppDelete(ctx, app)
if err != nil {
log.WithError(err).Error("error getting route in app delete")
handleErrorResponse(c, err)
return
}
//TODO allow this? #528
if len(routes) > 0 {
handleErrorResponse(c, models.ErrDeleteAppsWithRoutes)
return
}
err = s.FireBeforeAppDelete(ctx, app)
if err != nil {
log.WithError(err).Error("error firing before app delete")
handleErrorResponse(c, err)
return
}
app, err = s.Datastore.GetApp(ctx, app.Name)
if err != nil {
handleErrorResponse(c, err)
return
}
err = s.Datastore.RemoveApp(ctx, app.Name) err = s.Datastore.RemoveApp(ctx, app.Name)
if err != nil { if err != nil {

View File

@@ -18,7 +18,7 @@ func (s *Server) handleCallLogGet(c *gin.Context) {
return return
} }
callObj, err := s.LogDB.GetLog(ctx, callID) callObj, err := s.LogDB.GetLog(ctx, appName, callID)
if err != nil { if err != nil {
handleErrorResponse(c, err) handleErrorResponse(c, err)
return return
@@ -37,7 +37,7 @@ func (s *Server) handleCallLogDelete(c *gin.Context) {
handleErrorResponse(c, err) handleErrorResponse(c, err)
return return
} }
err = s.LogDB.DeleteLog(ctx, callID) err = s.LogDB.DeleteLog(ctx, appName, callID)
if err != nil { if err != nil {
handleErrorResponse(c, err) handleErrorResponse(c, err)
return return

View File

@@ -121,7 +121,6 @@ func TestFullStack(t *testing.T) {
{"execute myroute2", "POST", "/r/myapp/myroute2", `{ "name": "Teste" }`, http.StatusInternalServerError, 2}, {"execute myroute2", "POST", "/r/myapp/myroute2", `{ "name": "Teste" }`, http.StatusInternalServerError, 2},
{"get myroute2", "GET", "/v1/apps/myapp/routes/myroute2", ``, http.StatusOK, 2}, {"get myroute2", "GET", "/v1/apps/myapp/routes/myroute2", ``, http.StatusOK, 2},
{"delete myroute", "DELETE", "/v1/apps/myapp/routes/myroute", ``, http.StatusOK, 1}, {"delete myroute", "DELETE", "/v1/apps/myapp/routes/myroute", ``, http.StatusOK, 1},
{"delete app (fail)", "DELETE", "/v1/apps/myapp", ``, http.StatusConflict, 1},
{"delete myroute2", "DELETE", "/v1/apps/myapp/routes/myroute2", ``, http.StatusOK, 0}, {"delete myroute2", "DELETE", "/v1/apps/myapp/routes/myroute2", ``, http.StatusOK, 0},
{"delete app (success)", "DELETE", "/v1/apps/myapp", ``, http.StatusOK, 0}, {"delete app (success)", "DELETE", "/v1/apps/myapp", ``, http.StatusOK, 0},
{"get deleted app", "GET", "/v1/apps/myapp", ``, http.StatusNotFound, 0}, {"get deleted app", "GET", "/v1/apps/myapp", ``, http.StatusNotFound, 0},

View File

@@ -62,7 +62,6 @@ func TestCalls(t *testing.T) {
t.Error("Must fail because `dummy` call does not exist.") t.Error("Must fail because `dummy` call does not exist.")
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -97,7 +96,6 @@ func TestCalls(t *testing.T) {
t.Errorf("Unexpected error occurred: %v.", msg) t.Errorf("Unexpected error occurred: %v.", msg)
} }
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -135,7 +133,6 @@ func TestCalls(t *testing.T) {
t.Errorf("Call path mismatch.\n\tExpected: %v\n\tActual: %v", c.Path, s.RoutePath) t.Errorf("Call path mismatch.\n\tExpected: %v\n\tActual: %v", c.Path, s.RoutePath)
} }
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })

View File

@@ -75,7 +75,6 @@ func TestRouteExecutions(t *testing.T) {
if !strings.Contains(expectedOutput, output.String()) { if !strings.Contains(expectedOutput, output.String()) {
t.Errorf("Assertion error.\n\tExpected: %v\n\tActual: %v", expectedOutput, output.String()) t.Errorf("Assertion error.\n\tExpected: %v\n\tActual: %v", expectedOutput, output.String())
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -105,7 +104,6 @@ func TestRouteExecutions(t *testing.T) {
if !strings.Contains(expectedOutput, output.String()) { if !strings.Contains(expectedOutput, output.String()) {
t.Errorf("Assertion error.\n\tExpected: %v\n\tActual: %v", expectedOutput, output.String()) t.Errorf("Assertion error.\n\tExpected: %v\n\tActual: %v", expectedOutput, output.String())
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -132,7 +130,6 @@ func TestRouteExecutions(t *testing.T) {
CheckRouteResponseError(t, err) CheckRouteResponseError(t, err)
CallAsync(t, u, &bytes.Buffer{}) CallAsync(t, u, &bytes.Buffer{})
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -188,7 +185,6 @@ func TestRouteExecutions(t *testing.T) {
t.Errorf("Call object status mismatch.\n\tExpected: %v\n\tActual:%v", "success", callObject.Status) t.Errorf("Call object status mismatch.\n\tExpected: %v\n\tActual:%v", "success", callObject.Status)
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -237,7 +233,6 @@ func TestRouteExecutions(t *testing.T) {
"output", "callObj.Payload.Call.Status") "output", "callObj.Payload.Call.Status")
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, routePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -283,7 +278,6 @@ func TestRouteExecutions(t *testing.T) {
"string, but got: %v", logObj.Payload.Log.Log) "string, but got: %v", logObj.Payload.Log.Log)
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, routePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -356,7 +350,6 @@ func TestRouteExecutions(t *testing.T) {
t.Errorf("Unexpected error: %s", err) t.Errorf("Unexpected error: %s", err)
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, routePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -401,7 +394,6 @@ func TestRouteExecutions(t *testing.T) {
t.Errorf("Log entry suppose to be truncated up to expected size %v, got %v", t.Errorf("Log entry suppose to be truncated up to expected size %v, got %v",
size/1024, len(logObj.Payload.Log.Log)) size/1024, len(logObj.Payload.Log.Log))
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, routePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })

View File

@@ -29,7 +29,6 @@ func TestRoutes(t *testing.T) {
CreateApp(t, s.Context, s.Client, s.AppName, map[string]string{}) CreateApp(t, s.Context, s.Client, s.AppName, map[string]string{})
CreateRoute(t, s.Context, s.Client, s.AppName, s.RoutePath, s.Image, s.RouteType, CreateRoute(t, s.Context, s.Client, s.AppName, s.RoutePath, s.Image, s.RouteType,
s.Format, s.RouteConfig, s.RouteHeaders) s.Format, s.RouteConfig, s.RouteHeaders)
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -42,7 +41,6 @@ func TestRoutes(t *testing.T) {
if !assertContainsRoute(ListRoutes(t, s.Context, s.Client, s.AppName), s.RoutePath) { if !assertContainsRoute(ListRoutes(t, s.Context, s.Client, s.AppName), s.RoutePath) {
t.Errorf("Unable to find corresponding route `%v` in list", s.RoutePath) t.Errorf("Unable to find corresponding route `%v` in list", s.RoutePath)
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -58,7 +56,6 @@ func TestRoutes(t *testing.T) {
t.Errorf("Unable to find corresponding route `%v` in list", s.RoutePath) t.Errorf("Unable to find corresponding route `%v` in list", s.RoutePath)
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -78,7 +75,6 @@ func TestRoutes(t *testing.T) {
CheckRouteResponseError(t, err) CheckRouteResponseError(t, err)
assertRouteFields(t, routeResp.Payload.Route, s.RoutePath, s.Image, newRouteType, s.Format) assertRouteFields(t, routeResp.Payload.Route, s.RoutePath, s.Image, newRouteType, s.Format)
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -102,7 +98,6 @@ func TestRoutes(t *testing.T) {
CheckRouteResponseError(t, err) CheckRouteResponseError(t, err)
assertRouteFields(t, routeResp.Payload.Route, s.RoutePath, s.Image, s.RouteType, s.Format) assertRouteFields(t, routeResp.Payload.Route, s.RoutePath, s.Image, s.RouteType, s.Format)
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -122,7 +117,6 @@ func TestRoutes(t *testing.T) {
t.Errorf("Route path suppose to be immutable, but it's not.") t.Errorf("Route path suppose to be immutable, but it's not.")
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -138,7 +132,6 @@ func TestRoutes(t *testing.T) {
t.Errorf("Route duplicate error should appear, but it didn't") t.Errorf("Route duplicate error should appear, but it didn't")
} }
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -171,7 +164,6 @@ func TestRoutes(t *testing.T) {
DeployRoute(t, s.Context, s.Client, s.AppName, s.RoutePath, s.Image, s.RouteType, s.Format, s.RouteConfig, s.RouteHeaders) DeployRoute(t, s.Context, s.Client, s.AppName, s.RoutePath, s.Image, s.RouteType, s.Format, s.RouteConfig, s.RouteHeaders)
GetApp(t, s.Context, s.Client, s.AppName) GetApp(t, s.Context, s.Client, s.AppName)
GetRoute(t, s.Context, s.Client, s.AppName, s.RoutePath) GetRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -181,7 +173,6 @@ func TestRoutes(t *testing.T) {
DeployRoute(t, s.Context, s.Client, s.AppName, s.RoutePath, s.Image, s.RouteType, s.Format, s.RouteConfig, s.RouteHeaders) DeployRoute(t, s.Context, s.Client, s.AppName, s.RoutePath, s.Image, s.RouteType, s.Format, s.RouteConfig, s.RouteHeaders)
GetApp(t, s.Context, s.Client, s.AppName) GetApp(t, s.Context, s.Client, s.AppName)
GetRoute(t, s.Context, s.Client, s.AppName, s.RoutePath) GetRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
@@ -199,8 +190,6 @@ func TestRoutes(t *testing.T) {
s.Format, s.RouteConfig, s.RouteHeaders) s.Format, s.RouteConfig, s.RouteHeaders)
assertRouteFields(t, updatedRoute, s.RoutePath, s.Image, newRouteType, s.Format) assertRouteFields(t, updatedRoute, s.RoutePath, s.Image, newRouteType, s.Format)
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
DeleteApp(t, s.Context, s.Client, s.AppName) DeleteApp(t, s.Context, s.Client, s.AppName)
}) })
} }