This commit is contained in:
d1slike committed 2024-04-24 17:34:03 +03:00
1 parent e2419e2c4b
commit 05eb762273
7 files changed
+409 -1437

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* исправлен метод /config/get_config_by_id
### v2.4.9
* обновлены зависимости (исправляет panic при запуске)
### v2.4.8
-533
View File
@@ -1,533 +0,0 @@
package main
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net"
"os"
"path/filepath"
"strconv"
"strings"
"testing"
"time"
"github.com/integration-system/isp-lib-test/ctx"
"github.com/integration-system/isp-lib-test/docker"
"github.com/integration-system/isp-lib-test/utils"
"github.com/integration-system/isp-lib-test/utils/postgres"
"github.com/integration-system/isp-lib/v2/backend"
"github.com/integration-system/isp-lib/v2/bootstrap"
"github.com/integration-system/isp-lib/v2/structure"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"isp-config-service/conf"
"isp-config-service/domain"
"isp-config-service/entity"
"isp-config-service/store/state"
)
const (
configServiceHttpPort = "9001"
configServiceGrpcPort = "9002"
configServiceSchema = "config_service"
configsNumber = 3
maxAwaitingTime = 25 * time.Second
attemptTimeout = 300 * time.Millisecond
deleteCommonConfigsCommand = "config/common_config/delete_config"
getRoutesCommand = "config/routing/get_routes"
getModulesInfoCommand = "config/module/get_modules_info"
createUpdateConfigCommand = "config/config/create_update_config"
getAllConfigVersionsCommand = "config/config/get_all_version"
)
var (
pgCfg structure.DBConfiguration
configsHttpAddrs = make([]structure.AddressConfiguration, configsNumber)
configsGrpcAddrs = make([]structure.AddressConfiguration, configsNumber)
configsCtxs = make([]*docker.ContainerContext, configsNumber)
)
const mockModuleName = "mockModule"
type (
mockRemoteConfig struct {
Value1 string `json:"value1"`
Value2 int `json:"value2"`
Value3 Value3 `json:"value3"`
}
Value3 struct {
Value31 string `json:"value31"`
}
)
func testMain(m *testing.M) {
cfg := ctx.BaseTestConfiguration{}
test, err := ctx.NewIntegrationTest(m, &cfg, setup)
if err != nil {
panic(err)
}
test.PrepareAndRun()
}
func setup(testCtx *ctx.TestContext, runTest func() int) int {
cfg := testCtx.BaseConfiguration()
cli, err := docker.NewClient()
if err != nil {
panic(err)
}
defer cli.Close()
env := docker.NewTestEnvironment(testCtx, cli)
defer env.Cleanup()
_, pgCfg = env.RunPGContainer()
_, err = postgres.Wait(pgCfg, 10*time.Second)
if err != nil {
panic(err)
}
pgCfg.Schema = configServiceSchema
configs := make([]conf.Configuration, configsNumber)
peersAddrs := make([]string, configsNumber)
for i := 0; i < configsNumber; i++ {
httpAddr := getConfigServiceAddress(i, configServiceHttpPort)
grpcAddr := getConfigServiceAddress(i, configServiceGrpcPort)
cfg := conf.Configuration{
Database: pgCfg,
ModuleName: moduleName,
GrpcOuterAddress: grpcAddr,
WS: conf.WebService{
Rest: httpAddr,
Grpc: grpcAddr,
},
Cluster: conf.ClusterConfiguration{
InMemory: false,
DataDir: "./data",
Peers: nil,
OuterAddress: httpAddr.GetAddress(),
ConnectTimeoutSeconds: 10,
BootstrapCluster: false,
},
}
configsGrpcAddrs[i] = grpcAddr
configsHttpAddrs[i] = httpAddr
configs[i] = cfg
peersAddrs[i] = httpAddr.GetAddress()
}
configs[0].Cluster.BootstrapCluster = true
for i := 0; i < configsNumber; i++ {
c := configs[i]
peersAddrsEnv := generatePeersConfigEnv(peersAddrs)
peersAddrsEnv["LOG_LEVEL"] = "debug"
ctx := env.RunAppContainer(
cfg.Images.Module, c, nil,
docker.WithName(c.GrpcOuterAddress.IP),
docker.WithLogger(NewWriteLogger(strconv.Itoa(i)+"_config:", ioutil.Discard, "DeleteCommonConfigsCommand")),
// docker.WithLogger(NewWriteLogger(strconv.Itoa(i)+"_config:", ioutil.Discard, "Apply 10 command")),
// docker.PullImage(cfg.Registry.Username, cfg.Registry.Password),
docker.WithEnv(peersAddrsEnv),
)
grpcAddr := configsGrpcAddrs[i]
grpcAddr.IP = ctx.GetIPAddress()
configsGrpcAddrs[i] = grpcAddr
httpAddr := configsHttpAddrs[i]
httpAddr.IP = ctx.GetIPAddress()
configsHttpAddrs[i] = httpAddr
configsCtxs[i] = ctx
}
//nolint
// time.Sleep(3 * time.Second)
return runTest()
}
func TestClusterElection(t *testing.T) {
a := assert.New(t)
ready := testClusterReady(a, -1)
if !ready {
return
}
for i := 0; i < configsNumber; i++ {
fmt.Print("\n\n\n")
log.Printf("stopping %d container\n", i)
a.NoError(configsCtxs[i].StopContainer(20 * time.Second))
time.Sleep(5 * time.Second)
fmt.Print("\n\n\n")
log.Printf("checking cluster except %d\n", i)
ready = testClusterReady(a, i)
if !ready {
return
}
fmt.Print("\n\n\n")
log.Printf("starting %d container\n", i)
a.NoError(configsCtxs[i].StartContainer())
time.Sleep(4 * time.Second)
log.Printf("checking cluster, iteration %d\n", i+1)
ready = testClusterReady(a, -1)
if !ready {
return
}
}
}
//nolint:funlen
func TestUpdateConfig(t *testing.T) {
a := assert.New(t)
ready := testClusterReady(a, -1)
if !ready {
return
}
httpAddr := configsHttpAddrs[configsNumber-1]
grpcAddr := configsGrpcAddrs[configsNumber-1]
remoteConfig := mockRemoteConfig{
Value1: "sad",
Value2: 6,
Value3: Value3{
Value31: "32",
},
}
tempDir := t.TempDir()
remoteCfgPath := filepath.Join(tempDir, "remote_config.json")
remoteCfgJson, err := json.Marshal(remoteConfig)
a.NoError(err)
a.NoError(os.WriteFile(remoteCfgPath, remoteCfgJson, 0666))
go newMockModule(a, httpAddr, remoteCfgPath)
time.Sleep(5 * time.Second) // TODO
client := newGrpcClient(a, grpcAddr)
if client == nil {
a.FailNow("unable to connect to config")
}
getModuleConfig := func() entity.Config {
modulesInfo := getModulesInfo(a, client)
a.Len(modulesInfo, 2)
mockModule := modulesInfo[1]
a.Equal(mockModuleName, mockModule.Name)
if !a.Len(mockModule.Configs, 1) {
t.FailNow()
}
return mockModule.Configs[0].Config
}
initialConfig := getModuleConfig()
initialConfigVersions := getAllConfigVersions(a, client, initialConfig.Id)
a.Len(initialConfigVersions, 0)
a.EqualValues(1, initialConfig.Version)
a.EqualValues(remoteConfig.Value2, initialConfig.Data["value2"])
remCfg := map[string]interface{}{
"value1": "test1",
"value2": 0,
"value3": map[string]interface{}{
"value31": "something",
},
}
configForUpdate := entity.Config{
Id: initialConfig.Id,
Name: initialConfig.Name,
ModuleId: initialConfig.ModuleId,
Description: initialConfig.Description,
Data: remCfg,
}
const updatesCount = state.DefaultVersionCount + 1
for i := 0; i < updatesCount; i++ {
remCfg["value2"] = i
updatedConfig := updateConfig(a, client, configForUpdate)
a.EqualValues(i, updatedConfig.Data["value2"])
}
// wait until raft is synchronized to non-leader nodes
time.Sleep(3 * time.Second) // TODO remove?
const lastVersion = updatesCount + 1
const lastDataValue = updatesCount - 1
finalConfig := getModuleConfig()
a.EqualValues(lastVersion, finalConfig.Version)
a.EqualValues(lastDataValue, finalConfig.Data["value2"])
configVersions := getAllConfigVersions(a, client, initialConfig.Id)
a.Len(configVersions, state.DefaultVersionCount)
for i, cfgVer := range configVersions {
// -1 because last config is not listed in versions
version := lastVersion - i - 1
dataValue := lastDataValue - i - 1
a.EqualValues(dataValue, cfgVer.Data["value2"])
a.EqualValues(version, cfgVer.ConfigVersion)
}
}
func getConfigServiceAddress(num int, port string) structure.AddressConfiguration {
lastIP := pgCfg.Address
ip := net.ParseIP(lastIP).To4()
ip[3] = byte(int(ip[3]) + num + 1)
return structure.AddressConfiguration{
//IP: fmt.Sprintf("%s-%d", "isp-config-service", num),
IP: ip.String(),
Port: port,
}
}
func testClusterReady(a *assert.Assertions, except int) bool {
clients := make([]*backend.RxGrpcClient, 0, configsNumber)
defer func() {
for _, client := range clients {
_ = client.Close()
}
}()
for j := 0; j < configsNumber; j++ {
if j == except {
continue
}
configAddr := configsGrpcAddrs[j]
client := newGrpcClient(a, configAddr)
if client == nil {
a.Failf("", "unable to connect to %d config", j)
return false
}
clients = append(clients, client)
ready := testRaftReady(a, client)
if !ready {
return ready
}
}
prevRoutes := getRoutes(a, clients[0])
routesLen := len(clients)
for i := 1; i < len(clients); i++ {
routes := getRoutes(a, clients[i])
t := a.Len(routes, routesLen, "invalid length")
if !t {
return t
}
match := a.ElementsMatch(prevRoutes, routes, "different backend declarations")
if !match {
return match
}
}
return true
}
func newGrpcClient(a *assert.Assertions, configAddr structure.AddressConfiguration) *backend.RxGrpcClient {
start := time.Now()
client := backend.NewRxGrpcClient(backend.WithDialOptions(
grpc.WithInsecure(),
))
client.ReceiveAddressList([]structure.AddressConfiguration{configAddr})
_, err := await(func() (interface{}, error) {
err := client.Invoke(getRoutesCommand, -1, nil, nil)
code := status.Code(err)
if code != codes.Unknown && code != codes.Unavailable {
return nil, nil
}
//nolint
// log.Println("connect to grpc err:", err)
return nil, err
}, maxAwaitingTime, attemptTimeout)
if !a.NoError(err) {
return nil
}
log.Println("waiting until grpc ready:", time.Since(start).Round(time.Second))
return client
}
func testRaftReady(a *assert.Assertions, client *backend.RxGrpcClient) bool {
req := new(domain.ConfigIdRequest)
req.Id = "33"
response := new(structure.GrpcError)
start := time.Now()
f := func() (interface{}, error) {
err := client.Invoke(
deleteCommonConfigsCommand,
-1,
req,
response,
)
//nolint
// log.Println("send grpc request. response: ", response, "err: ", err)
return nil, err
}
_, err := await(f, maxAwaitingTime, attemptTimeout)
log.Println("waiting until raft ready:", time.Since(start).Round(time.Second))
return a.NoError(err)
}
func getRoutes(a *assert.Assertions, client *backend.RxGrpcClient) []structure.BackendDeclaration {
f := func() (interface{}, error) {
var response []structure.BackendDeclaration
err := client.Invoke(
getRoutesCommand,
-1,
nil,
&response,
)
if err != nil {
return nil, err
} else if len(response) == 0 {
return nil, errors.New("zero routes")
}
//nolint
// log.Println("routes:", response)
return response, nil
}
response, err := await(f, time.Second, 50*time.Millisecond)
a.NoError(err)
declarations, _ := response.([]structure.BackendDeclaration)
return declarations
}
func getModulesInfo(a *assert.Assertions, client *backend.RxGrpcClient) []domain.ModuleInfo {
var response []domain.ModuleInfo
err := client.Invoke(
getModulesInfoCommand,
-1,
nil,
&response,
)
a.NoError(err)
return response
}
func updateConfig(a *assert.Assertions, client *backend.RxGrpcClient, config entity.Config) domain.ConfigModuleInfo {
var response domain.ConfigModuleInfo
err := client.Invoke(
createUpdateConfigCommand,
-1,
domain.CreateUpdateConfigRequest{Config: config},
&response,
)
a.NoError(err)
return response
}
func getAllConfigVersions(a *assert.Assertions, client *backend.RxGrpcClient, configId string) []entity.VersionConfig {
var response []entity.VersionConfig
err := client.Invoke(
getAllConfigVersionsCommand,
-1,
domain.ConfigIdRequest{Id: configId},
&response,
)
a.NoError(err)
return response
}
func await(dialer func() (interface{}, error), timeout, attemptTimeout time.Duration) (interface{}, error) {
retryer := utils.NewRetryer(dialer, timeout)
retryer.AttemptTimeout = attemptTimeout
return retryer.Do()
}
func generatePeersConfigEnv(peers []string) map[string]string {
key := "LC_ISP_CLUSTER.PEERS"
val := strings.Join(peers, ",")
return map[string]string{
key: val,
}
}
type writeLogger struct {
prefix string
w io.Writer
filter string
}
func (l *writeLogger) Write(p []byte) (int, error) {
lines := bytes.SplitAfter(p, []byte("\n"))
for _, line := range lines {
s := string(line)
if l.filter != "" && strings.Contains(s, l.filter) || strings.TrimSpace(s) == "" {
continue
}
_, err := l.w.Write(p)
if err != nil {
fmt.Printf("%s %s: %v", l.prefix, s, err)
} else {
fmt.Printf("%s %s", l.prefix, s)
}
}
return len(p), nil
}
// NewWriteLogger returns a writer that behaves like w except
// that it logs (using fmt.Printf) each write to standard error,
// printing the prefix and the string data written.
func NewWriteLogger(prefix string, w io.Writer, filter string) io.Writer {
return &writeLogger{prefix, w, filter}
}
func newMockModule(a *assert.Assertions, configAddr structure.AddressConfiguration, remoteCfgPath string) {
makeDeclaration := func(localConfig interface{}) bootstrap.ModuleInfo {
return bootstrap.ModuleInfo{
ModuleName: mockModuleName,
ModuleVersion: "dev",
GrpcOuterAddress: structure.AddressConfiguration{
IP: "128.3.3.3",
Port: "9999",
},
Endpoints: nil,
}
}
socketConfiguration := func(cfg interface{}) structure.SocketConfiguration {
return structure.SocketConfiguration{
Host: configAddr.IP,
Port: configAddr.Port,
Secure: false,
UrlParams: map[string]string{
"module_name": mockModuleName,
},
}
}
cfg := bootstrap.
ServiceBootstrap(&conf.Configuration{}, &mockRemoteConfig{}).
DefaultRemoteConfigPath(remoteCfgPath).
SocketConfiguration(socketConfiguration).
OnSocketErrorReceive(func(errorMessage map[string]interface{}) {
a.Fail("OnSocketErrorReceive", errorMessage)
}).
OnConfigErrorReceive(func(errorMessage string) {
fmt.Printf("OnConfigErrorReceive: %s\n", errorMessage)
}).
DeclareMe(makeDeclaration).
OnShutdown(func(ctx context.Context, sig os.Signal) {
a.Fail("OnShutdown")
}).
OnRemoteConfigReceive(func(remoteConfig, _ *mockRemoteConfig) {
// TODO: compare configs?
fmt.Println("OnRemoteConfigReceive", remoteConfig)
}).OnModuleReady(func() {
fmt.Println("OnModuleReady")
})
cfg.Run()
}
-1
View File
@@ -223,7 +223,6 @@ func (c *config) GetConfigById(req domain.ConfigIdRequest) (entity.Config, error
})
if len(response) > 0 {
response[0].Data = nil
return response[0], nil
}
+237 -256
View File
@@ -1,18 +1,13 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2020-09-28 13:28:03.40325566 +0300 MSK m=+35.454929207
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs
import (
"github.com/integration-system/isp-lib/v2/docs"
)
import "github.com/integration-system/swag"
var doc = `{
const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{.Description}}",
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"license": {
@@ -818,10 +813,6 @@ var doc = `{
"definitions": {
"domain.BroadcastEventRequest": {
"type": "object",
"required": [
"event",
"moduleNames"
],
"properties": {
"event": {
"type": "string"
@@ -833,8 +824,10 @@ var doc = `{
}
},
"payload": {
"type": "object",
"$ref": "#/definitions/json.RawMessage"
"type": "array",
"items": {
"type": "integer"
}
}
}
},
@@ -868,9 +861,6 @@ var doc = `{
},
"domain.ConfigIdRequest": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "string"
@@ -879,10 +869,6 @@ var doc = `{
},
"domain.ConfigModuleInfo": {
"type": "object",
"required": [
"moduleId",
"name"
],
"properties": {
"active": {
"type": "boolean"
@@ -897,7 +883,6 @@ var doc = `{
"type": "string"
},
"data": {
"type": "object",
"$ref": "#/definitions/entity.ConfigData"
},
"description": {
@@ -927,7 +912,6 @@ var doc = `{
"type": "object",
"properties": {
"address": {
"type": "object",
"$ref": "#/definitions/structure.AddressConfiguration"
},
"endpoints": {
@@ -949,10 +933,6 @@ var doc = `{
},
"domain.CreateUpdateConfigRequest": {
"type": "object",
"required": [
"moduleId",
"name"
],
"properties": {
"active": {
"type": "boolean"
@@ -967,7 +947,6 @@ var doc = `{
"type": "string"
},
"data": {
"type": "object",
"$ref": "#/definitions/entity.ConfigData"
},
"description": {
@@ -1000,7 +979,6 @@ var doc = `{
"type": "boolean"
},
"links": {
"type": "object",
"$ref": "#/definitions/domain.CommonConfigLinks"
}
}
@@ -1015,9 +993,6 @@ var doc = `{
},
"domain.GetByModuleIdRequest": {
"type": "object",
"required": [
"moduleId"
],
"properties": {
"moduleId": {
"type": "string"
@@ -1026,9 +1001,6 @@ var doc = `{
},
"domain.GetByModuleNameRequest": {
"type": "object",
"required": [
"moduleName"
],
"properties": {
"moduleName": {
"type": "string"
@@ -1056,7 +1028,6 @@ var doc = `{
"type": "boolean"
},
"configSchema": {
"type": "object",
"$ref": "#/definitions/schema.Schema"
},
"configs": {
@@ -1096,15 +1067,11 @@ var doc = `{
},
"entity.CommonConfig": {
"type": "object",
"required": [
"name"
],
"properties": {
"createdAt": {
"type": "string"
},
"data": {
"type": "object",
"$ref": "#/definitions/entity.ConfigData"
},
"description": {
@@ -1123,10 +1090,6 @@ var doc = `{
},
"entity.Config": {
"type": "object",
"required": [
"moduleId",
"name"
],
"properties": {
"active": {
"type": "boolean"
@@ -1141,7 +1104,6 @@ var doc = `{
"type": "string"
},
"data": {
"type": "object",
"$ref": "#/definitions/entity.ConfigData"
},
"description": {
@@ -1181,7 +1143,6 @@ var doc = `{
"type": "string"
},
"schema": {
"type": "object",
"$ref": "#/definitions/schema.Schema"
},
"updatedAt": {
@@ -1194,9 +1155,6 @@ var doc = `{
},
"entity.Module": {
"type": "object",
"required": [
"name"
],
"properties": {
"createdAt": {
"type": "string"
@@ -1228,7 +1186,6 @@ var doc = `{
"type": "string"
},
"data": {
"type": "object",
"$ref": "#/definitions/entity.ConfigData"
},
"id": {
@@ -1236,185 +1193,12 @@ var doc = `{
}
}
},
"json.RawMessage": {
"$ref": "#/definitions/json.RawMessage"
},
"jsonschema.Definitions": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/jsonschema.Type"
}
},
"jsonschema.Schema": {
"type": "object",
"properties": {
"$ref": {
"description": "section 7",
"type": "string"
},
"$schema": {
"description": "RFC draft-wright-json-schema-00",
"type": "string"
},
"additionalItems": {
"description": "section 5.9",
"type": "integer"
},
"additionalProperties": {
"description": "section 5.18",
"type": "object",
"$ref": "#/definitions/json.RawMessage"
},
"allOf": {
"description": "section 5.22",
"type": "array",
"items": {
"type": "integer"
}
},
"anyOf": {
"description": "section 5.23",
"type": "array",
"items": {
"type": "integer"
}
},
"binaryEncoding": {
"description": "section 4.3",
"type": "string"
},
"default": {
"description": "section 6.2",
"type": "object"
},
"definitions": {
"type": "object",
"$ref": "#/definitions/jsonschema.Definitions"
},
"dependencies": {
"description": "section 5.19",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/jsonschema.Type"
}
},
"description": {
"description": "section 6.1",
"type": "string"
},
"enum": {
"description": "section 5.20",
"type": "array",
"items": {
"type": "object"
}
},
"exclusiveMaximum": {
"description": "section 5.3",
"type": "boolean"
},
"exclusiveMinimum": {
"description": "section 5.5",
"type": "boolean"
},
"format": {
"description": "section 7",
"type": "string"
},
"items": {
"description": "section 5.9",
"type": "integer"
},
"maxItems": {
"description": "section 5.10",
"type": "integer"
},
"maxLength": {
"description": "section 5.6",
"type": "integer"
},
"maxProperties": {
"description": "section 5.13",
"type": "integer"
},
"maximum": {
"description": "section 5.2",
"type": "integer"
},
"media": {
"description": "RFC draft-wright-json-schema-hyperschema-00, section 4",
"type": "integer"
},
"minItems": {
"description": "section 5.11",
"type": "integer"
},
"minLength": {
"description": "section 5.7",
"type": "integer"
},
"minProperties": {
"description": "section 5.14",
"type": "integer"
},
"minimum": {
"description": "section 5.4",
"type": "integer"
},
"multipleOf": {
"description": "RFC draft-wright-json-schema-validation-00, section 5",
"type": "integer"
},
"not": {
"description": "section 5.25",
"type": "integer"
},
"oneOf": {
"description": "section 5.24",
"type": "array",
"items": {
"type": "integer"
}
},
"pattern": {
"description": "section 5.8",
"type": "string"
},
"patternProperties": {
"description": "section 5.17",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/jsonschema.Type"
}
},
"properties": {
"description": "section 5.16",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/jsonschema.Type"
}
},
"required": {
"description": "section 5.15",
"type": "array",
"items": {
"type": "string"
}
},
"title": {
"description": "RFC draft-wright-json-schema-validation-00, section 6, 7",
"type": "string"
},
"type": {
"description": "section 5.21",
"type": "string"
},
"uniqueItems": {
"description": "section 5.12",
"type": "boolean"
}
}
},
"jsonschema.Type": {
"type": "object",
"properties": {
@@ -1428,25 +1212,31 @@ var doc = `{
},
"additionalItems": {
"description": "section 5.9",
"type": "integer"
"allOf": [
{
"$ref": "#/definitions/jsonschema.Type"
}
]
},
"additionalProperties": {
"description": "section 5.18",
"type": "object",
"$ref": "#/definitions/json.RawMessage"
"type": "array",
"items": {
"type": "integer"
}
},
"allOf": {
"description": "section 5.22",
"type": "array",
"items": {
"type": "integer"
"$ref": "#/definitions/jsonschema.Type"
}
},
"anyOf": {
"description": "section 5.23",
"type": "array",
"items": {
"type": "integer"
"$ref": "#/definitions/jsonschema.Type"
}
},
"binaryEncoding": {
@@ -1454,13 +1244,15 @@ var doc = `{
"type": "string"
},
"default": {
"description": "section 6.2",
"type": "object"
"description": "section 6.2"
},
"definitions": {
"description": "section 5.26",
"type": "object",
"$ref": "#/definitions/jsonschema.Definitions"
"allOf": [
{
"$ref": "#/definitions/jsonschema.Definitions"
}
]
},
"dependencies": {
"description": "section 5.19",
@@ -1476,9 +1268,7 @@ var doc = `{
"enum": {
"description": "section 5.20",
"type": "array",
"items": {
"type": "object"
}
"items": {}
},
"exclusiveMaximum": {
"description": "section 5.3",
@@ -1494,7 +1284,11 @@ var doc = `{
},
"items": {
"description": "section 5.9",
"type": "integer"
"allOf": [
{
"$ref": "#/definitions/jsonschema.Type"
}
]
},
"maxItems": {
"description": "section 5.10",
@@ -1514,7 +1308,11 @@ var doc = `{
},
"media": {
"description": "RFC draft-wright-json-schema-hyperschema-00, section 4",
"type": "integer"
"allOf": [
{
"$ref": "#/definitions/jsonschema.Type"
}
]
},
"minItems": {
"description": "section 5.11",
@@ -1538,13 +1336,17 @@ var doc = `{
},
"not": {
"description": "section 5.25",
"type": "integer"
"allOf": [
{
"$ref": "#/definitions/jsonschema.Type"
}
]
},
"oneOf": {
"description": "section 5.24",
"type": "array",
"items": {
"type": "integer"
"$ref": "#/definitions/jsonschema.Type"
}
},
"pattern": {
@@ -1587,7 +1389,188 @@ var doc = `{
}
},
"schema.Schema": {
"$ref": "#/definitions/jsonschema.Schema"
"type": "object",
"properties": {
"$ref": {
"description": "section 7",
"type": "string"
},
"$schema": {
"description": "RFC draft-wright-json-schema-00",
"type": "string"
},
"additionalItems": {
"description": "section 5.9",
"allOf": [
{
"$ref": "#/definitions/jsonschema.Type"
}
]
},
"additionalProperties": {
"description": "section 5.18",
"type": "array",
"items": {
"type": "integer"
}
},
"allOf": {
"description": "section 5.22",
"type": "array",
"items": {
"$ref": "#/definitions/jsonschema.Type"
}
},
"anyOf": {
"description": "section 5.23",
"type": "array",
"items": {
"$ref": "#/definitions/jsonschema.Type"
}
},
"binaryEncoding": {
"description": "section 4.3",
"type": "string"
},
"default": {
"description": "section 6.2"
},
"definitions": {
"$ref": "#/definitions/jsonschema.Definitions"
},
"dependencies": {
"description": "section 5.19",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/jsonschema.Type"
}
},
"description": {
"description": "section 6.1",
"type": "string"
},
"enum": {
"description": "section 5.20",
"type": "array",
"items": {}
},
"exclusiveMaximum": {
"description": "section 5.3",
"type": "boolean"
},
"exclusiveMinimum": {
"description": "section 5.5",
"type": "boolean"
},
"format": {
"description": "section 7",
"type": "string"
},
"items": {
"description": "section 5.9",
"allOf": [
{
"$ref": "#/definitions/jsonschema.Type"
}
]
},
"maxItems": {
"description": "section 5.10",
"type": "integer"
},
"maxLength": {
"description": "section 5.6",
"type": "integer"
},
"maxProperties": {
"description": "section 5.13",
"type": "integer"
},
"maximum": {
"description": "section 5.2",
"type": "integer"
},
"media": {
"description": "RFC draft-wright-json-schema-hyperschema-00, section 4",
"allOf": [
{
"$ref": "#/definitions/jsonschema.Type"
}
]
},
"minItems": {
"description": "section 5.11",
"type": "integer"
},
"minLength": {
"description": "section 5.7",
"type": "integer"
},
"minProperties": {
"description": "section 5.14",
"type": "integer"
},
"minimum": {
"description": "section 5.4",
"type": "integer"
},
"multipleOf": {
"description": "RFC draft-wright-json-schema-validation-00, section 5",
"type": "integer"
},
"not": {
"description": "section 5.25",
"allOf": [
{
"$ref": "#/definitions/jsonschema.Type"
}
]
},
"oneOf": {
"description": "section 5.24",
"type": "array",
"items": {
"$ref": "#/definitions/jsonschema.Type"
}
},
"pattern": {
"description": "section 5.8",
"type": "string"
},
"patternProperties": {
"description": "section 5.17",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/jsonschema.Type"
}
},
"properties": {
"description": "section 5.16",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/jsonschema.Type"
}
},
"required": {
"description": "section 5.15",
"type": "array",
"items": {
"type": "string"
}
},
"title": {
"description": "RFC draft-wright-json-schema-validation-00, section 6, 7",
"type": "string"
},
"type": {
"description": "section 5.21",
"type": "string"
},
"uniqueItems": {
"description": "section 5.12",
"type": "boolean"
}
}
},
"structure.AddressConfiguration": {
"type": "object",
@@ -1604,7 +1587,6 @@ var doc = `{
"type": "object",
"properties": {
"address": {
"type": "object",
"$ref": "#/definitions/structure.AddressConfiguration"
},
"endpoints": {
@@ -1632,9 +1614,6 @@ var doc = `{
},
"structure.EndpointDescriptor": {
"type": "object",
"required": [
"path"
],
"properties": {
"extra": {
"type": "object",
@@ -1656,9 +1635,7 @@ var doc = `{
"properties": {
"details": {
"type": "array",
"items": {
"type": "object"
}
"items": {}
},
"errorCode": {
"type": "string"
@@ -1683,15 +1660,19 @@ var doc = `{
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = docs.SwaggerInfo{
Version: "2.4.1",
Host: "localhost:9003",
BasePath: "/api/config",
Schemes: []string{},
Title: "ISP configuration service",
Description: "Сервис управления конфигурацией модулей ISP кластера",
var SwaggerInfo = &swag.Spec{
Version: "2.4.1",
Host: "localhost:9003",
BasePath: "/api/config",
Schemes: []string{},
Title: "ISP configuration service",
Description: "Сервис управления конфигурацией модулей ISP кластера",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}
func init() {
docs.InitSwagger(SwaggerInfo, doc)
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
+159 -186
View File
@@ -9,11 +9,9 @@ definitions:
type: string
type: array
payload:
$ref: '#/definitions/json.RawMessage'
type: object
required:
- event
- moduleNames
items:
type: integer
type: array
type: object
domain.CommonConfigLinks:
additionalProperties:
@@ -38,8 +36,6 @@ definitions:
properties:
id:
type: string
required:
- id
type: object
domain.ConfigModuleInfo:
properties:
@@ -53,7 +49,6 @@ definitions:
type: string
data:
$ref: '#/definitions/entity.ConfigData'
type: object
description:
type: string
id:
@@ -68,15 +63,11 @@ definitions:
type: boolean
version:
type: integer
required:
- moduleId
- name
type: object
domain.Connection:
properties:
address:
$ref: '#/definitions/structure.AddressConfiguration'
type: object
endpoints:
items:
$ref: '#/definitions/structure.EndpointDescriptor'
@@ -100,7 +91,6 @@ definitions:
type: string
data:
$ref: '#/definitions/entity.ConfigData'
type: object
description:
type: string
id:
@@ -115,9 +105,6 @@ definitions:
type: string
version:
type: integer
required:
- moduleId
- name
type: object
domain.DeleteCommonConfigResponse:
properties:
@@ -125,7 +112,6 @@ definitions:
type: boolean
links:
$ref: '#/definitions/domain.CommonConfigLinks'
type: object
type: object
domain.DeleteResponse:
properties:
@@ -136,15 +122,11 @@ definitions:
properties:
moduleId:
type: string
required:
- moduleId
type: object
domain.GetByModuleNameRequest:
properties:
moduleName:
type: string
required:
- moduleName
type: object
domain.ModuleDependency:
properties:
@@ -161,7 +143,6 @@ definitions:
type: boolean
configSchema:
$ref: '#/definitions/schema.Schema'
type: object
configs:
items:
$ref: '#/definitions/domain.ConfigModuleInfo'
@@ -191,7 +172,6 @@ definitions:
type: string
data:
$ref: '#/definitions/entity.ConfigData'
type: object
description:
type: string
id:
@@ -200,8 +180,6 @@ definitions:
type: string
updatedAt:
type: string
required:
- name
type: object
entity.Config:
properties:
@@ -215,7 +193,6 @@ definitions:
type: string
data:
$ref: '#/definitions/entity.ConfigData'
type: object
description:
type: string
id:
@@ -228,9 +205,6 @@ definitions:
type: string
version:
type: integer
required:
- moduleId
- name
type: object
entity.ConfigData:
additionalProperties: true
@@ -245,7 +219,6 @@ definitions:
type: string
schema:
$ref: '#/definitions/schema.Schema'
type: object
updatedAt:
type: string
version:
@@ -263,8 +236,6 @@ definitions:
type: string
name:
type: string
required:
- name
type: object
entity.VersionConfig:
properties:
@@ -276,141 +247,13 @@ definitions:
type: string
data:
$ref: '#/definitions/entity.ConfigData'
type: object
id:
type: string
type: object
json.RawMessage:
$ref: '#/definitions/json.RawMessage'
jsonschema.Definitions:
additionalProperties:
$ref: '#/definitions/jsonschema.Type'
type: object
jsonschema.Schema:
properties:
$ref:
description: section 7
type: string
$schema:
description: RFC draft-wright-json-schema-00
type: string
additionalItems:
description: section 5.9
type: integer
additionalProperties:
$ref: '#/definitions/json.RawMessage'
description: section 5.18
type: object
allOf:
description: section 5.22
items:
type: integer
type: array
anyOf:
description: section 5.23
items:
type: integer
type: array
binaryEncoding:
description: section 4.3
type: string
default:
description: section 6.2
type: object
definitions:
$ref: '#/definitions/jsonschema.Definitions'
type: object
dependencies:
additionalProperties:
$ref: '#/definitions/jsonschema.Type'
description: section 5.19
type: object
description:
description: section 6.1
type: string
enum:
description: section 5.20
items:
type: object
type: array
exclusiveMaximum:
description: section 5.3
type: boolean
exclusiveMinimum:
description: section 5.5
type: boolean
format:
description: section 7
type: string
items:
description: section 5.9
type: integer
maxItems:
description: section 5.10
type: integer
maxLength:
description: section 5.6
type: integer
maxProperties:
description: section 5.13
type: integer
maximum:
description: section 5.2
type: integer
media:
description: RFC draft-wright-json-schema-hyperschema-00, section 4
type: integer
minItems:
description: section 5.11
type: integer
minLength:
description: section 5.7
type: integer
minProperties:
description: section 5.14
type: integer
minimum:
description: section 5.4
type: integer
multipleOf:
description: RFC draft-wright-json-schema-validation-00, section 5
type: integer
not:
description: section 5.25
type: integer
oneOf:
description: section 5.24
items:
type: integer
type: array
pattern:
description: section 5.8
type: string
patternProperties:
additionalProperties:
$ref: '#/definitions/jsonschema.Type'
description: section 5.17
type: object
properties:
additionalProperties:
$ref: '#/definitions/jsonschema.Type'
description: section 5.16
type: object
required:
description: section 5.15
items:
type: string
type: array
title:
description: RFC draft-wright-json-schema-validation-00, section 6, 7
type: string
type:
description: section 5.21
type: string
uniqueItems:
description: section 5.12
type: boolean
type: object
jsonschema.Type:
properties:
$ref:
@@ -420,32 +263,33 @@ definitions:
description: RFC draft-wright-json-schema-00
type: string
additionalItems:
allOf:
- $ref: '#/definitions/jsonschema.Type'
description: section 5.9
type: integer
additionalProperties:
$ref: '#/definitions/json.RawMessage'
description: section 5.18
type: object
items:
type: integer
type: array
allOf:
description: section 5.22
items:
type: integer
$ref: '#/definitions/jsonschema.Type'
type: array
anyOf:
description: section 5.23
items:
type: integer
$ref: '#/definitions/jsonschema.Type'
type: array
binaryEncoding:
description: section 4.3
type: string
default:
description: section 6.2
type: object
definitions:
$ref: '#/definitions/jsonschema.Definitions'
allOf:
- $ref: '#/definitions/jsonschema.Definitions'
description: section 5.26
type: object
dependencies:
additionalProperties:
$ref: '#/definitions/jsonschema.Type'
@@ -456,8 +300,7 @@ definitions:
type: string
enum:
description: section 5.20
items:
type: object
items: {}
type: array
exclusiveMaximum:
description: section 5.3
@@ -469,8 +312,9 @@ definitions:
description: section 7
type: string
items:
allOf:
- $ref: '#/definitions/jsonschema.Type'
description: section 5.9
type: integer
maxItems:
description: section 5.10
type: integer
@@ -484,8 +328,9 @@ definitions:
description: section 5.2
type: integer
media:
allOf:
- $ref: '#/definitions/jsonschema.Type'
description: RFC draft-wright-json-schema-hyperschema-00, section 4
type: integer
minItems:
description: section 5.11
type: integer
@@ -502,12 +347,13 @@ definitions:
description: RFC draft-wright-json-schema-validation-00, section 5
type: integer
not:
allOf:
- $ref: '#/definitions/jsonschema.Type'
description: section 5.25
type: integer
oneOf:
description: section 5.24
items:
type: integer
$ref: '#/definitions/jsonschema.Type'
type: array
pattern:
description: section 5.8
@@ -538,7 +384,132 @@ definitions:
type: boolean
type: object
schema.Schema:
$ref: '#/definitions/jsonschema.Schema'
properties:
$ref:
description: section 7
type: string
$schema:
description: RFC draft-wright-json-schema-00
type: string
additionalItems:
allOf:
- $ref: '#/definitions/jsonschema.Type'
description: section 5.9
additionalProperties:
description: section 5.18
items:
type: integer
type: array
allOf:
description: section 5.22
items:
$ref: '#/definitions/jsonschema.Type'
type: array
anyOf:
description: section 5.23
items:
$ref: '#/definitions/jsonschema.Type'
type: array
binaryEncoding:
description: section 4.3
type: string
default:
description: section 6.2
definitions:
$ref: '#/definitions/jsonschema.Definitions'
dependencies:
additionalProperties:
$ref: '#/definitions/jsonschema.Type'
description: section 5.19
type: object
description:
description: section 6.1
type: string
enum:
description: section 5.20
items: {}
type: array
exclusiveMaximum:
description: section 5.3
type: boolean
exclusiveMinimum:
description: section 5.5
type: boolean
format:
description: section 7
type: string
items:
allOf:
- $ref: '#/definitions/jsonschema.Type'
description: section 5.9
maxItems:
description: section 5.10
type: integer
maxLength:
description: section 5.6
type: integer
maxProperties:
description: section 5.13
type: integer
maximum:
description: section 5.2
type: integer
media:
allOf:
- $ref: '#/definitions/jsonschema.Type'
description: RFC draft-wright-json-schema-hyperschema-00, section 4
minItems:
description: section 5.11
type: integer
minLength:
description: section 5.7
type: integer
minProperties:
description: section 5.14
type: integer
minimum:
description: section 5.4
type: integer
multipleOf:
description: RFC draft-wright-json-schema-validation-00, section 5
type: integer
not:
allOf:
- $ref: '#/definitions/jsonschema.Type'
description: section 5.25
oneOf:
description: section 5.24
items:
$ref: '#/definitions/jsonschema.Type'
type: array
pattern:
description: section 5.8
type: string
patternProperties:
additionalProperties:
$ref: '#/definitions/jsonschema.Type'
description: section 5.17
type: object
properties:
additionalProperties:
$ref: '#/definitions/jsonschema.Type'
description: section 5.16
type: object
required:
description: section 5.15
items:
type: string
type: array
title:
description: RFC draft-wright-json-schema-validation-00, section 6, 7
type: string
type:
description: section 5.21
type: string
uniqueItems:
description: section 5.12
type: boolean
type: object
structure.AddressConfiguration:
properties:
ip:
@@ -550,7 +521,6 @@ definitions:
properties:
address:
$ref: '#/definitions/structure.AddressConfiguration'
type: object
endpoints:
items:
$ref: '#/definitions/structure.EndpointDescriptor'
@@ -577,14 +547,11 @@ definitions:
type: string
userAuthRequired:
type: boolean
required:
- path
type: object
structure.GrpcError:
properties:
details:
items:
type: object
items: {}
type: array
errorCode:
type: string
@@ -665,7 +632,8 @@ paths:
post:
consumes:
- application/json
description: Возвращает флаг удаления и набор связей с модулями и конфигурациями, в случае наличия связей deleted всегда false
description: Возвращает флаг удаления и набор связей с модулями и конфигурациями,
в случае наличия связей deleted всегда false
parameters:
- description: id общей конфигурации
in: body
@@ -691,7 +659,8 @@ paths:
post:
consumes:
- application/json
description: Возвращает массив конфигураций по запрошенным идентификаторам (все, если массив пустой)
description: Возвращает массив конфигураций по запрошенным идентификаторам (все,
если массив пустой)
produces:
- application/json
responses:
@@ -708,7 +677,8 @@ paths:
post:
consumes:
- application/json
description: Возвращает ассоциативный массив, ключами которого являются название модулей, а значения - название конфигурации модуля
description: Возвращает ассоциативный массив, ключами которого являются название
модулей, а значения - название конфигурации модуля
parameters:
- description: id общей конфигурации
in: body
@@ -886,7 +856,8 @@ paths:
post:
consumes:
- application/json
description: Возвращает актуальную версию конфигурации без дополнительного содержимого (ConfigData)
description: Возвращает актуальную версию конфигурации без дополнительного содержимого
(ConfigData)
parameters:
- description: id конфигурации
in: body
@@ -952,7 +923,8 @@ paths:
post:
consumes:
- application/json
description: Активирует указанную конфигурацию и деактивирует остальные, возвращает активированную конфигурацию
description: Активирует указанную конфигурацию и деактивирует остальные, возвращает
активированную конфигурацию
parameters:
- description: id конфигурации для изменения
in: body
@@ -1062,7 +1034,8 @@ paths:
post:
consumes:
- application/json
description: Возвращает полное состояние всех модулей в кластере (конфигурация, схема конфигурации, подключенные экземпляры)
description: Возвращает полное состояние всех модулей в кластере (конфигурация,
схема конфигурации, подключенные экземпляры)
produces:
- application/json
responses:
+6 -17
View File
@@ -10,33 +10,25 @@ require (
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.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/integration-system/swag v1.7.115
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.8.1
github.com/xeipuuv/gojsonschema v1.2.0
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
@@ -44,19 +36,17 @@ require (
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/gorilla/websocket v1.4.2 // 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/go-uuid v1.0.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
@@ -69,11 +59,10 @@ require (
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/onsi/ginkgo v1.15.0 // indirect
github.com/onsi/gomega v1.10.5 // 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
@@ -85,7 +74,6 @@ require (
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
@@ -99,6 +87,7 @@ require (
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/lint v0.0.0-20210508222113-6edffad5e616 // 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
+6 -444
View File
File diff suppressed because it is too large. Load diff