mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-07 16:44:25 +01:00
Rename database package to sqlite
This commit is contained in:
parent
aac72e3741
commit
c700154f5e
@ -6,8 +6,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/TwinProduction/gatus/storage/store"
|
"github.com/TwinProduction/gatus/storage/store"
|
||||||
"github.com/TwinProduction/gatus/storage/store/database"
|
|
||||||
"github.com/TwinProduction/gatus/storage/store/memory"
|
"github.com/TwinProduction/gatus/storage/store/memory"
|
||||||
|
"github.com/TwinProduction/gatus/storage/store/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -53,7 +53,7 @@ func Initialize(cfg *Config) error {
|
|||||||
ctx, cancelFunc = context.WithCancel(context.Background())
|
ctx, cancelFunc = context.WithCancel(context.Background())
|
||||||
switch cfg.Type {
|
switch cfg.Type {
|
||||||
case TypeSQLite:
|
case TypeSQLite:
|
||||||
provider, err = database.NewStore(string(cfg.Type), cfg.File)
|
provider, err = sqlite.NewStore(string(cfg.Type), cfg.File)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/TwinProduction/gatus/storage/store/database"
|
"github.com/TwinProduction/gatus/storage/store/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInitialize(t *testing.T) {
|
func TestInitialize(t *testing.T) {
|
||||||
@ -38,7 +38,7 @@ func TestInitialize(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Name: "sqlite-no-file",
|
Name: "sqlite-no-file",
|
||||||
Cfg: &Config{Type: TypeSQLite},
|
Cfg: &Config{Type: TypeSQLite},
|
||||||
ExpectedErr: database.ErrFilePathNotSpecified,
|
ExpectedErr: sqlite.ErrFilePathNotSpecified,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "sqlite-with-file",
|
Name: "sqlite-with-file",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package database
|
package sqlite
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
@ -222,7 +222,7 @@ func (s *Store) Insert(service *core.Service, result *core.Result) {
|
|||||||
// based on result.Success.
|
// based on result.Success.
|
||||||
numberOfEvents, err := s.getNumberOfEventsByServiceID(tx, serviceID)
|
numberOfEvents, err := s.getNumberOfEventsByServiceID(tx, serviceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[database][Insert] Failed to retrieve total number of events for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
log.Printf("[sqlite][Insert] Failed to retrieve total number of events for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
||||||
}
|
}
|
||||||
if numberOfEvents == 0 {
|
if numberOfEvents == 0 {
|
||||||
// There's no events yet, which means we need to add the EventStart and the first healthy/unhealthy event
|
// There's no events yet, which means we need to add the EventStart and the first healthy/unhealthy event
|
||||||
@ -232,18 +232,18 @@ func (s *Store) Insert(service *core.Service, result *core.Result) {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Silently fail
|
// Silently fail
|
||||||
log.Printf("[database][Insert] Failed to insert event=%s for group=%s; service=%s: %s", core.EventStart, service.Group, service.Name, err.Error())
|
log.Printf("[sqlite][Insert] Failed to insert event=%s for group=%s; service=%s: %s", core.EventStart, service.Group, service.Name, err.Error())
|
||||||
}
|
}
|
||||||
event := core.NewEventFromResult(result)
|
event := core.NewEventFromResult(result)
|
||||||
if err = s.insertEvent(tx, serviceID, event); err != nil {
|
if err = s.insertEvent(tx, serviceID, event); err != nil {
|
||||||
// Silently fail
|
// Silently fail
|
||||||
log.Printf("[database][Insert] Failed to insert event=%s for group=%s; service=%s: %s", event.Type, service.Group, service.Name, err.Error())
|
log.Printf("[sqlite][Insert] Failed to insert event=%s for group=%s; service=%s: %s", event.Type, service.Group, service.Name, err.Error())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Get the success value of the previous result
|
// Get the success value of the previous result
|
||||||
var lastResultSuccess bool
|
var lastResultSuccess bool
|
||||||
if lastResultSuccess, err = s.getLastServiceResultSuccessValue(tx, serviceID); err != nil {
|
if lastResultSuccess, err = s.getLastServiceResultSuccessValue(tx, serviceID); err != nil {
|
||||||
log.Printf("[database][Insert] Failed to retrieve outcome of previous result for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
log.Printf("[sqlite][Insert] Failed to retrieve outcome of previous result for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
||||||
} else {
|
} else {
|
||||||
// If we managed to retrieve the outcome of the previous result, we'll compare it with the new result.
|
// If we managed to retrieve the outcome of the previous result, we'll compare it with the new result.
|
||||||
// If the final outcome (success or failure) of the previous and the new result aren't the same, it means
|
// If the final outcome (success or failure) of the previous and the new result aren't the same, it means
|
||||||
@ -253,7 +253,7 @@ func (s *Store) Insert(service *core.Service, result *core.Result) {
|
|||||||
event := core.NewEventFromResult(result)
|
event := core.NewEventFromResult(result)
|
||||||
if err = s.insertEvent(tx, serviceID, event); err != nil {
|
if err = s.insertEvent(tx, serviceID, event); err != nil {
|
||||||
// Silently fail
|
// Silently fail
|
||||||
log.Printf("[database][Insert] Failed to insert event=%s for group=%s; service=%s: %s", event.Type, service.Group, service.Name, err.Error())
|
log.Printf("[sqlite][Insert] Failed to insert event=%s for group=%s; service=%s: %s", event.Type, service.Group, service.Name, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,44 +262,44 @@ func (s *Store) Insert(service *core.Service, result *core.Result) {
|
|||||||
// (since we're only deleting MaximumNumberOfEvents at a time instead of 1)
|
// (since we're only deleting MaximumNumberOfEvents at a time instead of 1)
|
||||||
if numberOfEvents > eventsCleanUpThreshold {
|
if numberOfEvents > eventsCleanUpThreshold {
|
||||||
if err = s.deleteOldServiceEvents(tx, serviceID); err != nil {
|
if err = s.deleteOldServiceEvents(tx, serviceID); err != nil {
|
||||||
log.Printf("[database][Insert] Failed to delete old events for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
log.Printf("[sqlite][Insert] Failed to delete old events for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Second, we need to insert the result.
|
// Second, we need to insert the result.
|
||||||
if err = s.insertResult(tx, serviceID, result); err != nil {
|
if err = s.insertResult(tx, serviceID, result); err != nil {
|
||||||
log.Printf("[database][Insert] Failed to insert result for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
log.Printf("[sqlite][Insert] Failed to insert result for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
||||||
_ = tx.Rollback() // If we can't insert the result, we'll rollback now since there's no point continuing
|
_ = tx.Rollback() // If we can't insert the result, we'll rollback now since there's no point continuing
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Clean up old results
|
// Clean up old results
|
||||||
numberOfResults, err := s.getNumberOfResultsByServiceID(tx, serviceID)
|
numberOfResults, err := s.getNumberOfResultsByServiceID(tx, serviceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[database][Insert] Failed to retrieve total number of results for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
log.Printf("[sqlite][Insert] Failed to retrieve total number of results for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
||||||
} else {
|
} else {
|
||||||
if numberOfResults > resultsCleanUpThreshold {
|
if numberOfResults > resultsCleanUpThreshold {
|
||||||
if err = s.deleteOldServiceResults(tx, serviceID); err != nil {
|
if err = s.deleteOldServiceResults(tx, serviceID); err != nil {
|
||||||
log.Printf("[database][Insert] Failed to delete old results for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
log.Printf("[sqlite][Insert] Failed to delete old results for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Finally, we need to insert the uptime data.
|
// Finally, we need to insert the uptime data.
|
||||||
// Because the uptime data significantly outlives the results, we can't rely on the results for determining the uptime
|
// Because the uptime data significantly outlives the results, we can't rely on the results for determining the uptime
|
||||||
if err = s.updateServiceUptime(tx, serviceID, result); err != nil {
|
if err = s.updateServiceUptime(tx, serviceID, result); err != nil {
|
||||||
log.Printf("[database][Insert] Failed to update uptime for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
log.Printf("[sqlite][Insert] Failed to update uptime for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
||||||
}
|
}
|
||||||
// Clean up old uptime entries
|
// Clean up old uptime entries
|
||||||
ageOfOldestUptimeEntry, err := s.getAgeOfOldestServiceUptimeEntry(tx, serviceID)
|
ageOfOldestUptimeEntry, err := s.getAgeOfOldestServiceUptimeEntry(tx, serviceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[database][Insert] Failed to retrieve oldest service uptime entry for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
log.Printf("[sqlite][Insert] Failed to retrieve oldest service uptime entry for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
||||||
} else {
|
} else {
|
||||||
if ageOfOldestUptimeEntry > uptimeCleanUpThreshold {
|
if ageOfOldestUptimeEntry > uptimeCleanUpThreshold {
|
||||||
if err = s.deleteOldUptimeEntries(tx, serviceID, time.Now().Add(-(uptimeRetention + time.Hour))); err != nil {
|
if err = s.deleteOldUptimeEntries(tx, serviceID, time.Now().Add(-(uptimeRetention + time.Hour))); err != nil {
|
||||||
log.Printf("[database][Insert] Failed to delete old uptime entries for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
log.Printf("[sqlite][Insert] Failed to delete old uptime entries for group=%s; service=%s: %s", service.Group, service.Name, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//log.Printf("[database][Insert] Successfully inserted result in duration=%dns", time.Since(start).Nanoseconds())
|
//log.Printf("[sqlite][Insert] Successfully inserted result in duration=%dns", time.Since(start).Nanoseconds())
|
||||||
if err = tx.Commit(); err != nil {
|
if err = tx.Commit(); err != nil {
|
||||||
_ = tx.Rollback()
|
_ = tx.Rollback()
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ func (s *Store) DeleteAllServiceStatusesNotInKeys(keys []string) int {
|
|||||||
result, err = s.db.Exec(fmt.Sprintf("DELETE FROM service WHERE service_key NOT IN (%s)", strings.Trim(strings.Repeat("?,", len(keys)), ",")), args...)
|
result, err = s.db.Exec(fmt.Sprintf("DELETE FROM service WHERE service_key NOT IN (%s)", strings.Trim(strings.Repeat("?,", len(keys)), ",")), args...)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[database][DeleteAllServiceStatusesNotInKeys] Failed to delete rows that do not belong to any of keys=%v: %s", keys, err.Error())
|
log.Printf("[sqlite][DeleteAllServiceStatusesNotInKeys] Failed to delete rows that do not belong to any of keys=%v: %s", keys, err.Error())
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
rowsAffects, _ := result.RowsAffected()
|
rowsAffects, _ := result.RowsAffected()
|
||||||
@ -345,7 +345,7 @@ func (s *Store) Close() {
|
|||||||
|
|
||||||
// insertService inserts a service in the store and returns the generated id of said service
|
// insertService inserts a service in the store and returns the generated id of said service
|
||||||
func (s *Store) insertService(tx *sql.Tx, service *core.Service) (int64, error) {
|
func (s *Store) insertService(tx *sql.Tx, service *core.Service) (int64, error) {
|
||||||
//log.Printf("[database][insertService] Inserting service with group=%s and name=%s", service.Group, service.Name)
|
//log.Printf("[sqlite][insertService] Inserting service with group=%s and name=%s", service.Group, service.Name)
|
||||||
result, err := tx.Exec(
|
result, err := tx.Exec(
|
||||||
"INSERT INTO service (service_key, service_name, service_group) VALUES ($1, $2, $3)",
|
"INSERT INTO service (service_key, service_name, service_group) VALUES ($1, $2, $3)",
|
||||||
service.Key(),
|
service.Key(),
|
||||||
@ -465,12 +465,12 @@ func (s *Store) getServiceStatusByKey(tx *sql.Tx, key string, parameters *paging
|
|||||||
serviceStatus := core.NewServiceStatus(key, serviceGroup, serviceName)
|
serviceStatus := core.NewServiceStatus(key, serviceGroup, serviceName)
|
||||||
if parameters.EventsPageSize > 0 {
|
if parameters.EventsPageSize > 0 {
|
||||||
if serviceStatus.Events, err = s.getEventsByServiceID(tx, serviceID, parameters.EventsPage, parameters.EventsPageSize); err != nil {
|
if serviceStatus.Events, err = s.getEventsByServiceID(tx, serviceID, parameters.EventsPage, parameters.EventsPageSize); err != nil {
|
||||||
log.Printf("[database][getServiceStatusByKey] Failed to retrieve events for key=%s: %s", key, err.Error())
|
log.Printf("[sqlite][getServiceStatusByKey] Failed to retrieve events for key=%s: %s", key, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if parameters.ResultsPageSize > 0 {
|
if parameters.ResultsPageSize > 0 {
|
||||||
if serviceStatus.Results, err = s.getResultsByServiceID(tx, serviceID, parameters.ResultsPage, parameters.ResultsPageSize); err != nil {
|
if serviceStatus.Results, err = s.getResultsByServiceID(tx, serviceID, parameters.ResultsPage, parameters.ResultsPageSize); err != nil {
|
||||||
log.Printf("[database][getServiceStatusByKey] Failed to retrieve results for key=%s: %s", key, err.Error())
|
log.Printf("[sqlite][getServiceStatusByKey] Failed to retrieve results for key=%s: %s", key, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if parameters.IncludeUptime {
|
if parameters.IncludeUptime {
|
@ -1,4 +1,4 @@
|
|||||||
package database
|
package sqlite
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
@ -2,9 +2,9 @@ package store
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TwinProduction/gatus/core"
|
"github.com/TwinProduction/gatus/core"
|
||||||
"github.com/TwinProduction/gatus/storage/store/database"
|
|
||||||
"github.com/TwinProduction/gatus/storage/store/memory"
|
"github.com/TwinProduction/gatus/storage/store/memory"
|
||||||
"github.com/TwinProduction/gatus/storage/store/paging"
|
"github.com/TwinProduction/gatus/storage/store/paging"
|
||||||
|
"github.com/TwinProduction/gatus/storage/store/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Store is the interface that each stores should implement
|
// Store is the interface that each stores should implement
|
||||||
@ -43,5 +43,5 @@ type Store interface {
|
|||||||
var (
|
var (
|
||||||
// Validate interface implementation on compile
|
// Validate interface implementation on compile
|
||||||
_ Store = (*memory.Store)(nil)
|
_ Store = (*memory.Store)(nil)
|
||||||
_ Store = (*database.Store)(nil)
|
_ Store = (*sqlite.Store)(nil)
|
||||||
)
|
)
|
||||||
|
@ -5,9 +5,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/TwinProduction/gatus/core"
|
"github.com/TwinProduction/gatus/core"
|
||||||
"github.com/TwinProduction/gatus/storage/store/database"
|
|
||||||
"github.com/TwinProduction/gatus/storage/store/memory"
|
"github.com/TwinProduction/gatus/storage/store/memory"
|
||||||
"github.com/TwinProduction/gatus/storage/store/paging"
|
"github.com/TwinProduction/gatus/storage/store/paging"
|
||||||
|
"github.com/TwinProduction/gatus/storage/store/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BenchmarkStore_GetAllServiceStatuses(b *testing.B) {
|
func BenchmarkStore_GetAllServiceStatuses(b *testing.B) {
|
||||||
@ -15,11 +15,11 @@ func BenchmarkStore_GetAllServiceStatuses(b *testing.B) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal("failed to create store:", err.Error())
|
b.Fatal("failed to create store:", err.Error())
|
||||||
}
|
}
|
||||||
databaseStore, err := database.NewStore("sqlite", b.TempDir()+"/BenchmarkStore_GetAllServiceStatuses.db")
|
sqliteStore, err := sqlite.NewStore("sqlite", b.TempDir()+"/BenchmarkStore_GetAllServiceStatuses.db")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal("failed to create store:", err.Error())
|
b.Fatal("failed to create store:", err.Error())
|
||||||
}
|
}
|
||||||
defer databaseStore.Close()
|
defer sqliteStore.Close()
|
||||||
type Scenario struct {
|
type Scenario struct {
|
||||||
Name string
|
Name string
|
||||||
Store Store
|
Store Store
|
||||||
@ -37,13 +37,13 @@ func BenchmarkStore_GetAllServiceStatuses(b *testing.B) {
|
|||||||
Parallel: true,
|
Parallel: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "database",
|
Name: "sqlite",
|
||||||
Store: databaseStore,
|
Store: sqliteStore,
|
||||||
Parallel: false,
|
Parallel: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "database-parallel",
|
Name: "sqlite-parallel",
|
||||||
Store: databaseStore,
|
Store: sqliteStore,
|
||||||
Parallel: true,
|
Parallel: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -73,11 +73,11 @@ func BenchmarkStore_Insert(b *testing.B) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal("failed to create store:", err.Error())
|
b.Fatal("failed to create store:", err.Error())
|
||||||
}
|
}
|
||||||
databaseStore, err := database.NewStore("sqlite", b.TempDir()+"/BenchmarkStore_Insert.db")
|
sqliteStore, err := sqlite.NewStore("sqlite", b.TempDir()+"/BenchmarkStore_Insert.db")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal("failed to create store:", err.Error())
|
b.Fatal("failed to create store:", err.Error())
|
||||||
}
|
}
|
||||||
defer databaseStore.Close()
|
defer sqliteStore.Close()
|
||||||
type Scenario struct {
|
type Scenario struct {
|
||||||
Name string
|
Name string
|
||||||
Store Store
|
Store Store
|
||||||
@ -95,13 +95,13 @@ func BenchmarkStore_Insert(b *testing.B) {
|
|||||||
Parallel: true,
|
Parallel: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "database",
|
Name: "sqlite",
|
||||||
Store: databaseStore,
|
Store: sqliteStore,
|
||||||
Parallel: false,
|
Parallel: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "database-parallel",
|
Name: "sqlite-parallel",
|
||||||
Store: databaseStore,
|
Store: sqliteStore,
|
||||||
Parallel: false,
|
Parallel: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -145,11 +145,11 @@ func BenchmarkStore_GetServiceStatusByKey(b *testing.B) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal("failed to create store:", err.Error())
|
b.Fatal("failed to create store:", err.Error())
|
||||||
}
|
}
|
||||||
databaseStore, err := database.NewStore("sqlite", b.TempDir()+"/BenchmarkStore_GetServiceStatusByKey.db")
|
sqliteStore, err := sqlite.NewStore("sqlite", b.TempDir()+"/BenchmarkStore_GetServiceStatusByKey.db")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal("failed to create store:", err.Error())
|
b.Fatal("failed to create store:", err.Error())
|
||||||
}
|
}
|
||||||
defer databaseStore.Close()
|
defer sqliteStore.Close()
|
||||||
type Scenario struct {
|
type Scenario struct {
|
||||||
Name string
|
Name string
|
||||||
Store Store
|
Store Store
|
||||||
@ -167,13 +167,13 @@ func BenchmarkStore_GetServiceStatusByKey(b *testing.B) {
|
|||||||
Parallel: true,
|
Parallel: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "database",
|
Name: "sqlite",
|
||||||
Store: databaseStore,
|
Store: sqliteStore,
|
||||||
Parallel: false,
|
Parallel: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "database-parallel",
|
Name: "sqlite-parallel",
|
||||||
Store: databaseStore,
|
Store: sqliteStore,
|
||||||
Parallel: true,
|
Parallel: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/TwinProduction/gatus/core"
|
"github.com/TwinProduction/gatus/core"
|
||||||
"github.com/TwinProduction/gatus/storage/store/database"
|
|
||||||
"github.com/TwinProduction/gatus/storage/store/memory"
|
"github.com/TwinProduction/gatus/storage/store/memory"
|
||||||
"github.com/TwinProduction/gatus/storage/store/paging"
|
"github.com/TwinProduction/gatus/storage/store/paging"
|
||||||
|
"github.com/TwinProduction/gatus/storage/store/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -92,7 +92,7 @@ func initStoresAndBaseScenarios(t *testing.T, testName string) []*Scenario {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("failed to create store:", err.Error())
|
t.Fatal("failed to create store:", err.Error())
|
||||||
}
|
}
|
||||||
databaseStore, err := database.NewStore("sqlite", t.TempDir()+"/"+testName+".db")
|
sqliteStore, err := sqlite.NewStore("sqlite", t.TempDir()+"/"+testName+".db")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("failed to create store:", err.Error())
|
t.Fatal("failed to create store:", err.Error())
|
||||||
}
|
}
|
||||||
@ -102,8 +102,8 @@ func initStoresAndBaseScenarios(t *testing.T, testName string) []*Scenario {
|
|||||||
Store: memoryStore,
|
Store: memoryStore,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "database",
|
Name: "sqlite",
|
||||||
Store: databaseStore,
|
Store: sqliteStore,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user