Skip to content

Commit b87bd09

Browse files
Merge pull request #233 from RedisLabs/OPCR-47-add-global-default-user
feat: adding in global user to the redis active active update model
2 parents f0abda8 + ba68026 commit b87bd09

File tree

5 files changed

+269
-20
lines changed

5 files changed

+269
-20
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
# Initializes the CodeQL tools for scanning.
4141
- name: Initialize CodeQL
42-
uses: github/codeql-action/init@v3
42+
uses: github/codeql-action/init@v4
4343
with:
4444
languages: ${{ matrix.language }}
4545
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -50,7 +50,7 @@ jobs:
5050
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5151
# If this step fails, then you should remove it and run the build manually (see below)
5252
- name: Autobuild
53-
uses: github/codeql-action/autobuild@v3
53+
uses: github/codeql-action/autobuild@v4
5454

5555
# ℹ️ Command-line programs to run using the OS shell.
5656
# 📚 https://git.io/JvXDl
@@ -64,4 +64,4 @@ jobs:
6464
# make release
6565

6666
- name: Perform CodeQL Analysis
67-
uses: github/codeql-action/analyze@v3
67+
uses: github/codeql-action/analyze@v4

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,6 @@ $RECYCLE.BIN/
272272
bin/
273273
vendor
274274
.envrc
275+
276+
CLAUDE.md
277+
.claude

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
All notable changes to this project will be documented in this file.
33
See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/).
44

5+
## 0.37.0 (8th October 2025)
6+
7+
### Added:
8+
* Added `GlobalEnableDefaultUser` field to UpdateActiveActiveDatabase struct
9+
* New tests for ActiveActiveCreate and ActiveActiveUpdate methods
10+
511
## v0.36.5
612

713
### Changed:

active_active_database_test.go

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package rediscloud_api
22

33
import (
44
"context"
5+
"fmt"
6+
"net/http"
57
"net/http/httptest"
68
"testing"
79
"time"
@@ -12,6 +14,244 @@ import (
1214
"github.com/stretchr/testify/require"
1315
)
1416

17+
func TestAADatabase_Create(t *testing.T) {
18+
expected := 1466
19+
s := httptest.NewServer(testServer("key", "secret", postRequest(t, "/subscriptions/111478/databases", `{
20+
"dryRun": false,
21+
"name": "active-active-example",
22+
"protocol": "redis",
23+
"memoryLimitInGb": 1,
24+
"datasetSizeInGb": 1,
25+
"supportOSSClusterApi": false,
26+
"respVersion": "resp3",
27+
"useExternalEndpointForOSSClusterApi": false,
28+
"dataEvictionPolicy": "noeviction",
29+
"dataPersistence": "none",
30+
"sourceIp": [
31+
"0.0.0.0/0"
32+
],
33+
"password": "test-password",
34+
"alerts": [
35+
{
36+
"name": "dataset-size",
37+
"value": 80
38+
}
39+
],
40+
"modules": [
41+
{
42+
"name": "RedisJSON"
43+
}
44+
],
45+
"localThroughputMeasurement": [
46+
{
47+
"region": "us-east-1",
48+
"writeOperationsPerSecond": 1000,
49+
"readOperationsPerSecond": 1000
50+
},
51+
{
52+
"region": "us-east-2",
53+
"writeOperationsPerSecond": 1000,
54+
"readOperationsPerSecond": 1000
55+
}
56+
],
57+
"port": 12000,
58+
"queryPerformanceFactor": "Standard",
59+
"redisVersion": "7.2"
60+
}`, `{
61+
"taskId": "task",
62+
"commandType": "databaseCreateRequest",
63+
"status": "received",
64+
"description": "Task request received and is being queued for processing.",
65+
"timestamp": "2024-05-08T08:10:02Z",
66+
"_links": {
67+
"task": {
68+
"href": "https://example.org",
69+
"title": "getTaskStatusUpdates",
70+
"type": "GET"
71+
}
72+
}
73+
}`), getRequest(t, "/tasks/task", fmt.Sprintf(`{
74+
"taskId": "task",
75+
"commandType": "databaseCreateRequest",
76+
"status": "processing-completed",
77+
"timestamp": "2024-05-08T08:22:34Z",
78+
"response": {
79+
"resourceId": %d
80+
},
81+
"_links": {
82+
"self": {
83+
"href": "https://example.com",
84+
"type": "GET"
85+
}
86+
}
87+
}`, expected))))
88+
89+
subject, err := clientFromTestServer(s, "key", "secret")
90+
require.NoError(t, err)
91+
92+
actual, err := subject.Database.ActiveActiveCreate(context.TODO(), 111478, databases.CreateActiveActiveDatabase{
93+
DryRun: redis.Bool(false),
94+
Name: redis.String("active-active-example"),
95+
Protocol: redis.String("redis"),
96+
MemoryLimitInGB: redis.Float64(1),
97+
DatasetSizeInGB: redis.Float64(1),
98+
SupportOSSClusterAPI: redis.Bool(false),
99+
RespVersion: redis.String("resp3"),
100+
UseExternalEndpointForOSSClusterAPI: redis.Bool(false),
101+
DataEvictionPolicy: redis.String("noeviction"),
102+
GlobalDataPersistence: redis.String("none"),
103+
GlobalSourceIP: redis.StringSlice("0.0.0.0/0"),
104+
GlobalPassword: redis.String("test-password"),
105+
GlobalAlerts: []*databases.Alert{
106+
{
107+
Name: redis.String("dataset-size"),
108+
Value: redis.Int(80),
109+
},
110+
},
111+
GlobalModules: []*databases.Module{
112+
{
113+
Name: redis.String("RedisJSON"),
114+
},
115+
},
116+
LocalThroughputMeasurement: []*databases.LocalThroughput{
117+
{
118+
Region: redis.String("us-east-1"),
119+
WriteOperationsPerSecond: redis.Int(1000),
120+
ReadOperationsPerSecond: redis.Int(1000),
121+
},
122+
{
123+
Region: redis.String("us-east-2"),
124+
WriteOperationsPerSecond: redis.Int(1000),
125+
ReadOperationsPerSecond: redis.Int(1000),
126+
},
127+
},
128+
PortNumber: redis.Int(12000),
129+
QueryPerformanceFactor: redis.String("Standard"),
130+
RedisVersion: redis.String("7.2"),
131+
})
132+
require.NoError(t, err)
133+
134+
assert.Equal(t, expected, actual)
135+
}
136+
137+
func TestAADatabase_Update(t *testing.T) {
138+
flow := taskFlow(
139+
t,
140+
http.MethodPut,
141+
"/subscriptions/111478/databases/1466/regions",
142+
`{
143+
"dryRun": false,
144+
"memoryLimitInGb": 2,
145+
"datasetSizeInGb": 2,
146+
"supportOSSClusterApi": false,
147+
"useExternalEndpointForOSSClusterApi": false,
148+
"clientSslCertificate": "cert-content",
149+
"clientTlsCertificates": ["cert1", "cert2"],
150+
"enableTls": true,
151+
"globalDataPersistence": "aof-every-1-second",
152+
"globalPassword": "new-password",
153+
"globalEnableDefaultUser": true,
154+
"globalSourceIp": [
155+
"192.168.1.0/24"
156+
],
157+
"globalAlerts": [
158+
{
159+
"name": "throughput-higher-than",
160+
"value": 90
161+
}
162+
],
163+
"regions": [
164+
{
165+
"region": "us-east-1",
166+
"remoteBackup": {
167+
"active": true,
168+
"interval": "every-12-hours",
169+
"timeUTC": "10:00",
170+
"storageType": "aws-s3",
171+
"storagePath": "s3://bucket/path"
172+
},
173+
"localThroughputMeasurement": {
174+
"writeOperationsPerSecond": 2000,
175+
"readOperationsPerSecond": 2000
176+
},
177+
"dataPersistence": "aof-every-1-second",
178+
"password": "region-password",
179+
"sourceIp": [
180+
"10.0.0.0/8"
181+
],
182+
"enableDefaultUser": false,
183+
"alerts": [
184+
{
185+
"name": "dataset-size",
186+
"value": 85
187+
}
188+
]
189+
}
190+
],
191+
"dataEvictionPolicy": "allkeys-lru",
192+
"queryPerformanceFactor": "6x"
193+
}`,
194+
"update-task",
195+
"databaseUpdateRequest",
196+
)
197+
198+
s := httptest.NewServer(testServer("key", "secret", flow...))
199+
defer s.Close()
200+
201+
subject, err := clientFromTestServer(s, "key", "secret")
202+
require.NoError(t, err)
203+
204+
err = subject.Database.ActiveActiveUpdate(context.TODO(), 111478, 1466, databases.UpdateActiveActiveDatabase{
205+
DryRun: redis.Bool(false),
206+
MemoryLimitInGB: redis.Float64(2),
207+
DatasetSizeInGB: redis.Float64(2),
208+
SupportOSSClusterAPI: redis.Bool(false),
209+
UseExternalEndpointForOSSClusterAPI: redis.Bool(false),
210+
ClientSSLCertificate: redis.String("cert-content"),
211+
ClientTLSCertificates: &[]*string{redis.String("cert1"), redis.String("cert2")},
212+
EnableTls: redis.Bool(true),
213+
GlobalDataPersistence: redis.String("aof-every-1-second"),
214+
GlobalPassword: redis.String("new-password"),
215+
GlobalEnableDefaultUser: redis.Bool(true),
216+
GlobalSourceIP: redis.StringSlice("192.168.1.0/24"),
217+
GlobalAlerts: &[]*databases.Alert{
218+
{
219+
Name: redis.String("throughput-higher-than"),
220+
Value: redis.Int(90),
221+
},
222+
},
223+
Regions: []*databases.LocalRegionProperties{
224+
{
225+
Region: redis.String("us-east-1"),
226+
RemoteBackup: &databases.DatabaseBackupConfig{
227+
Active: redis.Bool(true),
228+
Interval: redis.String("every-12-hours"),
229+
TimeUTC: redis.String("10:00"),
230+
StorageType: redis.String("aws-s3"),
231+
StoragePath: redis.String("s3://bucket/path"),
232+
},
233+
LocalThroughputMeasurement: &databases.LocalThroughput{
234+
WriteOperationsPerSecond: redis.Int(2000),
235+
ReadOperationsPerSecond: redis.Int(2000),
236+
},
237+
DataPersistence: redis.String("aof-every-1-second"),
238+
Password: redis.String("region-password"),
239+
SourceIP: redis.StringSlice("10.0.0.0/8"),
240+
EnableDefaultUser: redis.Bool(false),
241+
Alerts: &[]*databases.Alert{
242+
{
243+
Name: redis.String("dataset-size"),
244+
Value: redis.Int(85),
245+
},
246+
},
247+
},
248+
},
249+
DataEvictionPolicy: redis.String("allkeys-lru"),
250+
QueryPerformanceFactor: redis.String("6x"),
251+
})
252+
require.NoError(t, err)
253+
}
254+
15255
func TestAADatabase_List(t *testing.T) {
16256
body := `{
17257
"accountId": 69369,

service/databases/model_active_active.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,24 @@ func (o LocalThroughput) String() string {
9797
return internal.ToString(o)
9898
}
9999

100+
// Uses pointers for slices to allow empty slices to be serialised/sent
100101
type UpdateActiveActiveDatabase struct {
101-
DryRun *bool `json:"dryRun,omitempty"`
102-
MemoryLimitInGB *float64 `json:"memoryLimitInGb,omitempty"`
103-
DatasetSizeInGB *float64 `json:"datasetSizeInGb,omitempty"`
104-
SupportOSSClusterAPI *bool `json:"supportOSSClusterApi,omitempty"`
105-
UseExternalEndpointForOSSClusterAPI *bool `json:"useExternalEndpointForOSSClusterApi,omitempty"`
106-
ClientSSLCertificate *string `json:"clientSslCertificate,omitempty"`
107-
// Using a pointer to allow empty slices to be serialised/sent
108-
ClientTLSCertificates *[]*string `json:"clientTlsCertificates,omitempty"`
109-
EnableTls *bool `json:"enableTls,omitempty"`
110-
GlobalDataPersistence *string `json:"globalDataPersistence,omitempty"`
111-
GlobalPassword *string `json:"globalPassword,omitempty"`
112-
GlobalSourceIP []*string `json:"globalSourceIp,omitempty"`
113-
// Using a pointer to allow empty slices to be serialised/sent
114-
GlobalAlerts *[]*Alert `json:"globalAlerts,omitempty"`
115-
Regions []*LocalRegionProperties `json:"regions,omitempty"`
116-
DataEvictionPolicy *string `json:"dataEvictionPolicy,omitempty"`
117-
QueryPerformanceFactor *string `json:"queryPerformanceFactor,omitempty"`
102+
DryRun *bool `json:"dryRun,omitempty"`
103+
MemoryLimitInGB *float64 `json:"memoryLimitInGb,omitempty"`
104+
DatasetSizeInGB *float64 `json:"datasetSizeInGb,omitempty"`
105+
SupportOSSClusterAPI *bool `json:"supportOSSClusterApi,omitempty"`
106+
UseExternalEndpointForOSSClusterAPI *bool `json:"useExternalEndpointForOSSClusterApi,omitempty"`
107+
ClientSSLCertificate *string `json:"clientSslCertificate,omitempty"`
108+
ClientTLSCertificates *[]*string `json:"clientTlsCertificates,omitempty"`
109+
EnableTls *bool `json:"enableTls,omitempty"`
110+
GlobalDataPersistence *string `json:"globalDataPersistence,omitempty"`
111+
GlobalPassword *string `json:"globalPassword,omitempty"`
112+
GlobalEnableDefaultUser *bool `json:"globalEnableDefaultUser,omitempty"`
113+
GlobalSourceIP []*string `json:"globalSourceIp,omitempty"`
114+
GlobalAlerts *[]*Alert `json:"globalAlerts,omitempty"`
115+
Regions []*LocalRegionProperties `json:"regions,omitempty"`
116+
DataEvictionPolicy *string `json:"dataEvictionPolicy,omitempty"`
117+
QueryPerformanceFactor *string `json:"queryPerformanceFactor,omitempty"`
118118
}
119119

120120
func (o UpdateActiveActiveDatabase) String() string {

0 commit comments

Comments
 (0)