@@ -42,6 +42,15 @@ export class WorkspaceClusterDBSpec {
42
42
maxScore : 100 ,
43
43
govern : true ,
44
44
} ;
45
+ const wsc1a : DBWorkspaceCluster = {
46
+ name : "eu71" ,
47
+ applicationCluster : "us02" ,
48
+ url : "some-url" ,
49
+ state : "cordoned" ,
50
+ score : 0 ,
51
+ maxScore : 0 ,
52
+ govern : false ,
53
+ } ;
45
54
const wsc2 : DBWorkspaceCluster = {
46
55
name : "us71" ,
47
56
applicationCluster : "eu02" ,
@@ -53,22 +62,26 @@ export class WorkspaceClusterDBSpec {
53
62
} ;
54
63
55
64
await this . db . save ( wsc1 ) ;
65
+ await this . db . save ( wsc1a ) ;
56
66
await this . db . save ( wsc2 ) ;
57
67
58
68
// Can find the eu71 cluster as seen by the eu02 application cluster.
59
69
const result = await this . db . findByName ( "eu71" , "eu02" ) ;
60
70
expect ( result ) . not . to . be . undefined ;
61
71
expect ( ( result as WorkspaceCluster ) . name ) . to . equal ( "eu71" ) ;
72
+ expect ( ( result as WorkspaceCluster ) . applicationCluster ) . to . equal ( "eu02" ) ;
62
73
63
- // Can't find the eu71 cluster as seen by the us02 application cluster.
64
- // (no record in the db for that (ws-cluster, app-cluster) combination).
74
+ // Can find the eu71 cluster as seen by the us02 application cluster.
65
75
const result2 = await this . db . findByName ( "eu71" , "us02" ) ;
66
- expect ( result2 ) . to . be . undefined ;
76
+ expect ( result2 ) . not . to . be . undefined ;
77
+ expect ( ( result2 as WorkspaceCluster ) . name ) . to . equal ( "eu71" ) ;
78
+ expect ( ( result2 as WorkspaceCluster ) . applicationCluster ) . to . equal ( "us02" ) ;
67
79
68
80
// Can find the us71 cluster as seen by the eu02 application cluster.
69
81
const result3 = await this . db . findByName ( "us71" , "eu02" ) ;
70
82
expect ( result3 ) . not . to . be . undefined ;
71
83
expect ( ( result3 as WorkspaceCluster ) . name ) . to . equal ( "us71" ) ;
84
+ expect ( ( result3 as WorkspaceCluster ) . applicationCluster ) . to . equal ( "eu02" ) ;
72
85
}
73
86
74
87
@test public async deleteByName ( ) {
@@ -81,6 +94,15 @@ export class WorkspaceClusterDBSpec {
81
94
maxScore : 100 ,
82
95
govern : true ,
83
96
} ;
97
+ const wsc1a : DBWorkspaceCluster = {
98
+ name : "eu71" ,
99
+ applicationCluster : "us02" ,
100
+ url : "some-url" ,
101
+ state : "cordoned" ,
102
+ score : 0 ,
103
+ maxScore : 0 ,
104
+ govern : false ,
105
+ } ;
84
106
const wsc2 : DBWorkspaceCluster = {
85
107
name : "us71" ,
86
108
applicationCluster : "eu02" ,
@@ -92,11 +114,13 @@ export class WorkspaceClusterDBSpec {
92
114
} ;
93
115
94
116
await this . db . save ( wsc1 ) ;
117
+ await this . db . save ( wsc1a ) ;
95
118
await this . db . save ( wsc2 ) ;
96
119
97
120
// Can delete the eu71 cluster as seen by the eu02 application cluster.
98
121
await this . db . deleteByName ( "eu71" , "eu02" ) ;
99
122
expect ( await this . db . findByName ( "eu71" , "eu02" ) ) . to . be . undefined ;
123
+ expect ( await this . db . findByName ( "eu71" , "us02" ) ) . not . to . be . undefined ;
100
124
expect ( await this . db . findByName ( "us71" , "eu02" ) ) . not . to . be . undefined ;
101
125
}
102
126
@@ -110,6 +134,15 @@ export class WorkspaceClusterDBSpec {
110
134
maxScore : 100 ,
111
135
govern : true ,
112
136
} ;
137
+ const wsc1a : DBWorkspaceCluster = {
138
+ name : "eu71" ,
139
+ applicationCluster : "us02" ,
140
+ url : "some-url" ,
141
+ state : "cordoned" ,
142
+ score : 0 ,
143
+ maxScore : 0 ,
144
+ govern : false ,
145
+ } ;
113
146
const wsc2 : DBWorkspaceCluster = {
114
147
name : "us71" ,
115
148
applicationCluster : "eu02" ,
@@ -121,11 +154,13 @@ export class WorkspaceClusterDBSpec {
121
154
} ;
122
155
123
156
await this . db . save ( wsc1 ) ;
157
+ await this . db . save ( wsc1a ) ;
124
158
await this . db . save ( wsc2 ) ;
125
159
126
160
const wscs = await this . db . findFiltered ( { name : "eu71" , applicationCluster : "eu02" } ) ;
127
161
expect ( wscs . length ) . to . equal ( 1 ) ;
128
162
expect ( wscs [ 0 ] . name ) . to . equal ( "eu71" ) ;
163
+ expect ( wscs [ 0 ] . applicationCluster ) . to . equal ( "eu02" ) ;
129
164
}
130
165
131
166
@test public async testFindFilteredByApplicationCluster ( ) {
@@ -138,6 +173,15 @@ export class WorkspaceClusterDBSpec {
138
173
maxScore : 100 ,
139
174
govern : true ,
140
175
} ;
176
+ const wsc1a : DBWorkspaceCluster = {
177
+ name : "eu71" ,
178
+ applicationCluster : "us02" ,
179
+ url : "some-url" ,
180
+ state : "cordoned" ,
181
+ score : 0 ,
182
+ maxScore : 0 ,
183
+ govern : false ,
184
+ } ;
141
185
const wsc2 : DBWorkspaceCluster = {
142
186
name : "us71" ,
143
187
applicationCluster : "us02" ,
@@ -149,11 +193,20 @@ export class WorkspaceClusterDBSpec {
149
193
} ;
150
194
151
195
await this . db . save ( wsc1 ) ;
196
+ await this . db . save ( wsc1a ) ;
152
197
await this . db . save ( wsc2 ) ;
153
198
154
199
const wscs = await this . db . findFiltered ( { applicationCluster : "eu02" } ) ;
155
200
expect ( wscs . length ) . to . equal ( 1 ) ;
156
201
expect ( wscs [ 0 ] . name ) . to . equal ( "eu71" ) ;
202
+
203
+ const wscs2 = await this . db . findFiltered ( { applicationCluster : "us02" } ) ;
204
+ expect ( wscs2 . length ) . to . equal ( 2 ) ;
205
+ wscs2 . sort ( ( x , y ) => x . name . localeCompare ( y . name ) ) ;
206
+ expect ( wscs2 [ 0 ] . name ) . to . equal ( "eu71" ) ;
207
+ expect ( wscs2 [ 0 ] . applicationCluster ) . to . equal ( "us02" ) ;
208
+ expect ( wscs2 [ 1 ] . name ) . to . equal ( "us71" ) ;
209
+ expect ( wscs2 [ 1 ] . applicationCluster ) . to . equal ( "us02" ) ;
157
210
}
158
211
}
159
212
0 commit comments