diff --git a/asconfig/asconfig_test.go b/asconfig/asconfig_test.go index 86e83c3..574c8e6 100644 --- a/asconfig/asconfig_test.go +++ b/asconfig/asconfig_test.go @@ -67,26 +67,6 @@ func (s *AsConfigTestSuite) TestAsConfigGetFlatMap() { "namespaces.{bar}.storage-engine.type": "memory", }, }, - { - "xdr 4.9 context", - map[string]interface{}{ - "xdr": map[string]interface{}{ - "datacenters": []map[string]interface{}{ - { - "name": "DC1", - "dc-node-address-port": "1.1.1.1:3000", - "dc-int-ext-ipmap": []string{"1.1.1.1 2.2.2.2", "3.3.3.3 4.4.4.4"}, - }, - }, - }, - }, - &Conf{ - "xdr.datacenters.{DC1}.": 0, - "xdr.datacenters.{DC1}.name": "DC1", - "xdr.datacenters.{DC1}.dc-node-address-port": []string{"1.1.1.1:3000"}, - "xdr.datacenters.{DC1}.dc-int-ext-ipmap": []string{"1.1.1.1 2.2.2.2", "3.3.3.3 4.4.4.4"}, - }, - }, } for _, tc := range testCases { diff --git a/info/as_parser.go b/info/as_parser.go index 854e0e8..c447e0a 100644 --- a/info/as_parser.go +++ b/info/as_parser.go @@ -45,23 +45,20 @@ const ( // 1. string values which are not commands // 2. string values which are used to generate other commands // 3. string values which are both command and constant - constStatXDRpre50 = "statistics/xdr" // StatXdr - constStatNS = "namespace/" // StatNamespace - constStatDCpre50 = "dc/" // statDC - constStatDC = "get-stats:context=xdr;dc=" - constStatSet = "sets/" // StatSets - constStatBin = "bins/" // StatBins - constStatSIndex = "sindex/" // StatSindex - constStatNSNames = "namespaces" // StatNamespaces - constStatDCNames = "dcs" // StatDcs need dc names - constStatLogIDs = "logs" // StatLogs need logging id + constStatNS = "namespace/" // StatNamespace + constStatDC = "get-stats:context=xdr;dc=" + constStatSet = "sets/" // StatSets + constStatBin = "bins/" // StatBins + constStatSIndex = "sindex/" // StatSindex + constStatNSNames = "namespaces" // StatNamespaces + constStatDCNames = "dcs" // StatDcs need dc names + constStatLogIDs = "logs" // StatLogs need logging id cmdConfigNetwork = "get-config:context=network" // ConfigNetwork cmdConfigService = "get-config:context=service" // ConfigService cmdConfigNamespace = "get-config:context=namespace;id=" // ConfigNamespace cmdConfigXDR = "get-config:context=xdr" // ConfigXDR cmdConfigSecurity = "get-config:context=security" // ConfigSecurity - cmdConfigDCPre50 = "get-dc-config:context=dc;dc=" // ConfigDC cmdConfigDC = "get-config:context=xdr;dc=" // ConfigDC cmdConfigMESH = "mesh" // ConfigMesh cmdConfigRacks = "racks:" // configRacks @@ -414,10 +411,6 @@ func ParseNamespaceNames(m map[string]string) []string { // ParseDCNames parses all DC names func ParseDCNames(m map[string]string) []string { - if r, _ := lib.CompareVersions(m[cmdMetaBuild], "5.0"); r == -1 { - return getNames(m[constStatDCNames]) - } - rawXDRConfig := m[cmdConfigXDR] xdrConfig := ParseIntoMap(rawXDRConfig, ";", "=") rawNames, ok := xdrConfig[constStatDCNames].(string) @@ -590,8 +583,7 @@ func (info *AsInfo) createConfigCmdList( ) case ConfigXDRContext: - xdrCmdList, err := info.createXDRConfigCmdList(m[cmdMetaBuild], m) - + xdrCmdList, err := info.createXDRConfigCmdList(m) if err != nil { // TODO: log? return nil, err @@ -599,13 +591,6 @@ func (info *AsInfo) createConfigCmdList( cmdList = append(cmdList, xdrCmdList...) - // Pre 4.9 Only. Post 4.9 all DC configs are in xdr context. - case ConfigDCContext: - cmdList = append( - cmdList, - info.createDCConfigCmdListPre49(m[cmdMetaBuild], ParseDCNames(m)...)..., - ) - case ConfigSecurityContext: cmdList = append(cmdList, cmdConfigSecurity) @@ -650,21 +635,16 @@ func (info *AsInfo) createSetConfigCmdList(nsNames ...string) []string { return cmdList } -func (info *AsInfo) createXDRConfigCmdList(build string, m map[string]string) ([]string, error) { - if r, _ := lib.CompareVersions(build, "5.0"); r == -1 { - return []string{cmdConfigXDR}, nil - } - +func (info *AsInfo) createXDRConfigCmdList(m map[string]string) ([]string, error) { cmdList := make([]string, 0, 1) - resp, err := info.doInfo(cmdConfigXDR) + resp, err := info.doInfo(cmdConfigXDR) if err != nil { return nil, err } m = mergeDicts(m, resp) dcNames := ParseDCNames(m) - results := make(chan error, len(dcNames)) var ( @@ -734,21 +714,6 @@ func (info *AsInfo) createDCNamespaceConfigCmdList(dc string, namespaces ...stri return cmdList } -// createDCConfigCmdList creates get-config command for DC -func (info *AsInfo) createDCConfigCmdListPre49(build string, dcNames ...string) []string { - if r, _ := lib.CompareVersions(build, "5.0"); r != -1 { - return nil - } - - cmdList := make([]string, 0, len(dcNames)) - - for _, dc := range dcNames { - cmdList = append(cmdList, cmdConfigDCPre50+dc) - } - - return cmdList -} - func (info *AsInfo) createMetaCmdList() []string { cmdList := []string{ cmdMetaNodeID, cmdMetaBuild, cmdMetaService, @@ -929,10 +894,6 @@ func parseStatInfo(rawMap map[string]string) lib.Stats { statMap["dc"] = parseAllDcStats(rawMap) statMap["namespace"] = parseAllNsStats(rawMap) - if r, _ := lib.CompareVersions(rawMap[cmdMetaBuild], "5.0"); r == -1 { - statMap["xdr"] = parseBasicInfo(rawMap[constStatXDRpre50]) - } - return statMap } @@ -958,13 +919,12 @@ func parseAllNsStats(rawMap map[string]string) lib.Stats { m := make(lib.Stats) m["service"] = parseStatNsInfo(rawMap[constStatNS+ns]) m["set"] = parseStatSetsInfo(rawMap[constStatSet+ns]) + m["sindex"] = parseStatSindexsInfo(rawMap, ns) if r, _ := lib.CompareVersions(rawMap[cmdMetaBuild], "7.0"); r == -1 { m["bin"] = parseStatBinsInfo(rawMap[constStatBin+ns]) } - m["sindex"] = parseStatSindexsInfo(rawMap, ns) - nsStatMap[ns] = m } @@ -1045,25 +1005,12 @@ func parseConfigInfo(rawMap map[string]string) lib.Stats { configMap[ConfigNamespaceContext] = nsc } - var xc lib.Stats - if r, _ := lib.CompareVersions(rawMap[cmdMetaBuild], "5.0"); r == -1 { - xc = parseBasicConfigInfo(rawMap[cmdConfigXDR], "=") - } else { - xc = parseAllXDRConfig(rawMap, cmdConfigXDR) - } + xc := parseAllXDRConfig(rawMap, cmdConfigXDR) if len(xc) > 0 { configMap[ConfigXDRContext] = xc } - if r, _ := lib.CompareVersions(rawMap[cmdMetaBuild], "5.0"); r == -1 { - // Pre 5.0 Only. 5.0 and later all DC configs are nested in xdr context. - dcc := parseAllDcConfig(rawMap, cmdConfigDCPre50) - if len(dcc) > 0 { - configMap[ConfigDCContext] = dcc - } - } - sec := parseBasicConfigInfo(rawMap[cmdConfigSecurity], "=") if len(sec) > 0 { configMap[ConfigSecurityContext] = sec diff --git a/info/as_parser_test.go b/info/as_parser_test.go index 57d2b00..360160a 100644 --- a/info/as_parser_test.go +++ b/info/as_parser_test.go @@ -5,11 +5,12 @@ import ( "testing" "time" - aero "github.com/aerospike/aerospike-client-go/v7" - lib "github.com/aerospike/aerospike-management-lib" "github.com/go-logr/logr" "github.com/stretchr/testify/suite" "go.uber.org/mock/gomock" + + aero "github.com/aerospike/aerospike-client-go/v7" + lib "github.com/aerospike/aerospike-management-lib" ) type AsParserTestSuite struct { @@ -69,26 +70,6 @@ func (s *AsParserTestSuite) TestAsInfoGetAsConfig() { map[string]string{"sets/test": "ns=test:set=testset:objects=1:tombstones=0:memory_data_bytes=311142:device_data_bytes=0:truncate_lut=0:sindexes=0:index_populating=false:truncating=false:disable-eviction=false:enable-index=false:stop-writes-count=1:stop-writes-size=1;", "sets/bar": "ns=test:set=testset:objects=2:tombstones=0:memory_data_bytes=311142:device_data_bytes=0:truncate_lut=0:sindexes=0:index_populating=false:truncating=false:disable-eviction=false:enable-index=false:stop-writes-count=2:stop-writes-size=2;"}, lib.Stats{"namespaces": lib.Stats{"test": lib.Stats{"sets": lib.Stats{"testset": lib.Stats{"disable-eviction": false, "enable-index": false, "stop-writes-count": int64(1), "stop-writes-size": int64(1)}}}, "bar": lib.Stats{"sets": lib.Stats{"testset": lib.Stats{"disable-eviction": false, "enable-index": false, "stop-writes-count": int64(2), "stop-writes-size": int64(2)}}}}}, }, - { - "xdr", - map[string]string{"build": "4.9.0.35"}, // xdr5 test is below - []string{"get-config:context=xdr"}, - map[string]string{"get-config:context=xdr": "enable-xdr=false;enable-change-notification=false;forward-xdr-writes=false;xdr-delete-shipping-enabled=true;xdr-nsup-deletes-enabled=false"}, - lib.Stats{"xdr": lib.Stats{"enable-xdr": false, "enable-change-notification": false, "forward-xdr-writes": false, "xdr-delete-shipping-enabled": true, "xdr-nsup-deletes-enabled": false}}, - }, - { - "dcs", - map[string]string{"build": "4.9.0.35", "dcs": "DC1;DC2"}, - []string{"get-dc-config:context=dc;dc=DC1", "get-dc-config:context=dc;dc=DC2"}, - map[string]string{ - "get-dc-config:context=dc;dc=DC1": "dc-name=DC1:dc-type=aerospike:tls-name=:dc-security-config-file=:dc-ship-bins=true:nodes=1.1.1.1+3000:auth-mode=internal:int-ext-ipmap=:dc-connections=64:dc-connections-idle-ms=55000:dc-use-alternate-services=false:namespaces=", - "get-dc-config:context=dc;dc=DC2": "dc-name=DC2:dc-type=aerospike:tls-name=:dc-security-config-file=:dc-ship-bins=true:nodes=1.1.1.1+3000:auth-mode=internal:int-ext-ipmap=:dc-connections=64:dc-connections-idle-ms=55000:dc-use-alternate-services=false:namespaces=", - }, - lib.Stats{"dcs": lib.Stats{ - "DC1": lib.Stats{"dc-name": "DC1", "dc-type": "aerospike", "tls-name": "", "dc-security-config-file": "", "dc-ship-bins": true, "nodes": "1.1.1.1+3000", "auth-mode": "internal", "int-ext-ipmap": "", "dc-connections": int64(64), "dc-connections-idle-ms": int64(55000), "dc-use-alternate-services": false, "namespaces": ""}, - "DC2": lib.Stats{"dc-name": "DC2", "dc-type": "aerospike", "tls-name": "", "dc-security-config-file": "", "dc-ship-bins": true, "nodes": "1.1.1.1+3000", "auth-mode": "internal", "int-ext-ipmap": "", "dc-connections": int64(64), "dc-connections-idle-ms": int64(55000), "dc-use-alternate-services": false, "namespaces": ""}, - }}, - }, { "dcs", map[string]string{"build": "5.0.0.0", "dcs": "DC1;DC2"},