Merge branch 'deps' into 'master'
Deps See merge request integration-system/isp-config-service!6
This commit is contained in:
commit
de55ea643c
9 files changed
+559
-301
No files matched your search
@@ -1,71 +0,0 @@
|
||||
run:
|
||||
timeout: 2m
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- asciicheck
|
||||
- bodyclose
|
||||
- deadcode
|
||||
- dogsled
|
||||
- errcheck
|
||||
- funlen
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- gofmt
|
||||
- gomnd
|
||||
- goprintffuncname
|
||||
- gosimple
|
||||
- govet
|
||||
- nakedret
|
||||
- nestif
|
||||
- nolintlint
|
||||
- prealloc
|
||||
- rowserrcheck
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
- varcheck
|
||||
- gosec
|
||||
- misspell
|
||||
- whitespace
|
||||
- exhaustive #смотрит на соответствие между элементами enum и swich кейсами
|
||||
- exportloopref #for _,p := []int{1, 2, 3} { s.Bar(&p) /* If s stores the pointer, it will be bug.*/ }
|
||||
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed.
|
||||
linters-settings:
|
||||
maligned:
|
||||
suggest-new: true
|
||||
funlen:
|
||||
lines: 80
|
||||
statements: 40
|
||||
prealloc:
|
||||
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
|
||||
# True by default.
|
||||
simple: true
|
||||
range-loops: true # Report preallocation suggestions on range loops, true by default
|
||||
for-loops: true # Report preallocation suggestions on for loops, false by default
|
||||
gocritic:
|
||||
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
|
||||
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
|
||||
enabled-tags:
|
||||
- diagnostic
|
||||
- performance
|
||||
disabled-checks:
|
||||
- hugeParam
|
||||
- rangeValCopy
|
||||
- ifElseChain
|
||||
exhaustive:
|
||||
default-signifies-exhaustive: true
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: _test\.go # to exclude all test files for linter errcheck
|
||||
linters:
|
||||
- errcheck
|
||||
- linters:
|
||||
- gosec
|
||||
text: "G101:"
|
||||
@@ -1,3 +1,5 @@
|
||||
### v2.4.9
|
||||
* обновлены зависимости (исправляет panic при запуске)
|
||||
### v2.4.8
|
||||
* do not check for instance_uuid anymore
|
||||
### v2.4.7
|
||||
|
||||
@@ -71,7 +71,7 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
func testMain(m *testing.M) {
|
||||
cfg := ctx.BaseTestConfiguration{}
|
||||
test, err := ctx.NewIntegrationTest(m, &cfg, setup)
|
||||
if err != nil {
|
||||
@@ -1,24 +1,114 @@
|
||||
module isp-config-service
|
||||
|
||||
go 1.16
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/asaskevich/govalidator v0.0.0-20180315120708-ccb8e960c48f
|
||||
github.com/cenkalti/backoff/v4 v4.1.0
|
||||
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
|
||||
github.com/cenkalti/backoff/v4 v4.2.0
|
||||
github.com/go-pg/pg/v9 v9.2.1
|
||||
github.com/hashicorp/raft v1.2.0
|
||||
github.com/hashicorp/raft-boltdb/v2 v2.0.0-20210409134258-03c10cc3d4ea
|
||||
github.com/hashicorp/raft v1.3.11
|
||||
github.com/hashicorp/raft-boltdb/v2 v2.2.2
|
||||
github.com/integration-system/bellows v1.0.1
|
||||
github.com/integration-system/isp-etp-go/v2 v2.1.3
|
||||
github.com/integration-system/isp-lib-test v1.6.4
|
||||
github.com/integration-system/isp-lib/v2 v2.8.6
|
||||
github.com/integration-system/isp-log v1.1.8
|
||||
github.com/integration-system/isp-lib-test v1.7.0
|
||||
github.com/integration-system/isp-lib/v2 v2.11.0
|
||||
github.com/integration-system/isp-log v1.2.0
|
||||
github.com/integration-system/net-mux v1.0.1
|
||||
github.com/json-iterator/go v1.1.11
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/satori/go.uuid v1.2.0
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/stretchr/testify v1.8.1
|
||||
github.com/xeipuuv/gojsonschema v1.2.0
|
||||
google.golang.org/grpc v1.37.1
|
||||
google.golang.org/grpc v1.51.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||
github.com/Microsoft/go-winio v0.4.14 // indirect
|
||||
github.com/andybalholm/brotli v1.0.4 // indirect
|
||||
github.com/armon/go-metrics v0.4.1 // indirect
|
||||
github.com/boltdb/bolt v1.3.1 // indirect
|
||||
github.com/buaazp/fasthttprouter v0.1.1 // indirect
|
||||
github.com/codemodus/kace v0.5.1 // indirect
|
||||
github.com/containerd/containerd v1.4.4 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/docker/distribution v2.7.1+incompatible // indirect
|
||||
github.com/docker/docker v20.10.5+incompatible // indirect
|
||||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/docker/go-units v0.4.0 // indirect
|
||||
github.com/fatih/color v1.13.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.0 // indirect
|
||||
github.com/go-openapi/spec v0.20.7 // indirect
|
||||
github.com/go-openapi/swag v0.22.3 // indirect
|
||||
github.com/go-pg/zerochecker v0.2.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-hclog v1.3.1 // indirect
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||
github.com/hashicorp/go-msgpack v0.5.5 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/integration-system/cony v0.3.0 // indirect
|
||||
github.com/integration-system/go-cmp v0.0.0-20190131081942-ac5582987a2f // indirect
|
||||
github.com/integration-system/isp-event-lib v1.9.0 // indirect
|
||||
github.com/integration-system/jsonschema v1.0.1 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.15.12 // indirect
|
||||
github.com/lib/pq v1.10.7 // indirect
|
||||
github.com/magiconair/properties v1.8.6 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
|
||||
github.com/opencontainers/image-spec v1.0.1 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/pressly/goose v2.7.0+incompatible // indirect
|
||||
github.com/profefe/profefe v0.0.0-20210412073930-18342f204d75 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/segmentio/asm v1.2.0 // indirect
|
||||
github.com/segmentio/encoding v0.3.6 // indirect
|
||||
github.com/sirupsen/logrus v1.9.0 // indirect
|
||||
github.com/spf13/afero v1.9.3 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/spf13/viper v1.14.0 // indirect
|
||||
github.com/streadway/amqp v1.0.0 // indirect
|
||||
github.com/subosito/gotenv v1.4.1 // indirect
|
||||
github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a // indirect
|
||||
github.com/swaggo/http-swagger v1.3.3 // indirect
|
||||
github.com/swaggo/swag v1.8.8 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasthttp v1.43.0 // indirect
|
||||
github.com/vmihailenco/bufpool v0.1.11 // indirect
|
||||
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
|
||||
github.com/vmihailenco/tagparser v0.1.2 // indirect
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||
go.etcd.io/bbolt v1.3.6 // indirect
|
||||
golang.org/x/crypto v0.3.0 // indirect
|
||||
golang.org/x/net v0.2.0 // indirect
|
||||
golang.org/x/sys v0.2.0 // indirect
|
||||
golang.org/x/text v0.4.0 // indirect
|
||||
golang.org/x/tools v0.3.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
mellium.im/sasl v0.3.0 // indirect
|
||||
nhooyr.io/websocket v1.8.7 // indirect
|
||||
)
|
||||
@@ -1,37 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"isp-config-service/entity"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestConfigService_validateSchema(t *testing.T) {
|
||||
var (
|
||||
a = assert.New(t)
|
||||
|
||||
schemaDesc = []byte(`{"schema":{"properties":{"configuration":{"required":["address","token"],"properties":{"address":{"type":"string","title":"Адрес"},"token":{"type":"string","title":"Токен"}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","title":"Remote config"},"title":"module_name"}`)
|
||||
validData = map[string]interface{}{"configuration": map[string]interface{}{"address": "127.0.0.1", "token": "token"}}
|
||||
invalidValue = map[string]interface{}{"configuration": map[string]interface{}{"address": 127001, "token": "token"}}
|
||||
invalidName = map[string]interface{}{"config": map[string]interface{}{"test": "127.0.0.1", "token": "token"}}
|
||||
|
||||
schema entity.ConfigSchema
|
||||
valid bool
|
||||
err error
|
||||
)
|
||||
|
||||
a.NoError(json.Unmarshal(schemaDesc, &schema))
|
||||
|
||||
valid, err = ConfigService.validateSchema(schema, validData)
|
||||
a.NoError(err)
|
||||
a.True(valid)
|
||||
|
||||
valid, err = ConfigService.validateSchema(schema, invalidValue)
|
||||
a.Error(err)
|
||||
a.False(valid)
|
||||
|
||||
valid, err = ConfigService.validateSchema(schema, invalidName)
|
||||
a.Error(err)
|
||||
a.False(valid)
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"isp-config-service/conf"
|
||||
"isp-config-service/entity"
|
||||
)
|
||||
|
||||
func TestVersionConfigStore(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
|
||||
type example struct {
|
||||
cfg entity.VersionConfig
|
||||
removedId string
|
||||
}
|
||||
|
||||
config.UnsafeSet(&conf.Configuration{VersionConfigCount: 5})
|
||||
vcs := NewVersionConfigStore()
|
||||
for _, e := range []example{
|
||||
{cfg: entity.VersionConfig{Id: "1", ConfigId: "1"}, removedId: ""},
|
||||
{cfg: entity.VersionConfig{Id: "2", ConfigId: "1"}, removedId: ""},
|
||||
{cfg: entity.VersionConfig{Id: "3", ConfigId: "1"}, removedId: ""},
|
||||
{cfg: entity.VersionConfig{Id: "4", ConfigId: "1"}, removedId: ""},
|
||||
{cfg: entity.VersionConfig{Id: "5", ConfigId: "1"}, removedId: ""},
|
||||
{cfg: entity.VersionConfig{Id: "6", ConfigId: "1"}, removedId: "1"},
|
||||
{cfg: entity.VersionConfig{Id: "7", ConfigId: "1"}, removedId: "2"},
|
||||
} {
|
||||
removedId := vcs.Update(e.cfg)
|
||||
a.Equal(e.removedId, removedId)
|
||||
}
|
||||
for i, versionConfig := range vcs.GetByConfigId("1") {
|
||||
a.Equal(fmt.Sprintf("%d", 7-i), versionConfig.Id)
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"isp-config-service/entity"
|
||||
state2 "isp-config-service/store/state"
|
||||
)
|
||||
|
||||
type mockSnapshotSink struct {
|
||||
bytes.Buffer
|
||||
}
|
||||
|
||||
func (d mockSnapshotSink) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d mockSnapshotSink) ID() string {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (d mockSnapshotSink) Cancel() error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func TestStore_SnapshotRestore(t *testing.T) {
|
||||
state := state2.NewState()
|
||||
state.WritableModules().Create(entity.Module{
|
||||
Id: state2.GenerateId(),
|
||||
Name: "name1",
|
||||
CreatedAt: time.Now().Round(time.Millisecond),
|
||||
LastConnectedAt: time.Now().Round(time.Millisecond),
|
||||
LastDisconnectedAt: time.Now().Round(time.Millisecond),
|
||||
})
|
||||
|
||||
store := NewStateStore(state)
|
||||
snapshot, err := store.Snapshot()
|
||||
assert.NoError(t, err)
|
||||
sink := mockSnapshotSink{}
|
||||
err = snapshot.Persist(&sink)
|
||||
assert.NoError(t, err)
|
||||
|
||||
newState := state2.NewState()
|
||||
store.state = newState
|
||||
err = store.Restore(&sink)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, state, store.state)
|
||||
}
|
||||
Reference in new issue
Block a user