Bye bye openapi (#1081)

* add DateTime sans mgo

* change all uses of strfmt.DateTime to common.DateTime, remove test strfmt usage

* remove api tests, system-test dep on api test

multiple reasons to remove the api tests:

* awkward dependency with fn_go meant generating bindings on a branched fn to
vendor those to test new stuff. this is at a minimum not at all intuitive,
worth it, nor a fun way to spend the finite amount of time we have to live.
* api tests only tested a subset of functionality that the server/ api tests
already test, and we risk having tests where one tests some thing and the
other doesn't. let's not. we have too many test suites as it is, and these
pretty much only test that we updated the fn_go bindings, which is actually a
hassle as noted above and the cli will pretty quickly figure out anyway.
* fn_go relies on openapi, which relies on mgo, which is deprecated and we'd
like to remove as a dependency. openapi is a _huge_ dep built in a NIH
fashion, that cannot simply remove the mgo dep as users may be using it.
we've now stolen their date time and otherwise killed usage of it in fn core,
for fn_go it still exists but that's less of a problem.

* update deps

removals:

* easyjson
* mgo
* go-openapi
* mapstructure
* fn_go
* purell
* go-validator

also, had to lock docker. we shouldn't use docker on master anyway, they
strongly advise against that. had no luck with latest version rev, so i locked
it to what we were using before. until next time.

the rest is just playing dep roulette, those end up removing a ton tho

* fix exec test to work

* account for john le cache
This commit is contained in:
Reed Allman
2018-06-21 11:09:16 -07:00
committed by GitHub
parent aa5d7169f4
commit 51ff7caeb2
2635 changed files with 440440 additions and 402994 deletions

View File

@@ -18,7 +18,6 @@ import (
"github.com/fnproject/fn/api/id"
"github.com/fnproject/fn/api/models"
"github.com/fnproject/fn/fnext"
"github.com/go-openapi/strfmt"
"github.com/sirupsen/logrus"
"go.opencensus.io/stats"
"go.opencensus.io/trace"
@@ -804,7 +803,7 @@ func (a *agent) prepCold(ctx context.Context, call *call, tok ResourceToken, ch
deadline := time.Now().Add(time.Duration(call.Timeout) * time.Second)
// add Fn-specific information to the config to shove everything into env vars for cold
call.Config["FN_DEADLINE"] = strfmt.DateTime(deadline).String()
call.Config["FN_DEADLINE"] = common.DateTime(deadline).String()
call.Config["FN_METHOD"] = call.Model().Method
call.Config["FN_REQUEST_URL"] = call.Model().URL
call.Config["FN_CALL_ID"] = call.Model().ID

View File

@@ -16,7 +16,6 @@ import (
"github.com/fnproject/fn/api/common"
"github.com/fnproject/fn/api/id"
"github.com/fnproject/fn/api/models"
"github.com/go-openapi/strfmt"
"github.com/sirupsen/logrus"
)
@@ -128,7 +127,7 @@ func FromRequest(a Agent, app *models.App, path string, req *http.Request) CallO
Config: buildConfig(app, route),
Annotations: buildAnnotations(app, route),
Headers: req.Header,
CreatedAt: strfmt.DateTime(time.Now()),
CreatedAt: common.DateTime(time.Now()),
URL: reqURL(req),
Method: req.Method,
AppID: app.ID,
@@ -373,7 +372,7 @@ func (c *call) Start(ctx context.Context) error {
return ctx.Err()
}
c.StartedAt = strfmt.DateTime(time.Now())
c.StartedAt = common.DateTime(time.Now())
c.Status = "running"
if !c.isLB {
@@ -411,7 +410,7 @@ func (c *call) End(ctx context.Context, errIn error) error {
ctx, span := trace.StartSpan(ctx, "agent_call_end")
defer span.End()
c.CompletedAt = strfmt.DateTime(time.Now())
c.CompletedAt = common.DateTime(time.Now())
switch errIn {
case nil:

View File

@@ -22,7 +22,6 @@ import (
"github.com/fnproject/fn/api/common"
"github.com/fnproject/fn/api/models"
"github.com/fsouza/go-dockerclient"
"github.com/go-openapi/strfmt"
"github.com/sirupsen/logrus"
)
@@ -536,7 +535,7 @@ func cherryPick(ds *docker.Stats) drivers.Stat {
}
return drivers.Stat{
Timestamp: strfmt.DateTime(ds.Read),
Timestamp: common.DateTime(ds.Read),
Metrics: map[string]uint64{
// source: https://godoc.org/github.com/fsouza/go-dockerclient#Stats
// ex (for future expansion): {"read":"2016-08-03T18:08:05Z","pids_stats":{},"network":{},"networks":{"eth0":{"rx_bytes":508,"tx_packets":6,"rx_packets":6,"tx_bytes":508}},"memory_stats":{"stats":{"cache":16384,"pgpgout":281,"rss":8826880,"pgpgin":2440,"total_rss":8826880,"hierarchical_memory_limit":536870912,"total_pgfault":3809,"active_anon":8843264,"total_active_anon":8843264,"total_pgpgout":281,"total_cache":16384,"pgfault":3809,"total_pgpgin":2440},"max_usage":8953856,"usage":8953856,"limit":536870912},"blkio_stats":{"io_service_bytes_recursive":[{"major":202,"op":"Read"},{"major":202,"op":"Write"},{"major":202,"op":"Sync"},{"major":202,"op":"Async"},{"major":202,"op":"Total"}],"io_serviced_recursive":[{"major":202,"op":"Read"},{"major":202,"op":"Write"},{"major":202,"op":"Sync"},{"major":202,"op":"Async"},{"major":202,"op":"Total"}]},"cpu_stats":{"cpu_usage":{"percpu_usage":[47641874],"usage_in_usermode":30000000,"total_usage":47641874},"system_cpu_usage":8880800500000000,"throttling_data":{}},"precpu_stats":{"cpu_usage":{"percpu_usage":[44946186],"usage_in_usermode":30000000,"total_usage":44946186},"system_cpu_usage":8880799510000000,"throttling_data":{}}}

View File

@@ -12,7 +12,7 @@ import (
"strings"
"time"
"github.com/go-openapi/strfmt"
"github.com/fnproject/fn/api/common"
)
// A DriverCookie identifies a unique request to run a task.
@@ -146,7 +146,7 @@ type ContainerTask interface {
// Stat is a bucket of stats from a driver at a point in time for a certain task.
type Stat struct {
Timestamp strfmt.DateTime `json:"timestamp"`
Timestamp common.DateTime `json:"timestamp"`
Metrics map[string]uint64 `json:"metrics"`
}
@@ -237,7 +237,7 @@ func average(samples []Stat) (Stat, bool) {
}
}
s.Timestamp = strfmt.DateTime(time.Unix(0, t))
s.Timestamp = common.DateTime(time.Unix(0, t))
for k, v := range s.Metrics {
s.Metrics[k] = v / uint64(l)
}

View File

@@ -4,7 +4,7 @@ import (
"testing"
"time"
"github.com/go-openapi/strfmt"
"github.com/fnproject/fn/api/common"
)
func TestAverage(t *testing.T) {
@@ -12,7 +12,7 @@ func TestAverage(t *testing.T) {
stats := make([]Stat, 10)
for i := 0; i < len(stats); i++ {
stats[i] = Stat{
Timestamp: strfmt.DateTime(start.Add(time.Duration(i) * time.Minute)),
Timestamp: common.DateTime(start.Add(time.Duration(i) * time.Minute)),
Metrics: map[string]uint64{"x": uint64(i)},
}
}
@@ -38,7 +38,7 @@ func TestDecimate(t *testing.T) {
stats := make([]Stat, 480)
for i := range stats {
stats[i] = Stat{
Timestamp: strfmt.DateTime(start.Add(time.Duration(i) * time.Second)),
Timestamp: common.DateTime(start.Add(time.Duration(i) * time.Second)),
Metrics: map[string]uint64{"x": uint64(i)},
}
}
@@ -55,7 +55,7 @@ func TestDecimate(t *testing.T) {
stats = make([]Stat, 700)
for i := range stats {
stats[i] = Stat{
Timestamp: strfmt.DateTime(start.Add(time.Duration(i) * time.Second)),
Timestamp: common.DateTime(start.Add(time.Duration(i) * time.Second)),
Metrics: map[string]uint64{"x": uint64(i)},
}
}
@@ -67,7 +67,7 @@ func TestDecimate(t *testing.T) {
stats = make([]Stat, 300)
for i := range stats {
stats[i] = Stat{
Timestamp: strfmt.DateTime(start.Add(time.Duration(i) * time.Second)),
Timestamp: common.DateTime(start.Add(time.Duration(i) * time.Second)),
Metrics: map[string]uint64{"x": uint64(i)},
}
}
@@ -83,7 +83,7 @@ func TestDecimate(t *testing.T) {
start = start.Add(20 * time.Minute)
}
stats[i] = Stat{
Timestamp: strfmt.DateTime(start.Add(time.Duration(i) * time.Second)),
Timestamp: common.DateTime(start.Add(time.Duration(i) * time.Second)),
Metrics: map[string]uint64{"x": uint64(i)},
}
}

View File

@@ -9,7 +9,7 @@ import (
"testing"
"time"
"github.com/go-openapi/strfmt"
"github.com/fnproject/fn/api/common"
)
// implements CallInfo, modify as needed
@@ -23,8 +23,8 @@ func (t *testCall) IsCloudEvent() bool { return t.cloud }
func (t *testCall) CallID() string { return "foo" }
func (t *testCall) ContentType() string { return t.contentType }
func (t *testCall) Input() io.Reader { return t.input }
func (t *testCall) Deadline() strfmt.DateTime {
return strfmt.DateTime(time.Now().Add(30 * time.Second))
func (t *testCall) Deadline() common.DateTime {
return common.DateTime(time.Now().Add(30 * time.Second))
}
func (t *testCall) CallType() string { return "sync" }
func (t *testCall) ProtocolType() string { return "http" }

View File

@@ -6,8 +6,8 @@ import (
"io"
"net/http"
"github.com/fnproject/fn/api/common"
"github.com/fnproject/fn/api/models"
"github.com/go-openapi/strfmt"
)
var errInvalidProtocol = errors.New("Invalid Protocol")
@@ -39,7 +39,7 @@ type CallInfo interface {
CallID() string
ContentType() string
Input() io.Reader
Deadline() strfmt.DateTime
Deadline() common.DateTime
CallType() string
// ProtocolType let's function/fdk's know what type original request is. Only 'http' for now.
@@ -75,13 +75,13 @@ func (ci callInfoImpl) Input() io.Reader {
return ci.req.Body
}
func (ci callInfoImpl) Deadline() strfmt.DateTime {
func (ci callInfoImpl) Deadline() common.DateTime {
deadline, ok := ci.req.Context().Deadline()
if !ok {
// In theory deadline must have been set here
panic("No context deadline is set in protocol, should never happen")
}
return strfmt.DateTime(deadline)
return common.DateTime(deadline)
}
// CallType returns whether the function call was "sync" or "async".

View File

@@ -22,7 +22,6 @@ import (
"github.com/fnproject/fn/api/models"
"github.com/fnproject/fn/fnext"
"github.com/fnproject/fn/grpcutil"
"github.com/go-openapi/strfmt"
"github.com/golang/protobuf/ptypes/empty"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
@@ -69,7 +68,7 @@ type callHandle struct {
c *call // the agent's version of call
// Timings, for metrics:
receivedTime strfmt.DateTime // When was the call received?
receivedTime common.DateTime // When was the call received?
// For implementing http.ResponseWriter:
headers http.Header
@@ -525,7 +524,7 @@ func (pr *pureRunner) spawnSubmit(state *callHandle) {
// handleTryCall based on the TryCall message, tries to place the call on NBIO Agent
func (pr *pureRunner) handleTryCall(tc *runner.TryCall, state *callHandle) error {
state.receivedTime = strfmt.DateTime(time.Now())
state.receivedTime = common.DateTime(time.Now())
var c models.Call
err := json.Unmarshal([]byte(tc.ModelsCallJson), &c)
if err != nil {

144
api/common/time.go Normal file
View File

@@ -0,0 +1,144 @@
// Copyright 2015 go-swagger maintainers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ^ we took this from then, and got rid of mgo since it's not a dep of ours.
// we can also change resolution to not be milliseconds. there's your attribution.
package common
import (
"database/sql/driver"
"fmt"
"regexp"
"strings"
"time"
)
// IsDate returns true when the string is a valid date
func IsDate(str string) bool {
_, err := time.Parse(RFC3339FullDate, str)
return err == nil
}
// IsDateTime returns true when the string is a valid date-time
func IsDateTime(str string) bool {
if len(str) < 4 {
return false
}
s := strings.Split(strings.ToLower(str), "t")
if len(s) < 2 || !IsDate(s[0]) {
return false
}
matches := rxDateTime.FindAllStringSubmatch(s[1], -1)
if len(matches) == 0 || len(matches[0]) == 0 {
return false
}
m := matches[0]
res := m[1] <= "23" && m[2] <= "59" && m[3] <= "59"
return res
}
const (
// RFC3339Millis represents a ISO8601 format to millis instead of to nanos
RFC3339Millis = "2006-01-02T15:04:05.000Z07:00"
// RFC3339Micro represents a ISO8601 format to micro instead of to nano
RFC3339Micro = "2006-01-02T15:04:05.000000Z07:00"
// DateTimePattern pattern to match for the date-time format from http://tools.ietf.org/html/rfc3339#section-5.6
DateTimePattern = `^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$`
// RFC3339FullDate represents a full-date as specified by RFC3339
// See: http://goo.gl/xXOvVd
RFC3339FullDate = "2006-01-02"
)
var (
dateTimeFormats = []string{RFC3339Micro, RFC3339Millis, time.RFC3339, time.RFC3339Nano}
rxDateTime = regexp.MustCompile(DateTimePattern)
// MarshalFormat sets the time resolution format used for marshaling time (set to milliseconds)
MarshalFormat = RFC3339Millis
)
// ParseDateTime parses a string that represents an ISO8601 time or a unix epoch
func ParseDateTime(data string) (DateTime, error) {
if data == "" {
return NewDateTime(), nil
}
var lastError error
for _, layout := range dateTimeFormats {
dd, err := time.Parse(layout, data)
if err != nil {
lastError = err
continue
}
lastError = nil
return DateTime(dd), nil
}
return DateTime{}, lastError
}
// DateTime is a time but it serializes to ISO8601 format with millis
// It knows how to read 3 different variations of a RFC3339 date time.
// Most APIs we encounter want either millisecond or second precision times.
// This just tries to make it worry-free.
type DateTime time.Time
// NewDateTime is a representation of zero value for DateTime type
func NewDateTime() DateTime {
return DateTime(time.Unix(0, 0).UTC())
}
// String converts this time to a string
func (t DateTime) String() string {
return time.Time(t).Format(MarshalFormat)
}
// MarshalText implements the text marshaller interface
func (t DateTime) MarshalText() ([]byte, error) {
return []byte(t.String()), nil
}
// UnmarshalText implements the text unmarshaller interface
func (t *DateTime) UnmarshalText(text []byte) error {
tt, err := ParseDateTime(string(text))
if err != nil {
return err
}
*t = tt
return nil
}
// Scan scans a DateTime value from database driver type.
func (t *DateTime) Scan(raw interface{}) error {
// TODO: case int64: and case float64: ?
switch v := raw.(type) {
case []byte:
return t.UnmarshalText(v)
case string:
return t.UnmarshalText([]byte(v))
case time.Time:
*t = DateTime(v)
case nil:
*t = DateTime{}
default:
return fmt.Errorf("cannot sql.Scan() common.DateTime from: %#v", v)
}
return nil
}
// Value converts DateTime to a primitive value ready to written to a database.
func (t DateTime) Value() (driver.Value, error) {
return driver.Value(t.String()), nil
}

View File

@@ -8,9 +8,9 @@ import (
"testing"
"time"
"github.com/fnproject/fn/api/common"
"github.com/fnproject/fn/api/id"
"github.com/fnproject/fn/api/models"
"github.com/go-openapi/strfmt"
)
var testApp = &models.App{
@@ -30,10 +30,10 @@ func SetupTestCall(t *testing.T, ctx context.Context, ls models.LogStore) *model
var call models.Call
call.AppID = testApp.ID
call.CreatedAt = strfmt.DateTime(time.Now())
call.CreatedAt = common.DateTime(time.Now())
call.Status = "success"
call.StartedAt = strfmt.DateTime(time.Now())
call.CompletedAt = strfmt.DateTime(time.Now())
call.StartedAt = common.DateTime(time.Now())
call.CompletedAt = common.DateTime(time.Now())
call.Path = testRoute.Path
return &call
}
@@ -48,7 +48,7 @@ func Test(t *testing.T, fnl models.LogStore) {
t.Run("calls-get", func(t *testing.T) {
filter := &models.CallFilter{AppID: call.AppID, Path: call.Path, PerPage: 100}
now := time.Now()
call.CreatedAt = strfmt.DateTime(now)
call.CreatedAt = common.DateTime(now)
call.ID = id.New().String()
err := fnl.InsertCall(ctx, call)
if err != nil {
@@ -65,11 +65,11 @@ func Test(t *testing.T, fnl models.LogStore) {
c2 := *call
c3 := *call
now = time.Now().Add(100 * time.Millisecond)
c2.CreatedAt = strfmt.DateTime(now) // add ms cuz db uses it for sort
c2.CreatedAt = common.DateTime(now) // add ms cuz db uses it for sort
c2.ID = id.New().String()
now = time.Now().Add(200 * time.Millisecond)
c3.CreatedAt = strfmt.DateTime(now)
c3.CreatedAt = common.DateTime(now)
c3.ID = id.New().String()
err = fnl.InsertCall(ctx, &c2)
@@ -177,11 +177,11 @@ func Test(t *testing.T, fnl models.LogStore) {
})
call = new(models.Call)
call.CreatedAt = strfmt.DateTime(time.Now())
call.CreatedAt = common.DateTime(time.Now())
call.Status = "error"
call.Error = "ya dun goofed"
call.StartedAt = strfmt.DateTime(time.Now())
call.CompletedAt = strfmt.DateTime(time.Now())
call.StartedAt = common.DateTime(time.Now())
call.CompletedAt = common.DateTime(time.Now())
call.AppID = testApp.Name
call.Path = testRoute.Path

View File

@@ -8,8 +8,8 @@ import (
"time"
"unicode"
"github.com/fnproject/fn/api/common"
"github.com/fnproject/fn/api/id"
"github.com/go-openapi/strfmt"
)
type App struct {
@@ -18,16 +18,16 @@ type App struct {
Config Config `json:"config,omitempty" db:"config"`
Annotations Annotations `json:"annotations,omitempty" db:"annotations"`
SyslogURL *string `json:"syslog_url,omitempty" db:"syslog_url"`
CreatedAt strfmt.DateTime `json:"created_at,omitempty" db:"created_at"`
UpdatedAt strfmt.DateTime `json:"updated_at,omitempty" db:"updated_at"`
CreatedAt common.DateTime `json:"created_at,omitempty" db:"created_at"`
UpdatedAt common.DateTime `json:"updated_at,omitempty" db:"updated_at"`
}
func (a *App) SetDefaults() {
if time.Time(a.CreatedAt).IsZero() {
a.CreatedAt = strfmt.DateTime(time.Now())
a.CreatedAt = common.DateTime(time.Now())
}
if time.Time(a.UpdatedAt).IsZero() {
a.UpdatedAt = strfmt.DateTime(time.Now())
a.UpdatedAt = common.DateTime(time.Now())
}
if a.Config == nil {
// keeps the json from being nil
@@ -134,7 +134,7 @@ func (a *App) Update(patch *App) {
a.Annotations = a.Annotations.MergeChange(patch.Annotations)
if !a.Equals(original) {
a.UpdatedAt = strfmt.DateTime(time.Now())
a.UpdatedAt = common.DateTime(time.Now())
}
}

View File

@@ -4,7 +4,7 @@ import (
"net/http"
"github.com/fnproject/fn/api/agent/drivers"
"github.com/go-openapi/strfmt"
"github.com/fnproject/fn/api/common"
)
const (
@@ -132,13 +132,13 @@ type Call struct {
SyslogURL string `json:"syslog_url,omitempty" db:"-"`
// Time when call completed, whether it was successul or failed. Always in UTC.
CompletedAt strfmt.DateTime `json:"completed_at,omitempty" db:"completed_at"`
CompletedAt common.DateTime `json:"completed_at,omitempty" db:"completed_at"`
// Time when call was submitted. Always in UTC.
CreatedAt strfmt.DateTime `json:"created_at,omitempty" db:"created_at"`
CreatedAt common.DateTime `json:"created_at,omitempty" db:"created_at"`
// Time when call started execution. Always in UTC.
StartedAt strfmt.DateTime `json:"started_at,omitempty" db:"started_at"`
StartedAt common.DateTime `json:"started_at,omitempty" db:"started_at"`
// Stats is a list of metrics from this call's execution, possibly empty.
Stats drivers.Stats `json:"stats,omitempty" db:"stats"`
@@ -154,8 +154,8 @@ type Call struct {
type CallFilter struct {
Path string // match
AppID string // match
FromTime strfmt.DateTime
ToTime strfmt.DateTime
FromTime common.DateTime
ToTime common.DateTime
Cursor string
PerPage int
}

View File

@@ -7,7 +7,7 @@ import (
"strings"
"time"
"github.com/go-openapi/strfmt"
"github.com/fnproject/fn/api/common"
)
const (
@@ -38,8 +38,8 @@ type Route struct {
TmpFsSize uint32 `json:"tmpfs_size" db:"tmpfs_size"`
Config Config `json:"config,omitempty" db:"config"`
Annotations Annotations `json:"annotations,omitempty" db:"annotations"`
CreatedAt strfmt.DateTime `json:"created_at,omitempty" db:"created_at"`
UpdatedAt strfmt.DateTime `json:"updated_at,omitempty" db:"updated_at"`
CreatedAt common.DateTime `json:"created_at,omitempty" db:"created_at"`
UpdatedAt common.DateTime `json:"updated_at,omitempty" db:"updated_at"`
}
// SetDefaults sets zeroed field to defaults.
@@ -74,11 +74,11 @@ func (r *Route) SetDefaults() {
}
if time.Time(r.CreatedAt).IsZero() {
r.CreatedAt = strfmt.DateTime(time.Now())
r.CreatedAt = common.DateTime(time.Now())
}
if time.Time(r.UpdatedAt).IsZero() {
r.UpdatedAt = strfmt.DateTime(time.Now())
r.UpdatedAt = common.DateTime(time.Now())
}
}
@@ -243,7 +243,7 @@ func (r *Route) Update(patch *Route) {
r.Annotations = r.Annotations.MergeChange(patch.Annotations)
if !r.Equals(original) {
r.UpdatedAt = strfmt.DateTime(time.Now())
r.UpdatedAt = common.DateTime(time.Now())
}
}

View File

@@ -6,9 +6,9 @@ import (
"time"
"github.com/fnproject/fn/api"
"github.com/fnproject/fn/api/common"
"github.com/fnproject/fn/api/models"
"github.com/gin-gonic/gin"
"github.com/go-openapi/strfmt"
)
func (s *Server) handleCallList(c *gin.Context) {
@@ -42,7 +42,7 @@ func (s *Server) handleCallList(c *gin.Context) {
}
// "" gets parsed to a zero time, which is fine (ignored in query)
func timeParams(c *gin.Context) (fromTime, toTime strfmt.DateTime, err error) {
func timeParams(c *gin.Context) (fromTime, toTime common.DateTime, err error) {
fromStr := c.Query("from_time")
toStr := c.Query("to_time")
var ok bool
@@ -61,10 +61,10 @@ func timeParams(c *gin.Context) (fromTime, toTime strfmt.DateTime, err error) {
return fromTime, toTime, nil
}
func strToTime(str string) (strfmt.DateTime, bool) {
func strToTime(str string) (common.DateTime, bool) {
sec, err := strconv.ParseInt(str, 10, 64)
if err != nil {
return strfmt.DateTime(time.Time{}), false
return common.DateTime(time.Time{}), false
}
return strfmt.DateTime(time.Unix(sec, 0)), true
return common.DateTime(time.Unix(sec, 0)), true
}

View File

@@ -8,12 +8,12 @@ import (
"testing"
"time"
"github.com/fnproject/fn/api/common"
"github.com/fnproject/fn/api/datastore"
"github.com/fnproject/fn/api/id"
"github.com/fnproject/fn/api/logs"
"github.com/fnproject/fn/api/models"
"github.com/fnproject/fn/api/mqs"
"github.com/go-openapi/strfmt"
)
func TestCallGet(t *testing.T) {
@@ -39,7 +39,7 @@ func TestCallGet(t *testing.T) {
Timeout: 30,
IdleTimeout: 30,
Memory: 256,
CreatedAt: strfmt.DateTime(time.Now()),
CreatedAt: common.DateTime(time.Now()),
URL: "http://localhost:8080/r/myapp/thisisatest",
Method: "GET",
}
@@ -110,16 +110,16 @@ func TestCallList(t *testing.T) {
Timeout: 30,
IdleTimeout: 30,
Memory: 256,
CreatedAt: strfmt.DateTime(time.Now()),
CreatedAt: common.DateTime(time.Now()),
URL: "http://localhost:8080/r/myapp/thisisatest",
Method: "GET",
}
c2 := *call
c3 := *call
c2.CreatedAt = strfmt.DateTime(time.Now().Add(100 * time.Second))
c2.CreatedAt = common.DateTime(time.Now().Add(100 * time.Second))
c2.ID = id.New().String()
c2.Path = "test2"
c3.CreatedAt = strfmt.DateTime(time.Now().Add(200 * time.Second))
c3.CreatedAt = common.DateTime(time.Now().Add(200 * time.Second))
c3.ID = id.New().String()
c3.Path = "/test3"

View File

@@ -119,7 +119,7 @@ func (s *Server) handleRunnerStart(c *gin.Context) {
// cover our tracks since if the db is down we can't run anything anyway (treat as such).
// TODO do this client side and validate it here?
//call.Status = "running"
//call.StartedAt = strfmt.DateTime(time.Now())
//call.StartedAt = common.DateTime(time.Now())
//err := s.datastore.UpdateCall(c.Request.Context(), &call)
//if err != nil {
//if err == InvalidStatusChange {