Skip to content

Commit 61fa9aa

Browse files
authored
feat: TOOLS-3078 Added 8.1 Server Schema based Test cases (#71)
* feat: TOOLS-3078 Add test cases for Aerospike 8.1 config conversion Introduces new test data and configuration files for Aerospike server version 8.1.0.0, including .conf, .yaml, and associated test definitions. Updates the schema submodule to the latest commit to support these tests. * fix: correct apply-ttl-reduction key to apply-ttl-reductions in server81.yaml * feat: implement exponential backoff for Docker image pulling to handle rate limiting * fix: remove exponential backoff logic for Docker container creation in integration tests * feat: TOOLS-3078 Update schema submodule to 8.1.0 commit Advanced the schema/schemas submodule to commit f99d3c1, pulling in the latest changes from the schema repository. * Update dependencies in go.mod and go.sum Upgraded multiple direct and indirect dependencies to newer versions, including aerospike-client-go, aerospike-management-lib, tools-common-go, docker, go-logr, fsnotify, viper, cast, and OpenTelemetry packages. Removed unused and outdated dependencies to keep the project up to date and improve compatibility and security.
1 parent 1ebec1d commit 61fa9aa

File tree

10 files changed

+300
-94
lines changed

10 files changed

+300
-94
lines changed

go.mod

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ toolchain go1.24.5
66

77
require (
88
github.com/aerospike/aerospike-client-go/v8 v8.2.2
9-
github.com/aerospike/aerospike-management-lib v1.7.1-0.20250709120612-377d0ff87581
10-
github.com/aerospike/tools-common-go v0.2.1-0.20250130070321-acda09110e14
9+
github.com/aerospike/aerospike-management-lib v1.8.0
10+
github.com/aerospike/tools-common-go v0.3.0
1111
github.com/bombsimon/logrusr/v4 v4.1.0
1212
github.com/docker/docker v28.3.2+incompatible
1313
github.com/go-logr/logr v1.4.3
@@ -31,45 +31,40 @@ require (
3131
github.com/docker/go-connections v0.5.0 // indirect
3232
github.com/docker/go-units v0.5.0 // indirect
3333
github.com/felixge/httpsnoop v1.0.4 // indirect
34-
github.com/fsnotify/fsnotify v1.7.0 // indirect
34+
github.com/fsnotify/fsnotify v1.8.0 // indirect
3535
github.com/go-logr/stdr v1.2.2 // indirect
36+
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
3637
github.com/gogo/protobuf v1.3.2 // indirect
37-
github.com/hashicorp/hcl v1.0.0 // indirect
3838
github.com/inconshreveable/mousetrap v1.1.0 // indirect
39-
github.com/magiconair/properties v1.8.7 // indirect
40-
github.com/mitchellh/mapstructure v1.5.0 // indirect
4139
github.com/moby/docker-image-spec v1.3.1 // indirect
42-
github.com/moby/sys/atomicwriter v0.1.0 // indirect
40+
github.com/moby/sys/sequential v0.6.0 // indirect
4341
github.com/opencontainers/go-digest v1.0.0 // indirect
44-
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
42+
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
4543
github.com/pkg/errors v0.9.1 // indirect
4644
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
47-
github.com/sagikazarmark/locafero v0.4.0 // indirect
48-
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
45+
github.com/sagikazarmark/locafero v0.7.0 // indirect
4946
github.com/sourcegraph/conc v0.3.0 // indirect
50-
github.com/spf13/afero v1.11.0 // indirect
51-
github.com/spf13/cast v1.6.0 // indirect
52-
github.com/spf13/viper v1.19.0 // indirect
47+
github.com/spf13/afero v1.12.0 // indirect
48+
github.com/spf13/cast v1.7.1 // indirect
49+
github.com/spf13/viper v1.20.1 // indirect
5350
github.com/subosito/gotenv v1.6.0 // indirect
5451
github.com/wadey/gocovmerge v0.0.0-20160331181800-b5bfa59ec0ad // indirect
5552
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
5653
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
5754
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
5855
github.com/yuin/gopher-lua v1.1.1 // indirect
5956
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
60-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect
57+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
6158
go.opentelemetry.io/otel v1.37.0 // indirect
6259
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 // indirect
6360
go.opentelemetry.io/otel/metric v1.37.0 // indirect
6461
go.opentelemetry.io/otel/trace v1.37.0 // indirect
6562
go.opentelemetry.io/proto/otlp v1.2.0 // indirect
6663
go.uber.org/multierr v1.11.0 // indirect
67-
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
6864
golang.org/x/sync v0.12.0 // indirect
6965
golang.org/x/sys v0.31.0 // indirect
7066
golang.org/x/text v0.23.0 // indirect
7167
golang.org/x/tools v0.31.0 // indirect
7268
gopkg.in/inf.v0 v0.9.1 // indirect
73-
gopkg.in/ini.v1 v1.67.0 // indirect
7469
k8s.io/apimachinery v0.29.0 // indirect
7570
)

go.sum

Lines changed: 33 additions & 48 deletions
Large diffs are not rendered by default.

integration_test.go

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -452,34 +452,9 @@ func runServer(version string, serverVersion string, confPath string, auth testu
452452

453453
// TODO if possible, don't create new containers each time
454454
var id string
455-
maxRetries := 5
456-
retryCount := 0
457-
backoffTime := 5 * time.Second
458-
459-
for {
460-
id, err = testutils.CreateAerospikeContainer(containerName, containerConf, containerHostConf, imagePullOptions, dockerClient)
461-
if err == nil {
462-
break
463-
}
464-
465-
// Check if this is a rate limit error
466-
if strings.Contains(err.Error(), "toomanyrequests") {
467-
retryCount++
468-
if retryCount > maxRetries {
469-
t.Errorf("Failed after %d retries: %v", maxRetries, err)
470-
return "", ""
471-
}
472-
473-
// Log the retry
474-
t.Logf("Docker pull rate limit reached, retrying in %v (attempt %d/%d)", backoffTime, retryCount, maxRetries)
475455

476-
// Sleep with exponential backoff
477-
time.Sleep(backoffTime)
478-
backoffTime *= 2 // exponential backoff
479-
continue
480-
}
481-
482-
// If it's not a rate limit error, just fail
456+
id, err = testutils.CreateAerospikeContainer(containerName, containerConf, containerHostConf, imagePullOptions, dockerClient)
457+
if err != nil {
483458
t.Error(err)
484459
return "", ""
485460
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"Source":"testdata/cases/server81/server81.conf",
4+
"Destination":"testdata/cases/server81/server81-res-.yaml",
5+
"Expected":"testdata/cases/server81/server81.yaml",
6+
"Arguments":["convert","--aerospike-version","8.1.0.0","--format","asconfig","--output","testdata/cases/server81/server81-res-.yaml"],
7+
"SkipServerTest":false,
8+
"ServerErrorAllowList":null,
9+
"ServerImage":"aerospike/aerospike-server-enterprise:8.1.0.0-rc3"
10+
}
11+
]
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
2+
service {
3+
cluster-name cl1
4+
5+
user root
6+
group root
7+
pidfile /dummy/file/path1
8+
9+
batch-max-requests 1000
10+
tls-refresh-period 300S
11+
}
12+
13+
logging {
14+
console {
15+
context namespace info
16+
}
17+
}
18+
19+
network {
20+
service {
21+
address any
22+
port 3000
23+
}
24+
25+
heartbeat {
26+
mode multicast
27+
multicast-group 127.0.0.1
28+
port 9918
29+
30+
31+
32+
33+
interval 150
34+
timeout 10
35+
}
36+
37+
fabric {
38+
port 3001
39+
}
40+
41+
admin {
42+
address any
43+
port 3003
44+
}
45+
}
46+
47+
namespace ns1 {
48+
replication-factor 2
49+
50+
index-type shmem
51+
sindex-type shmem
52+
53+
disable-mrt-writes false
54+
mrt-duration 60
55+
strong-consistency true
56+
apply-ttl-reductions false
57+
58+
migrate-skip-unreadable false
59+
60+
default-read-touch-ttl-pct 50
61+
62+
storage-engine memory {
63+
data-size 32G
64+
}
65+
66+
evict-indexes-memory-pct 50
67+
68+
indexes-memory-budget 2147483648
69+
70+
nsup-period 2048
71+
72+
set s1 {
73+
default-read-touch-ttl-pct -1
74+
}
75+
76+
active-rack 2
77+
}
78+
79+
namespace ns2 {
80+
replication-factor 2
81+
index-type shmem
82+
sindex-type shmem
83+
apply-ttl-reductions true
84+
default-read-touch-ttl-pct 0
85+
storage-engine device {
86+
device /dummy/mount/point1
87+
evict-used-pct 70
88+
stop-writes-used-pct 70
89+
stop-writes-avail-pct 20
90+
flush-size 2M
91+
}
92+
93+
set s2 {
94+
default-read-touch-ttl-pct 50
95+
}
96+
}
97+
98+
security {
99+
default-password-file /dummy/file/path2
100+
}
101+
102+
xdr {
103+
dc dataCenter1 {
104+
node-address-port 127.0.0.1 3000
105+
namespace ns1 {
106+
remote-namespace ns2
107+
ship-versions-interval 2M
108+
ship-versions-policy interval
109+
}
110+
}
111+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
logging:
2+
- namespace: info
3+
name: console
4+
namespaces:
5+
- default-read-touch-ttl-pct: 0
6+
index-type:
7+
type: shmem
8+
name: ns2
9+
replication-factor: 2
10+
apply-ttl-reductions: true
11+
sets:
12+
- default-read-touch-ttl-pct: 50
13+
name: s2
14+
sindex-type:
15+
type: shmem
16+
storage-engine:
17+
devices:
18+
- /dummy/mount/point1
19+
evict-used-pct: 70
20+
flush-size: 2097152
21+
stop-writes-avail-pct: 20
22+
stop-writes-used-pct: 70
23+
type: device
24+
- active-rack: 2
25+
default-read-touch-ttl-pct: 50
26+
evict-indexes-memory-pct: 50
27+
index-type:
28+
type: shmem
29+
indexes-memory-budget: 2147483648
30+
name: ns1
31+
nsup-period: 2048
32+
replication-factor: 2
33+
disable-mrt-writes: false
34+
mrt-duration: 60
35+
strong-consistency: true
36+
apply-ttl-reductions: false
37+
migrate-skip-unreadable: false
38+
sets:
39+
- default-read-touch-ttl-pct: -1
40+
name: s1
41+
sindex-type:
42+
type: shmem
43+
storage-engine:
44+
data-size: 34359738368
45+
type: memory
46+
network:
47+
fabric:
48+
port: 3001
49+
heartbeat:
50+
interval: 150
51+
mode: multicast
52+
multicast-groups:
53+
- 127.0.0.1
54+
port: 9918
55+
timeout: 10
56+
admin:
57+
addresses:
58+
- any
59+
port: 3003
60+
service:
61+
addresses:
62+
- any
63+
port: 3000
64+
security:
65+
default-password-file: /dummy/file/path2
66+
service:
67+
batch-max-requests: 1000
68+
cluster-name: cl1
69+
group: root
70+
pidfile: /dummy/file/path1
71+
tls-refresh-period: 300
72+
user: root
73+
xdr:
74+
dcs:
75+
- name: dataCenter1
76+
namespaces:
77+
- name: ns1
78+
remote-namespace: ns2
79+
ship-versions-interval: 120
80+
ship-versions-policy: interval
81+
node-address-ports:
82+
- 127.0.0.1:3000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"TestedVersion":"8.1.0.0-rc3","OriginallyUsedVersion":"8.1.0.0-rc3"}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"Source":"testdata/cases/server81/server81.yaml",
4+
"Destination":"testdata/cases/server81/server81-res-.conf",
5+
"Expected":"testdata/cases/server81/server81.conf",
6+
"Arguments":["convert","--aerospike-version","8.1.0.0","--format","yaml","--output","testdata/cases/server81/server81-res-.conf"],
7+
"SkipServerTest":false,
8+
"ServerErrorAllowList":null,
9+
"ServerImage":"aerospike/aerospike-server-enterprise:8.1.0.0-rc3"
10+
}
11+
]

testutils/utils.go

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"log"
99
"os"
1010
"os/exec"
11+
"strings"
12+
"time"
1113

1214
"github.com/docker/docker/api/types/container"
1315
"github.com/docker/docker/api/types/image"
@@ -70,8 +72,41 @@ func RemoveAerospikeContainer(id string, cli *client.Client) error {
7072

7173
func CreateAerospikeContainer(name string, c *container.Config, ch *container.HostConfig, imagePullOpts image.PullOptions, cli *client.Client) (string, error) {
7274
ctx := context.Background()
73-
reader, err := cli.ImagePull(ctx, name, imagePullOpts)
74-
if err != nil {
75+
76+
// Retry configuration for Docker Hub rate limiting
77+
maxRetries := 10
78+
baseBackoff := 10 * time.Second // Base backoff time
79+
maxBackoff := 5 * time.Minute // Maximum backoff time
80+
81+
var reader io.ReadCloser
82+
var err error
83+
84+
// Retry loop for image pulling with exponential backoff
85+
for attempt := 1; attempt <= maxRetries; attempt++ {
86+
reader, err = cli.ImagePull(ctx, name, imagePullOpts)
87+
if err == nil {
88+
break
89+
}
90+
91+
// Check if this is a rate limit error
92+
if strings.Contains(err.Error(), "toomanyrequests") || strings.Contains(err.Error(), "rate limit") {
93+
if attempt == maxRetries {
94+
log.Printf("Failed to pull image %s after %d attempts due to rate limiting: %s", name, maxRetries, err)
95+
return "", err
96+
}
97+
98+
// Exponential backoff: 2^(attempt-1) * baseBackoff, capped at maxBackoff
99+
backoffTime := time.Duration(1<<(attempt-1)) * baseBackoff
100+
if backoffTime > maxBackoff {
101+
backoffTime = maxBackoff
102+
}
103+
104+
log.Printf("Docker pull rate limit reached for %s, retrying in %v (attempt %d/%d)", name, backoffTime, attempt, maxRetries)
105+
time.Sleep(backoffTime)
106+
continue
107+
}
108+
109+
// If it's not a rate limit error, don't retry
75110
log.Printf("Unable to pull image %s: %s", name, err)
76111
return "", err
77112
}

0 commit comments

Comments
 (0)