Skip to content

Commit a10b8fc

Browse files
Query Performance Factors: get, list (#198)
* feat: query performance factor in create databases and tests * test: added new params in testdatabase_create * feat: updating database update command and tests * feat: performance query factor in get/list SDK and test update * feat: performance query factor in active active subs * Feat/performance query factors (#199) * Updates to exclude .envrc file through .gitignore * Updates the Database model with QueryPerformanceFactor property --------- Co-authored-by: Trent Rosenbaum <[email protected]>
1 parent fc57188 commit a10b8fc

File tree

7 files changed

+71
-43
lines changed

7 files changed

+71
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,4 @@ $RECYCLE.BIN/
271271

272272
bin/
273273
vendor
274+
.envrc

active_active_database_test.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,7 @@ import (
1313
)
1414

1515
func TestAADatabase_List(t *testing.T) {
16-
s := httptest.NewServer(
17-
testServer(
18-
"apiKey",
19-
"secret",
20-
getRequestWithQuery(
21-
t,
22-
"/subscriptions/111478/databases",
23-
map[string][]string{"limit": {"100"}, "offset": {"0"}},
24-
`{
16+
body := `{
2517
"accountId": 69369,
2618
"subscription": [
2719
{
@@ -56,6 +48,7 @@ func TestAADatabase_List(t *testing.T) {
5648
"readOperationsPerSecond": 1000,
5749
"writeOperationsPerSecond": 1000,
5850
"dataPersistence": "none",
51+
"queryPerformanceFactor": "Standard",
5952
"alerts": [
6053
{
6154
"id": "51054122-2",
@@ -93,6 +86,7 @@ func TestAADatabase_List(t *testing.T) {
9386
"readOperationsPerSecond": 1000,
9487
"writeOperationsPerSecond": 1000,
9588
"dataPersistence": "none",
89+
"queryPerformanceFactor": "Standard",
9690
"alerts": [
9791
{
9892
"id": "51054121-2",
@@ -131,7 +125,19 @@ func TestAADatabase_List(t *testing.T) {
131125
"href": "https://api-staging.qa.redislabs.com/v1/subscriptions/111478/databases?offset=0&limit=100"
132126
}
133127
]
134-
}`,
128+
}`
129+
130+
query := map[string][]string{"limit": {"100"}, "offset": {"0"}}
131+
132+
s := httptest.NewServer(
133+
testServer(
134+
"apiKey",
135+
"secret",
136+
getRequestWithQuery(
137+
t,
138+
"/subscriptions/111478/databases",
139+
query,
140+
body,
135141
),
136142
getRequestWithQueryAndStatus(
137143
t,
@@ -182,6 +188,7 @@ func TestAADatabase_List(t *testing.T) {
182188
ReadOperationsPerSecond: redis.Int(1000),
183189
WriteOperationsPerSecond: redis.Int(1000),
184190
DataPersistence: redis.String("none"),
191+
QueryPerformanceFactor: redis.String("Standard"),
185192
Alerts: []*databases.Alert{
186193
{
187194
Name: redis.String("dataset-size"),
@@ -213,6 +220,7 @@ func TestAADatabase_List(t *testing.T) {
213220
ReadOperationsPerSecond: redis.Int(1000),
214221
WriteOperationsPerSecond: redis.Int(1000),
215222
DataPersistence: redis.String("none"),
223+
QueryPerformanceFactor: redis.String("Standard"),
216224
Alerts: []*databases.Alert{
217225
{
218226
Name: redis.String("dataset-size"),

database_test.go

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func TestDatabase_Create(t *testing.T) {
2525
"useExternalEndpointForOSSClusterApi": false,
2626
"dataPersistence": "none",
2727
"dataEvictionPolicy": "allkeys-lru",
28+
"queryPerformanceFactor": "6x",
2829
"replication": true,
2930
"throughputMeasurement": {
3031
"by": "operations-per-second",
@@ -94,6 +95,7 @@ func TestDatabase_Create(t *testing.T) {
9495
UseExternalEndpointForOSSClusterAPI: redis.Bool(false),
9596
DataPersistence: redis.String("none"),
9697
DataEvictionPolicy: redis.String("allkeys-lru"),
98+
QueryPerformanceFactor: redis.String("6x"),
9799
Replication: redis.Bool(true),
98100
ThroughputMeasurement: &databases.CreateThroughputMeasurement{
99101
By: redis.String("operations-per-second"),
@@ -135,14 +137,16 @@ func TestDatabase_List(t *testing.T) {
135137
"name": "first-example",
136138
"protocol": "redis",
137139
"provider": "AWS",
138-
"region": "eu-west-1"
140+
"region": "eu-west-1",
141+
"queryPerformanceFactor": "Standard"
139142
},
140143
{
141144
"databaseId": 43,
142145
"name": "second-example",
143146
"protocol": "redis",
144147
"provider": "AWS",
145-
"region": "eu-west-1"
148+
"region": "eu-west-1",
149+
"queryPerformanceFactor": "Standard"
146150
}
147151
]
148152
}
@@ -168,18 +172,20 @@ func TestDatabase_List(t *testing.T) {
168172

169173
assert.Equal(t, []*databases.Database{
170174
{
171-
ID: redis.Int(42),
172-
Name: redis.String("first-example"),
173-
Protocol: redis.String("redis"),
174-
Provider: redis.String("AWS"),
175-
Region: redis.String("eu-west-1"),
175+
ID: redis.Int(42),
176+
Name: redis.String("first-example"),
177+
Protocol: redis.String("redis"),
178+
Provider: redis.String("AWS"),
179+
Region: redis.String("eu-west-1"),
180+
QueryPerformanceFactor: redis.String("Standard"),
176181
},
177182
{
178-
ID: redis.Int(43),
179-
Name: redis.String("second-example"),
180-
Protocol: redis.String("redis"),
181-
Provider: redis.String("AWS"),
182-
Region: redis.String("eu-west-1"),
183+
ID: redis.Int(43),
184+
Name: redis.String("second-example"),
185+
Protocol: redis.String("redis"),
186+
Provider: redis.String("AWS"),
187+
Region: redis.String("eu-west-1"),
188+
QueryPerformanceFactor: redis.String("Standard"),
183189
},
184190
}, actual)
185191

@@ -209,6 +215,7 @@ func TestDatabase_Get(t *testing.T) {
209215
"by": "operations-per-second",
210216
"value": 10000
211217
},
218+
"QueryPerformanceFactor": "Standard",
212219
"activatedOn": "2020-11-03T09:03:30Z",
213220
"lastModified": "2020-11-03T09:03:30Z",
214221
"publicEndpoint": "example.com:16668",
@@ -284,6 +291,7 @@ func TestDatabase_Get(t *testing.T) {
284291
By: redis.String("operations-per-second"),
285292
Value: redis.Int(10_000),
286293
},
294+
QueryPerformanceFactor: redis.String("Standard"),
287295
Clustering: &databases.Clustering{
288296
NumberOfShards: redis.Int(1),
289297
RegexRules: []*databases.RegexRule{
@@ -355,7 +363,8 @@ func TestDatabase_Update(t *testing.T) {
355363
"value": 80
356364
}
357365
],
358-
"enableDefaultUser": false
366+
"enableDefaultUser": false,
367+
"queryPerformanceFactor": "2x"
359368
}`, `{
360369
"taskId": "task",
361370
"commandType": "databaseUpdateRequest",
@@ -415,7 +424,8 @@ func TestDatabase_Update(t *testing.T) {
415424
Value: redis.Int(80),
416425
},
417426
},
418-
EnableDefaultUser: redis.Bool(false),
427+
EnableDefaultUser: redis.Bool(false),
428+
QueryPerformanceFactor: redis.String("2x"),
419429
})
420430
require.NoError(t, err)
421431
}

service/databases/model.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ type CreateDatabase struct {
2323
AverageItemSizeInBytes *int `json:"averageItemSizeInBytes,omitempty"`
2424
ReplicaOf []*string `json:"replicaOf,omitempty"`
2525
// Deprecated: Use RemoteBackup instead
26-
PeriodicBackupPath *string `json:"periodicBackupPath,omitempty"`
27-
SourceIP []*string `json:"sourceIp,omitempty"`
28-
ClientSSLCertificate *string `json:"clientSslCertificate,omitempty"`
29-
ClientTLSCertificates *[]*string `json:"clientTlsCertificates,omitempty"`
30-
Password *string `json:"password,omitempty"`
31-
Alerts []*Alert `json:"alerts,omitempty"`
32-
Modules []*Module `json:"modules,omitempty"`
33-
EnableTls *bool `json:"enableTls,omitempty"`
34-
PortNumber *int `json:"port,omitempty"`
35-
RemoteBackup *DatabaseBackupConfig `json:"remoteBackup,omitempty"`
26+
PeriodicBackupPath *string `json:"periodicBackupPath,omitempty"`
27+
SourceIP []*string `json:"sourceIp,omitempty"`
28+
ClientSSLCertificate *string `json:"clientSslCertificate,omitempty"`
29+
ClientTLSCertificates *[]*string `json:"clientTlsCertificates,omitempty"`
30+
Password *string `json:"password,omitempty"`
31+
Alerts []*Alert `json:"alerts,omitempty"`
32+
Modules []*Module `json:"modules,omitempty"`
33+
EnableTls *bool `json:"enableTls,omitempty"`
34+
PortNumber *int `json:"port,omitempty"`
35+
RemoteBackup *DatabaseBackupConfig `json:"remoteBackup,omitempty"`
36+
QueryPerformanceFactor *string `json:"queryPerformanceFactor,omitempty"`
3637
}
3738

3839
func (o CreateDatabase) String() string {
@@ -78,6 +79,7 @@ type Database struct {
7879
PublicEndpoint *string `json:"publicEndpoint,omitempty"`
7980
RedisVersionCompliance *string `json:"redisVersionCompliance,omitempty"`
8081
Backup *Backup `json:"backup,omitempty"`
82+
QueryPerformanceFactor *string `json:"queryPerformanceFactor,omitempty"`
8183
}
8284

8385
func (o Database) String() string {
@@ -169,10 +171,11 @@ type UpdateDatabase struct {
169171
// It's important to use a pointer here, because the terraform user may want to send an empty list.
170172
// In that case, the developer must pass a (pointer to a) non-nil, zero-length slice
171173
// If the developer really wants to omit this value, passing a nil slice value would work
172-
Alerts *[]*Alert `json:"alerts,omitempty"`
173-
EnableTls *bool `json:"enableTls,omitempty"`
174-
RemoteBackup *DatabaseBackupConfig `json:"remoteBackup,omitempty"`
175-
EnableDefaultUser *bool `json:"enableDefaultUser,omitempty"`
174+
Alerts *[]*Alert `json:"alerts,omitempty"`
175+
EnableTls *bool `json:"enableTls,omitempty"`
176+
RemoteBackup *DatabaseBackupConfig `json:"remoteBackup,omitempty"`
177+
EnableDefaultUser *bool `json:"enableDefaultUser,omitempty"`
178+
QueryPerformanceFactor *string `json:"queryPerformanceFactor,omitempty"`
176179
}
177180

178181
func (o UpdateDatabase) String() string {

service/databases/model_active_active.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type CrdbDatabase struct {
4242
Alerts []*Alert `json:"alerts,omitempty"`
4343
Security *Security `json:"security,omitempty"`
4444
Backup *Backup `json:"backup,omitempty"`
45+
QueryPerformanceFactor *string `json:"queryPerformanceFactor,omitempty"`
4546
}
4647

4748
func (o CrdbDatabase) String() string {
@@ -76,6 +77,7 @@ type CreateActiveActiveDatabase struct {
7677
GlobalModules []*Module `json:"modules,omitempty"`
7778
LocalThroughputMeasurement []*LocalThroughput `json:"localThroughputMeasurement,omitempty"`
7879
PortNumber *int `json:"port,omitempty"`
80+
QueryPerformanceFactor *string `json:"queryPerformanceFactor,omitempty"`
7981
}
8082

8183
func (o CreateActiveActiveDatabase) String() string {
@@ -106,9 +108,10 @@ type UpdateActiveActiveDatabase struct {
106108
GlobalPassword *string `json:"globalPassword,omitempty"`
107109
GlobalSourceIP []*string `json:"globalSourceIp,omitempty"`
108110
// Using a pointer to allow empty slices to be serialised/sent
109-
GlobalAlerts *[]*Alert `json:"globalAlerts,omitempty"`
110-
Regions []*LocalRegionProperties `json:"regions,omitempty"`
111-
DataEvictionPolicy *string `json:"dataEvictionPolicy,omitempty"`
111+
GlobalAlerts *[]*Alert `json:"globalAlerts,omitempty"`
112+
Regions []*LocalRegionProperties `json:"regions,omitempty"`
113+
DataEvictionPolicy *string `json:"dataEvictionPolicy,omitempty"`
114+
QueryPerformanceFactor *string `json:"queryPerformanceFactor,omitempty"`
112115
}
113116

114117
func (o UpdateActiveActiveDatabase) String() string {

service/subscriptions/model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ type CreateDatabase struct {
6565
Modules []*CreateModules `json:"modules,omitempty"`
6666
Quantity *int `json:"quantity,omitempty"`
6767
AverageItemSizeInBytes *int `json:"averageItemSizeInBytes,omitempty"`
68+
QueryPerformanceFactor *string `json:"queryPerformanceFactor,omitempty"`
6869
}
6970

7071
func (o CreateDatabase) String() string {

subscription_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ func TestSubscription_Create(t *testing.T) {
4444
"by": "operations-per-second",
4545
"value": 10000
4646
},
47-
"quantity": 1
47+
"quantity": 1,
48+
"queryPerformanceFactor": "4x"
4849
}
4950
],
5051
"redisVersion": "latest"
@@ -133,7 +134,8 @@ func TestSubscription_Create(t *testing.T) {
133134
By: redis.String("operations-per-second"),
134135
Value: redis.Int(10000),
135136
},
136-
Quantity: redis.Int(1),
137+
Quantity: redis.Int(1),
138+
QueryPerformanceFactor: redis.String("4x"),
137139
},
138140
},
139141
RedisVersion: redis.String("latest"),

0 commit comments

Comments
 (0)