mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fix uuid & fix tests
This commit is contained in:
@@ -2,6 +2,7 @@ package runner
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -21,6 +22,7 @@ func TestRunnerHello(t *testing.T) {
|
||||
{&models.Route{Image: "iron/hello"}, `{"name": "test"}`, "success", "Hello test!", ""},
|
||||
} {
|
||||
runner := New(&Config{
|
||||
ID: fmt.Sprintf("task-hello-%d-%d", i, time.Now().Unix()),
|
||||
Ctx: context.Background(),
|
||||
Route: test.route,
|
||||
Timeout: 5 * time.Second,
|
||||
@@ -57,6 +59,7 @@ func TestRunnerError(t *testing.T) {
|
||||
{&models.Route{Image: "iron/error"}, `{"name": "test"}`, "error", "", "RuntimeError"},
|
||||
} {
|
||||
runner := New(&Config{
|
||||
ID: fmt.Sprintf("task-error-%d-%d", i, time.Now().Unix()),
|
||||
Ctx: context.Background(),
|
||||
Route: test.route,
|
||||
Timeout: 5 * time.Second,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -23,7 +24,7 @@ func handleRunner(c *gin.Context) {
|
||||
|
||||
log := c.MustGet("log").(logrus.FieldLogger)
|
||||
|
||||
reqID := uuid.NewV5(uuid.Nil, c.Request.RemoteAddr+c.Request.URL.Path).String()
|
||||
reqID := uuid.NewV5(uuid.Nil, fmt.Sprintf("%s%s%d", c.Request.RemoteAddr, c.Request.URL.Path, time.Now().Unix())).String()
|
||||
c.Set("reqID", reqID)
|
||||
|
||||
log = log.WithFields(logrus.Fields{"request_id": reqID})
|
||||
@@ -81,7 +82,6 @@ func handleRunner(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.WithField("routes", routes).Debug("Got routes from datastore")
|
||||
|
||||
for _, el := range routes {
|
||||
if el.Path == route {
|
||||
run := runner.New(&runner.Config{
|
||||
|
||||
Reference in New Issue
Block a user