mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
datastore no longer implements logstore (#1013)
* datastore no longer implements logstore the underlying implementation of our sql store implements both the datastore and the logstore interface, however going forward we are likely to encounter datastore implementers that would mock out the logstore interface and not use its methods - signalling a poor interface. this remedies that, now they are 2 completely separate things, which our sqlstore happens to implement both of. related to some recent changes around wrapping, this keeps the imposed metrics and validation wrapping of a servers logstore and datastore, just moving it into New instead of in the opts - this is so that a user can have the underlying datastore in order to set the logstore to it, since wrapping it in a validator/metrics would render it no longer a logstore implementer (i.e. validate datastore doesn't implement the logstore interface), we need to do this after setting the logstore to the datastore if one wasn't provided explicitly. * splits logstore and datastore metrics & validation logic * `make test` should be `make full-test` always. got rid of that so that nobody else has to wait for CI to blow up on them after the tests pass locally ever again. * fix new tests
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
"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/sirupsen/logrus"
|
||||
@@ -99,8 +100,9 @@ func TestCallConfigurationRequest(t *testing.T) {
|
||||
},
|
||||
},
|
||||
)
|
||||
ls := logs.NewMock()
|
||||
|
||||
a := New(NewDirectDataAccess(ds, ds, new(mqs.Mock)))
|
||||
a := New(NewDirectDataAccess(ds, ls, new(mqs.Mock)))
|
||||
defer checkClose(t, a)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
@@ -242,8 +244,9 @@ func TestCallConfigurationModel(t *testing.T) {
|
||||
|
||||
// FromModel doesn't need a datastore, for now...
|
||||
ds := datastore.NewMockInit()
|
||||
ls := logs.NewMock()
|
||||
|
||||
a := New(NewDirectDataAccess(ds, ds, new(mqs.Mock)))
|
||||
a := New(NewDirectDataAccess(ds, ls, new(mqs.Mock)))
|
||||
defer checkClose(t, a)
|
||||
|
||||
callI, err := a.GetCall(FromModel(cm))
|
||||
@@ -313,8 +316,9 @@ func TestAsyncCallHeaders(t *testing.T) {
|
||||
|
||||
// FromModel doesn't need a datastore, for now...
|
||||
ds := datastore.NewMockInit()
|
||||
ls := logs.NewMock()
|
||||
|
||||
a := New(NewDirectDataAccess(ds, ds, new(mqs.Mock)))
|
||||
a := New(NewDirectDataAccess(ds, ls, new(mqs.Mock)))
|
||||
defer checkClose(t, a)
|
||||
|
||||
callI, err := a.GetCall(FromModel(cm))
|
||||
@@ -439,8 +443,9 @@ func TestReqTooLarge(t *testing.T) {
|
||||
}
|
||||
|
||||
cfg.MaxRequestSize = 5
|
||||
ls := logs.NewMock()
|
||||
|
||||
a := New(NewDirectDataAccess(ds, ds, new(mqs.Mock)), WithConfig(cfg))
|
||||
a := New(NewDirectDataAccess(ds, ls, new(mqs.Mock)), WithConfig(cfg))
|
||||
defer checkClose(t, a)
|
||||
|
||||
_, err = a.GetCall(FromModel(cm))
|
||||
@@ -492,8 +497,9 @@ func TestSubmitError(t *testing.T) {
|
||||
|
||||
// FromModel doesn't need a datastore, for now...
|
||||
ds := datastore.NewMockInit()
|
||||
ls := logs.NewMock()
|
||||
|
||||
a := New(NewDirectDataAccess(ds, ds, new(mqs.Mock)))
|
||||
a := New(NewDirectDataAccess(ds, ls, new(mqs.Mock)))
|
||||
defer checkClose(t, a)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
@@ -560,7 +566,8 @@ func TestHTTPWithoutContentLengthWorks(t *testing.T) {
|
||||
},
|
||||
)
|
||||
|
||||
a := New(NewDirectDataAccess(ds, ds, new(mqs.Mock)))
|
||||
ls := logs.NewMock()
|
||||
a := New(NewDirectDataAccess(ds, ls, new(mqs.Mock)))
|
||||
defer checkClose(t, a)
|
||||
|
||||
bodOne := `{"echoContent":"yodawg"}`
|
||||
@@ -623,7 +630,8 @@ func TestGetCallReturnsResourceImpossibility(t *testing.T) {
|
||||
// FromModel doesn't need a datastore, for now...
|
||||
ds := datastore.NewMockInit()
|
||||
|
||||
a := New(NewCachedDataAccess(NewDirectDataAccess(ds, ds, new(mqs.Mock))))
|
||||
ls := logs.NewMock()
|
||||
a := New(NewCachedDataAccess(NewDirectDataAccess(ds, ls, new(mqs.Mock))))
|
||||
defer checkClose(t, a)
|
||||
|
||||
_, err := a.GetCall(FromModel(call))
|
||||
@@ -659,7 +667,8 @@ func TestTmpFsRW(t *testing.T) {
|
||||
},
|
||||
)
|
||||
|
||||
a := New(NewDirectDataAccess(ds, ds, new(mqs.Mock)))
|
||||
ls := logs.NewMock()
|
||||
a := New(NewDirectDataAccess(ds, ls, new(mqs.Mock)))
|
||||
defer checkClose(t, a)
|
||||
|
||||
// Here we tell fn-test-utils to read file /proc/mounts and create a /tmp/salsa of 4MB
|
||||
@@ -763,7 +772,8 @@ func TestTmpFsSize(t *testing.T) {
|
||||
|
||||
cfg.MaxTmpFsInodes = 1024
|
||||
|
||||
a := New(NewDirectDataAccess(ds, ds, new(mqs.Mock)), WithConfig(cfg))
|
||||
ls := logs.NewMock()
|
||||
a := New(NewDirectDataAccess(ds, ls, new(mqs.Mock)), WithConfig(cfg))
|
||||
defer checkClose(t, a)
|
||||
|
||||
// Here we tell fn-test-utils to read file /proc/mounts and create a /tmp/salsa of 4MB
|
||||
@@ -932,7 +942,8 @@ func TestPipesAreClear(t *testing.T) {
|
||||
},
|
||||
)
|
||||
|
||||
a := New(NewDirectDataAccess(ds, ds, new(mqs.Mock)))
|
||||
ls := logs.NewMock()
|
||||
a := New(NewDirectDataAccess(ds, ls, new(mqs.Mock)))
|
||||
defer checkClose(t, a)
|
||||
|
||||
// test read this body after 5s (after call times out) and make sure we don't get yodawg
|
||||
@@ -1082,7 +1093,8 @@ func TestPipesDontMakeSpuriousCalls(t *testing.T) {
|
||||
},
|
||||
)
|
||||
|
||||
a := New(NewDirectDataAccess(ds, ds, new(mqs.Mock)))
|
||||
ls := logs.NewMock()
|
||||
a := New(NewDirectDataAccess(ds, ls, new(mqs.Mock)))
|
||||
defer checkClose(t, a)
|
||||
|
||||
bodOne := `{"echoContent":"yodawg"}`
|
||||
@@ -1188,7 +1200,8 @@ func TestNBIOResourceTracker(t *testing.T) {
|
||||
cfg.MaxTotalMemory = 280 * 1024 * 1024
|
||||
cfg.HotPoll = 20 * time.Millisecond
|
||||
|
||||
a := New(NewDirectDataAccess(ds, ds, new(mqs.Mock)), WithConfig(cfg))
|
||||
ls := logs.NewMock()
|
||||
a := New(NewDirectDataAccess(ds, ls, new(mqs.Mock)), WithConfig(cfg))
|
||||
defer checkClose(t, a)
|
||||
|
||||
reqCount := 20
|
||||
@@ -1248,8 +1261,9 @@ type closingDataAccess struct {
|
||||
|
||||
func newClosingDataAccess(closeReturn error) *closingDataAccess {
|
||||
ds := datastore.NewMockInit()
|
||||
ls := logs.NewMock()
|
||||
return &closingDataAccess{
|
||||
DataAccess: NewDirectDataAccess(ds, ds, new(mqs.Mock)),
|
||||
DataAccess: NewDirectDataAccess(ds, ls, new(mqs.Mock)),
|
||||
closed: make(chan struct{}),
|
||||
closeReturn: closeReturn,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user