Merge pull request #1077 from mattermost/mark-tests
Marking when user ran the unit tests
Этот коммит содержится в:
@@ -19,6 +19,8 @@ func Setup() {
|
|||||||
StartServer()
|
StartServer()
|
||||||
InitApi()
|
InitApi()
|
||||||
Client = model.NewClient("http://localhost" + utils.Cfg.ServiceSettings.ListenAddress)
|
Client = model.NewClient("http://localhost" + utils.Cfg.ServiceSettings.ListenAddress)
|
||||||
|
|
||||||
|
Srv.Store.MarkSystemRanUnitTests()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,16 +84,16 @@ func securityAndDiagnosticsJob() {
|
|||||||
if *utils.Cfg.ServiceSettings.EnableSecurityFixAlert {
|
if *utils.Cfg.ServiceSettings.EnableSecurityFixAlert {
|
||||||
if result := <-api.Srv.Store.System().Get(); result.Err == nil {
|
if result := <-api.Srv.Store.System().Get(); result.Err == nil {
|
||||||
props := result.Data.(model.StringMap)
|
props := result.Data.(model.StringMap)
|
||||||
lastSecurityTime, _ := strconv.ParseInt(props["LastSecurityTime"], 10, 0)
|
lastSecurityTime, _ := strconv.ParseInt(props[model.SYSTEM_LAST_SECURITY_TIME], 10, 0)
|
||||||
currentTime := model.GetMillis()
|
currentTime := model.GetMillis()
|
||||||
|
|
||||||
if (currentTime - lastSecurityTime) > 1000*60*60*24*1 {
|
if (currentTime - lastSecurityTime) > 1000*60*60*24*1 {
|
||||||
l4g.Debug("Checking for security update from Mattermost")
|
l4g.Debug("Checking for security update from Mattermost")
|
||||||
|
|
||||||
id := props["DiagnosticId"]
|
id := props[model.SYSTEM_DIAGNOSTIC_ID]
|
||||||
if len(id) == 0 {
|
if len(id) == 0 {
|
||||||
id = model.NewId()
|
id = model.NewId()
|
||||||
systemId := &model.System{Name: "DiagnosticId", Value: id}
|
systemId := &model.System{Name: model.SYSTEM_DIAGNOSTIC_ID, Value: id}
|
||||||
<-api.Srv.Store.System().Save(systemId)
|
<-api.Srv.Store.System().Save(systemId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,13 @@ func securityAndDiagnosticsJob() {
|
|||||||
v.Set(utils.PROP_DIAGNOSTIC_OS, runtime.GOOS)
|
v.Set(utils.PROP_DIAGNOSTIC_OS, runtime.GOOS)
|
||||||
v.Set(utils.PROP_DIAGNOSTIC_CATEGORY, utils.VAL_DIAGNOSTIC_CATEGORY_DEFAULT)
|
v.Set(utils.PROP_DIAGNOSTIC_CATEGORY, utils.VAL_DIAGNOSTIC_CATEGORY_DEFAULT)
|
||||||
|
|
||||||
systemSecurityLastTime := &model.System{Name: "LastSecurityTime", Value: strconv.FormatInt(currentTime, 10)}
|
if len(props[model.SYSTEM_RAN_UNIT_TESTS]) > 0 {
|
||||||
|
v.Set(utils.PROP_DIAGNOSTIC_UNIT_TESTS, "1")
|
||||||
|
} else {
|
||||||
|
v.Set(utils.PROP_DIAGNOSTIC_UNIT_TESTS, "0")
|
||||||
|
}
|
||||||
|
|
||||||
|
systemSecurityLastTime := &model.System{Name: model.SYSTEM_LAST_SECURITY_TIME, Value: strconv.FormatInt(currentTime, 10)}
|
||||||
if lastSecurityTime == 0 {
|
if lastSecurityTime == 0 {
|
||||||
<-api.Srv.Store.System().Save(systemSecurityLastTime)
|
<-api.Srv.Store.System().Save(systemSecurityLastTime)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SYSTEM_DIAGNOSTIC_ID = "DiagnosticId"
|
||||||
|
SYSTEM_RAN_UNIT_TESTS = "RanUnitTests"
|
||||||
|
SYSTEM_LAST_SECURITY_TIME = "LastSecurityTime"
|
||||||
|
)
|
||||||
|
|
||||||
type System struct {
|
type System struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
|
|||||||
@@ -16,17 +16,18 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-gorp/gorp"
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
|
||||||
_ "github.com/lib/pq"
|
|
||||||
"github.com/mattermost/platform/model"
|
|
||||||
"github.com/mattermost/platform/utils"
|
|
||||||
"io"
|
"io"
|
||||||
sqltrace "log"
|
sqltrace "log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-gorp/gorp"
|
||||||
|
_ "github.com/go-sql-driver/mysql"
|
||||||
|
_ "github.com/lib/pq"
|
||||||
|
"github.com/mattermost/platform/model"
|
||||||
|
"github.com/mattermost/platform/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SqlStore struct {
|
type SqlStore struct {
|
||||||
@@ -179,6 +180,17 @@ func (ss SqlStore) GetCurrentSchemaVersion() string {
|
|||||||
return version
|
return version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ss SqlStore) MarkSystemRanUnitTests() {
|
||||||
|
if result := <-ss.System().Get(); result.Err == nil {
|
||||||
|
props := result.Data.(model.StringMap)
|
||||||
|
unitTests := props[model.SYSTEM_RAN_UNIT_TESTS]
|
||||||
|
if len(unitTests) == 0 {
|
||||||
|
systemTests := &model.System{Name: model.SYSTEM_RAN_UNIT_TESTS, Value: "1"}
|
||||||
|
<-ss.System().Save(systemTests)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (ss SqlStore) DoesTableExist(tableName string) bool {
|
func (ss SqlStore) DoesTableExist(tableName string) bool {
|
||||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||||
count, err := ss.GetMaster().SelectInt(
|
count, err := ss.GetMaster().SelectInt(
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
package store
|
package store
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mattermost/platform/model"
|
|
||||||
"github.com/mattermost/platform/utils"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/mattermost/platform/model"
|
||||||
|
"github.com/mattermost/platform/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var store Store
|
var store Store
|
||||||
@@ -16,6 +17,8 @@ func Setup() {
|
|||||||
if store == nil {
|
if store == nil {
|
||||||
utils.LoadConfig("config.json")
|
utils.LoadConfig("config.json")
|
||||||
store = NewSqlStore()
|
store = NewSqlStore()
|
||||||
|
|
||||||
|
store.MarkSystemRanUnitTests()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ type Store interface {
|
|||||||
System() SystemStore
|
System() SystemStore
|
||||||
Webhook() WebhookStore
|
Webhook() WebhookStore
|
||||||
Preference() PreferenceStore
|
Preference() PreferenceStore
|
||||||
|
MarkSystemRanUnitTests()
|
||||||
Close()
|
Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const (
|
|||||||
PROP_DIAGNOSTIC_OS = "os"
|
PROP_DIAGNOSTIC_OS = "os"
|
||||||
PROP_DIAGNOSTIC_USER_COUNT = "uc"
|
PROP_DIAGNOSTIC_USER_COUNT = "uc"
|
||||||
PROP_DIAGNOSTIC_ACTIVE_USER_COUNT = "auc"
|
PROP_DIAGNOSTIC_ACTIVE_USER_COUNT = "auc"
|
||||||
|
PROP_DIAGNOSTIC_UNIT_TESTS = "ut"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SendDiagnostic(values url.Values) {
|
func SendDiagnostic(values url.Values) {
|
||||||
|
|||||||
@@ -4,15 +4,16 @@
|
|||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mattermost/platform/api"
|
|
||||||
"github.com/mattermost/platform/model"
|
|
||||||
"github.com/mattermost/platform/store"
|
|
||||||
"github.com/mattermost/platform/utils"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/mattermost/platform/api"
|
||||||
|
"github.com/mattermost/platform/model"
|
||||||
|
"github.com/mattermost/platform/store"
|
||||||
|
"github.com/mattermost/platform/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ApiClient *model.Client
|
var ApiClient *model.Client
|
||||||
@@ -27,6 +28,8 @@ func Setup() {
|
|||||||
InitWeb()
|
InitWeb()
|
||||||
URL = "http://localhost" + utils.Cfg.ServiceSettings.ListenAddress
|
URL = "http://localhost" + utils.Cfg.ServiceSettings.ListenAddress
|
||||||
ApiClient = model.NewClient(URL)
|
ApiClient = model.NewClient(URL)
|
||||||
|
|
||||||
|
api.Srv.Store.MarkSystemRanUnitTests()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user