diff --git a/Makefile b/Makefile index 4cbf17a..f759ee5 100644 --- a/Makefile +++ b/Makefile @@ -27,10 +27,10 @@ test: mocks go test -v ./... .PHONY: coverage -coverage: - go test ./... -coverprofile coverage.cov -coverpkg ./... - grep -v "_mock.go" coverage.cov > coverage_no_mocks.cov - mv coverage_no_mocks.cov coverage.cov +coverage: mocks + go test ./... -coverprofile coverage.cov -coverpkg ./... || true + grep -v "_mock.go" coverage.cov > coverage_no_mocks.cov && mv coverage_no_mocks.cov coverage.cov + grep -v "test/" coverage.cov > coverage_no_mocks.cov && mv coverage_no_mocks.cov coverage.cov go tool cover -func coverage.cov .PHONY: clean-mocks diff --git a/asconfig/generate.go b/asconfig/generate.go index 4a4abb6..506ea6a 100644 --- a/asconfig/generate.go +++ b/asconfig/generate.go @@ -33,14 +33,14 @@ type ConfGetter interface { } type GenConf struct { - conf Conf - version string + Conf Conf + Version string } func newGenConf(conf Conf, version string) *GenConf { return &GenConf{ - conf: conf, - version: version, + Conf: conf, + Version: version, } } diff --git a/info/test/as_info.json b/info/test/as_info.json index 1925db0..8d4fdb1 100644 --- a/info/test/as_info.json +++ b/info/test/as_info.json @@ -2,128 +2,128 @@ "configs": { "logging": { "/var/log/aerospike/aerospike.log": { - "aggr": "WARNING", - "alloc": "WARNING", - "appeal": "WARNING", - "arenax": "WARNING", - "as": "WARNING", - "audit": "WARNING", - "batch": "WARNING", - "batch-sub": "WARNING", - "bin": "WARNING", - "clustering": "WARNING", - "config": "WARNING", - "drv_pmem": "WARNING", - "drv_ssd": "WARNING", - "exchange": "WARNING", - "exp": "WARNING", - "fabric": "WARNING", - "flat": "WARNING", - "geo": "WARNING", - "hardware": "WARNING", - "hb": "WARNING", - "health": "WARNING", - "hlc": "WARNING", - "index": "WARNING", - "info": "WARNING", - "info-port": "WARNING", - "key-busy": "WARNING", - "migrate": "WARNING", - "misc": "WARNING", - "msg": "WARNING", - "namespace": "WARNING", - "nsup": "WARNING", - "os": "WARNING", - "particle": "WARNING", - "partition": "WARNING", - "proto": "WARNING", - "proxy": "WARNING", - "proxy-divert": "WARNING", - "query": "WARNING", - "record": "WARNING", - "roster": "WARNING", - "rw": "WARNING", - "rw-client": "WARNING", - "secrets": "WARNING", - "security": "WARNING", - "service": "WARNING", - "service-list": "WARNING", - "sindex": "WARNING", - "skew": "WARNING", - "smd": "DETAIL", - "socket": "WARNING", - "storage": "WARNING", - "tls": "WARNING", - "truncate": "WARNING", - "tsvc": "WARNING", - "udf": "WARNING", - "vault": "WARNING", - "vmapx": "WARNING", - "xdr": "WARNING", - "xdr-client": "WARNING", - "xmem": "WARNING" + "aggr": "INFO", + "alloc": "INFO", + "appeal": "INFO", + "arenax": "INFO", + "as": "INFO", + "audit": "INFO", + "batch": "INFO", + "batch-sub": "INFO", + "bin": "INFO", + "clustering": "INFO", + "config": "INFO", + "drv_pmem": "INFO", + "drv_ssd": "INFO", + "exchange": "INFO", + "exp": "INFO", + "fabric": "INFO", + "flat": "INFO", + "geo": "INFO", + "hardware": "INFO", + "hb": "INFO", + "health": "INFO", + "hlc": "INFO", + "index": "INFO", + "info": "INFO", + "info-port": "INFO", + "key-busy": "INFO", + "migrate": "INFO", + "misc": "INFO", + "msg": "INFO", + "namespace": "INFO", + "nsup": "INFO", + "os": "INFO", + "particle": "INFO", + "partition": "INFO", + "proto": "INFO", + "proxy": "INFO", + "proxy-divert": "INFO", + "query": "INFO", + "record": "INFO", + "roster": "INFO", + "rw": "INFO", + "rw-client": "INFO", + "secrets": "INFO", + "security": "INFO", + "service": "INFO", + "service-list": "INFO", + "sindex": "INFO", + "skew": "INFO", + "smd": "INFO", + "socket": "INFO", + "storage": "INFO", + "tls": "INFO", + "truncate": "INFO", + "tsvc": "INFO", + "udf": "INFO", + "vault": "INFO", + "vmapx": "INFO", + "xdr": "INFO", + "xdr-client": "INFO", + "xmem": "INFO" }, "stderr": { - "aggr": "WARNING", - "alloc": "WARNING", - "appeal": "WARNING", - "arenax": "WARNING", - "as": "WARNING", - "audit": "WARNING", - "batch": "WARNING", - "batch-sub": "WARNING", - "bin": "WARNING", - "clustering": "WARNING", - "config": "WARNING", - "drv_pmem": "WARNING", - "drv_ssd": "WARNING", - "exchange": "WARNING", - "exp": "WARNING", - "fabric": "WARNING", - "flat": "WARNING", - "geo": "WARNING", - "hardware": "WARNING", - "hb": "WARNING", - "health": "WARNING", - "hlc": "WARNING", - "index": "WARNING", - "info": "WARNING", - "info-port": "WARNING", - "key-busy": "WARNING", - "migrate": "WARNING", - "misc": "WARNING", - "msg": "WARNING", - "namespace": "WARNING", - "nsup": "WARNING", - "os": "WARNING", - "particle": "WARNING", - "partition": "WARNING", - "proto": "WARNING", - "proxy": "WARNING", - "proxy-divert": "WARNING", - "query": "WARNING", - "record": "WARNING", - "roster": "WARNING", - "rw": "WARNING", - "rw-client": "WARNING", - "secrets": "WARNING", - "security": "WARNING", - "service": "WARNING", - "service-list": "WARNING", - "sindex": "WARNING", - "skew": "WARNING", - "smd": "DETAIL", - "socket": "WARNING", - "storage": "WARNING", - "tls": "WARNING", - "truncate": "WARNING", - "tsvc": "WARNING", - "udf": "WARNING", - "vault": "WARNING", - "vmapx": "WARNING", - "xdr": "WARNING", - "xdr-client": "WARNING", - "xmem": "WARNING" + "aggr": "INFO", + "alloc": "INFO", + "appeal": "INFO", + "arenax": "INFO", + "as": "INFO", + "audit": "INFO", + "batch": "INFO", + "batch-sub": "INFO", + "bin": "INFO", + "clustering": "INFO", + "config": "INFO", + "drv_pmem": "INFO", + "drv_ssd": "INFO", + "exchange": "INFO", + "exp": "INFO", + "fabric": "INFO", + "flat": "INFO", + "geo": "INFO", + "hardware": "INFO", + "hb": "INFO", + "health": "INFO", + "hlc": "INFO", + "index": "INFO", + "info": "INFO", + "info-port": "INFO", + "key-busy": "INFO", + "migrate": "INFO", + "misc": "INFO", + "msg": "INFO", + "namespace": "INFO", + "nsup": "INFO", + "os": "INFO", + "particle": "INFO", + "partition": "INFO", + "proto": "INFO", + "proxy": "INFO", + "proxy-divert": "INFO", + "query": "INFO", + "record": "INFO", + "roster": "INFO", + "rw": "INFO", + "rw-client": "INFO", + "secrets": "INFO", + "security": "INFO", + "service": "INFO", + "service-list": "INFO", + "sindex": "INFO", + "skew": "INFO", + "smd": "INFO", + "socket": "INFO", + "storage": "INFO", + "tls": "INFO", + "truncate": "INFO", + "tsvc": "INFO", + "udf": "INFO", + "vault": "INFO", + "vmapx": "INFO", + "xdr": "INFO", + "xdr-client": "INFO", + "xmem": "INFO" } }, "namespaces": { @@ -160,7 +160,7 @@ "index-type": "shmem", "inline-short-queries": false, "max-record-size": 0, - "memory-size": 4294967296, + "memory-size": 1073741824, "migrate-order": 5, "migrate-retransmit-ms": 5000, "migrate-sleep": 1, @@ -173,77 +173,57 @@ "read-consistency-level-override": "off", "reject-non-xdr-writes": false, "reject-xdr-writes": false, - "replication-factor": 2, - "sindex-stage-size": 1073741824, - "sindex-type": "shmem", - "single-query-threads": 4, - "stop-writes-pct": 90, - "stop-writes-sys-memory-pct": 90, - "storage-engine": "memory", - "strong-consistency": false, - "strong-consistency-allow-expunge": false, - "tomb-raider-eligible-age": 86400, - "tomb-raider-period": 86400, - "transaction-pending-limit": 20, - "truncate-threads": 4, - "write-commit-level-override": "off", - "xdr-bin-tombstone-ttl": 86400, - "xdr-tomb-raider-period": 120, - "xdr-tomb-raider-threads": 1 - }, - "foo": { - "allow-ttl-without-nsup": false, - "background-query-max-rps": 10000, - "conflict-resolution-policy": "generation", - "conflict-resolve-writes": false, - "default-ttl": 0, - "disable-cold-start-eviction": false, - "disable-write-dup-res": false, - "disallow-expunge": false, - "disallow-null-setname": false, - "enable-benchmarks-batch-sub": false, - "enable-benchmarks-ops-sub": false, - "enable-benchmarks-read": false, - "enable-benchmarks-udf": false, - "enable-benchmarks-udf-sub": false, - "enable-benchmarks-write": false, - "enable-hist-proxy": false, - "evict-hist-buckets": 10000, - "evict-tenths-pct": 5, - "force-long-queries": false, - "geo2dsphere-within.earth-radius-meters": 6371000, - "geo2dsphere-within.level-mod": 1, - "geo2dsphere-within.max-cells": 12, - "geo2dsphere-within.max-level": 20, - "geo2dsphere-within.min-level": 1, - "geo2dsphere-within.strict": true, - "high-water-disk-pct": 0, - "high-water-memory-pct": 0, - "ignore-migrate-fill-delay": false, - "index-stage-size": 1073741824, - "index-type": "shmem", - "inline-short-queries": false, - "max-record-size": 0, - "memory-size": 4294967296, - "migrate-order": 5, - "migrate-retransmit-ms": 5000, - "migrate-sleep": 1, - "nsup-hist-period": 3600, - "nsup-period": 0, - "nsup-threads": 1, - "partition-tree-sprigs": 256, - "prefer-uniform-balance": true, - "rack-id": 0, - "read-consistency-level-override": "off", - "reject-non-xdr-writes": false, - "reject-xdr-writes": false, - "replication-factor": 2, + "replication-factor": 1, + "sets": { + "zap": { + "disable-eviction": false, + "enable-index": false, + "stop-writes-count": 0, + "stop-writes-size": 0 + }, + "zip": { + "disable-eviction": false, + "enable-index": false, + "stop-writes-count": 0, + "stop-writes-size": 0 + } + }, "sindex-stage-size": 1073741824, "sindex-type": "shmem", "single-query-threads": 4, "stop-writes-pct": 90, "stop-writes-sys-memory-pct": 90, - "storage-engine": "memory", + "storage-engine": "device", + "storage-engine.cache-replica-writes": false, + "storage-engine.cold-start-empty": false, + "storage-engine.commit-min-size": 0, + "storage-engine.commit-to-device": false, + "storage-engine.compression": "none", + "storage-engine.compression-acceleration": 0, + "storage-engine.compression-level": 0, + "storage-engine.data-in-memory": false, + "storage-engine.defrag-lwm-pct": 50, + "storage-engine.defrag-queue-min": 0, + "storage-engine.defrag-sleep": 1000, + "storage-engine.defrag-startup-minimum": 0, + "storage-engine.direct-files": false, + "storage-engine.disable-odsync": false, + "storage-engine.enable-benchmarks-storage": false, + "storage-engine.encryption-key-file": "null", + "storage-engine.encryption-old-key-file": "null", + "storage-engine.file[0]": "/opt/aerospike/data/bar.dat", + "storage-engine.file[0].shadow": "/opt/aerospike/data/bar-shadow.dat", + "storage-engine.filesize": 1073741824, + "storage-engine.flush-max-ms": 1000, + "storage-engine.max-used-pct": 70, + "storage-engine.max-write-cache": 67108864, + "storage-engine.min-avail-pct": 5, + "storage-engine.post-write-queue": 256, + "storage-engine.read-page-cache": false, + "storage-engine.serialize-tomb-raider": false, + "storage-engine.sindex-startup-device-scan": false, + "storage-engine.tomb-raider-sleep": 1000, + "storage-engine.write-block-size": 1048576, "strong-consistency": false, "strong-consistency-allow-expunge": false, "tomb-raider-eligible-age": 86400, @@ -277,7 +257,7 @@ "force-long-queries": false, "geo2dsphere-within.earth-radius-meters": 6371000, "geo2dsphere-within.level-mod": 1, - "geo2dsphere-within.max-cells": 12, + "geo2dsphere-within.max-cells": 15, "geo2dsphere-within.max-level": 20, "geo2dsphere-within.min-level": 1, "geo2dsphere-within.strict": true, @@ -288,7 +268,7 @@ "index-type": "shmem", "inline-short-queries": false, "max-record-size": 0, - "memory-size": 4294967296, + "memory-size": 536870912, "migrate-order": 5, "migrate-retransmit-ms": 5000, "migrate-sleep": 1, @@ -301,7 +281,21 @@ "read-consistency-level-override": "off", "reject-non-xdr-writes": false, "reject-xdr-writes": false, - "replication-factor": 2, + "replication-factor": 1, + "sets": { + "blah": { + "disable-eviction": false, + "enable-index": false, + "stop-writes-count": 0, + "stop-writes-size": 0 + }, + "blee": { + "disable-eviction": false, + "enable-index": false, + "stop-writes-count": 0, + "stop-writes-size": 0 + } + }, "sindex-stage-size": 1073741824, "sindex-type": "shmem", "single-query-threads": 4, @@ -344,12 +338,13 @@ "heartbeat.interval": 150, "heartbeat.mode": "multicast", "heartbeat.mtu": 65535, - "heartbeat.multicast-group": "239.1.99.222", + "heartbeat.multicast-group": "239.1.99.222 239.1.99.223", "heartbeat.multicast-ttl": 0, "heartbeat.port": 9918, "heartbeat.protocol": "v3", "heartbeat.timeout": 10, "info.port": 3003, + "service.access-address": "1.1.1.1 2.2.2.2", "service.access-port": 0, "service.address": "any", "service.alternate-access-port": 0, @@ -365,13 +360,9 @@ "ns": "test", "rack_0": "BB9050011AC4202" }, - { - "ns": "foo", - "rack_0": "BB9050011AC4202" - }, { "ns": "bar", - "rack_0": "BB9050011AC4202,2B" + "rack_0": "BB9050011AC4202" } ], "security": { @@ -391,7 +382,7 @@ "batch-index-threads": 8, "batch-max-buffers-per-queue": 255, "batch-max-unused-buffers": 256, - "cluster-name": "null", + "cluster-name": "6.x-cluster-security", "debug-allocations": "none", "disable-udf-execution": false, "downgrading": false, @@ -406,7 +397,7 @@ "keep-caps-ssd-health": false, "log-local-time": false, "log-millis": false, - "microsecond-histograms": true, + "microsecond-histograms": false, "migrate-fill-delay": 0, "migrate-max-num-incoming": 4, "migrate-threads": 1, @@ -423,7 +414,7 @@ "salt-allocations": false, "secrets-address-port": "null", "secrets-tls-context": "null", - "service-threads": 8, + "service-threads": 40, "sindex-builder-threads": 4, "sindex-gc-period": 10, "stay-quiesced": false, @@ -447,7 +438,7 @@ "max-recoveries-interleaved": 0, "namespaces": { "test": { - "bin-policy": "all", + "bin-policy": "changed-or-specified", "compression-level": 1, "compression-threshold": 128, "delay-ms": 0, @@ -464,8 +455,8 @@ "ship-bin-luts": false, "ship-nsup-deletes": false, "ship-only-specified-sets": false, - "shipped-bins": "", - "shipped-sets": "", + "shipped-bins": "foo,bar", + "shipped-sets": "blah,blee", "transaction-queue-limit": 16384, "write-policy": "auto" } @@ -492,8 +483,8 @@ "forward": false, "hot-key-ms": 100, "ignore-expunges": false, - "ignored-bins": "", - "ignored-sets": "", + "ignored-bins": "tip,wip", + "ignored-sets": "zip,zap", "max-throughput": 100000, "remote-namespace": "null", "sc-replication-wait-ms": 100, @@ -523,7 +514,7 @@ "metadata": { "asd_build": "6.4.0.0", "build_os": "debian12", - "cluster_name": "null", + "cluster_name": "6.x-cluster-security", "edition": "Aerospike Enterprise Edition", "features": [ "batch-any", @@ -552,19 +543,15 @@ "node_id": "BB9050011AC4202", "ns_list": [ "test", - "foo", "bar" ], "service": [ - "172.17.0.5:3000" - ], - "services": [ - "172.17.0.4:3000" + "1.1.1.1:3000", + "2.2.2.2:3000" ], + "services": [], "services-alternate": [], - "services-alumni": [ - "172.17.0.4:3000" - ], + "services-alumni": [], "version": "Aerospike Enterprise Edition build 6.4.0.0" }, "statistics": { @@ -573,19 +560,79 @@ "bar": { "bin": null, "service": {}, - "set": {}, - "sindex": {} - }, - "foo": { - "bin": null, - "service": {}, - "set": {}, + "set": { + "zap": { + "device_data_bytes": 0, + "disable-eviction": false, + "enable-index": false, + "index_populating": false, + "memory_data_bytes": 0, + "ns": "bar", + "objects": 0, + "set": "zap", + "sindexes": 0, + "stop-writes-count": 0, + "stop-writes-size": 0, + "tombstones": 0, + "truncate_lut": 0, + "truncating": false + }, + "zip": { + "device_data_bytes": 0, + "disable-eviction": false, + "enable-index": false, + "index_populating": false, + "memory_data_bytes": 0, + "ns": "bar", + "objects": 0, + "set": "zip", + "sindexes": 0, + "stop-writes-count": 0, + "stop-writes-size": 0, + "tombstones": 0, + "truncate_lut": 0, + "truncating": false + } + }, "sindex": {} }, "test": { "bin": null, "service": {}, - "set": {}, + "set": { + "blah": { + "device_data_bytes": 0, + "disable-eviction": false, + "enable-index": false, + "index_populating": false, + "memory_data_bytes": 0, + "ns": "test", + "objects": 0, + "set": "blah", + "sindexes": 0, + "stop-writes-count": 0, + "stop-writes-size": 0, + "tombstones": 0, + "truncate_lut": 0, + "truncating": false + }, + "blee": { + "device_data_bytes": 0, + "disable-eviction": false, + "enable-index": false, + "index_populating": false, + "memory_data_bytes": 0, + "ns": "test", + "objects": 0, + "set": "blee", + "sindexes": 0, + "stop-writes-count": 0, + "stop-writes-size": 0, + "tombstones": 0, + "truncate_lut": 0, + "truncating": false + } + }, "sindex": {} } }, diff --git a/asconfig/generate_e2e_test.go b/test/generate_e2e_test.go similarity index 58% rename from asconfig/generate_e2e_test.go rename to test/generate_e2e_test.go index 1415301..10cf0b9 100644 --- a/asconfig/generate_e2e_test.go +++ b/test/generate_e2e_test.go @@ -1,4 +1,4 @@ -package asconfig +package test import ( "log" @@ -6,8 +6,8 @@ import ( "testing" aero "github.com/aerospike/aerospike-client-go/v6" + "github.com/aerospike/aerospike-management-lib/asconfig" "github.com/aerospike/aerospike-management-lib/info" - "github.com/aerospike/aerospike-management-lib/test" "github.com/go-logr/logr" "github.com/stretchr/testify/suite" ) @@ -17,7 +17,7 @@ type GenerateE2eTestSuite struct { } func (suite *GenerateE2eTestSuite) SetupSuite() { - err := test.Start(1) + err := Start(1) if err != nil { suite.T().Fatal(err) @@ -29,12 +29,12 @@ func (suite *GenerateE2eTestSuite) SetupSuite() { suite.T().Fail() } - Init(logr.Discard(), schemaDir) + asconfig.Init(logr.Discard(), schemaDir) } // Uncomment this function to check server logs after failure func (suite *GenerateE2eTestSuite) TearDownSuite() { - err := test.Stop() + err := Stop() if err != nil { suite.T().Fatal(err) @@ -47,34 +47,34 @@ func (suite *GenerateE2eTestSuite) SetupTest() { func (suite *GenerateE2eTestSuite) TestGenerate() { asPolicy := aero.NewClientPolicy() - host := aero.NewHost(test.IP, test.PORT_START) + host := aero.NewHost(IP, PORT_START) asPolicy.User = "admin" asPolicy.Password = "admin" asinfo := info.NewAsInfo(logr.Discard(), host, asPolicy) - genConf, err := GenerateConf(logr.Discard(), asinfo, true) + genConf, err := asconfig.GenerateConf(logr.Discard(), asinfo, true) suite.Assert().Nil(err) - genConfWithDefaults, err := GenerateConf(logr.Discard(), asinfo, false) + genConfWithDefaults, err := asconfig.GenerateConf(logr.Discard(), asinfo, false) suite.Assert().Nil(err) - asconf, err := NewMapAsConfig(logr.Discard(), genConf.version, genConf.conf) + asconf, err := asconfig.NewMapAsConfig(logr.Discard(), genConf.Version, genConf.Conf) suite.Assert().Nil(err) - asconfWithDefaults, err := NewMapAsConfig(logr.Discard(), genConfWithDefaults.version, genConfWithDefaults.conf) + asconfWithDefaults, err := asconfig.NewMapAsConfig(logr.Discard(), genConfWithDefaults.Version, genConfWithDefaults.Conf) suite.Assert().Nil(err) - test.RestartAerospikeContainer(test.GetAerospikeContainerName(0), asconf.ToConfFile()) + RestartAerospikeContainer(GetAerospikeContainerName(0), asconf.ToConfFile()) asinfo2 := info.NewAsInfo(logr.Discard(), host, asPolicy) - genConf2, err := GenerateConf(logr.Discard(), asinfo2, true) + genConf2, err := asconfig.GenerateConf(logr.Discard(), asinfo2, true) suite.Assert().Nil(err) - genConfWithDefaults2, err := GenerateConf(logr.Discard(), asinfo2, false) + genConfWithDefaults2, err := asconfig.GenerateConf(logr.Discard(), asinfo2, false) suite.Assert().Nil(err) - asconf2, err := NewMapAsConfig(logr.Discard(), genConf2.version, genConf2.conf) + asconf2, err := asconfig.NewMapAsConfig(logr.Discard(), genConf2.Version, genConf2.Conf) suite.Assert().Nil(err) - asconfWithDefaults2, err := NewMapAsConfig(logr.Discard(), genConfWithDefaults2.version, genConfWithDefaults2.conf) + asconfWithDefaults2, err := asconfig.NewMapAsConfig(logr.Discard(), genConfWithDefaults2.Version, genConfWithDefaults2.Conf) suite.Assert().Nil(err) suite.Assert().Equal(asconf, asconf2)