@@ -16,7 +16,6 @@ package e2e
16
16
17
17
import (
18
18
"fmt"
19
- "os"
20
19
"testing"
21
20
"time"
22
21
@@ -77,12 +76,14 @@ var message = "Agent: '%s' is %s with principal"
77
76
func (suite * ClusterInfoTestSuite ) Test_ClusterInfo_Managed () {
78
77
requires := suite .Require ()
79
78
79
+ clusterDetail := suite .ClusterDetails
80
+
80
81
// Verify that connection status has been updated when agent is already connected
81
82
requires .Eventually (func () bool {
82
- return fixture .HasConnectionStatus (os . Getenv ( fixture .ManagedAgentServerKey ) , appv1.ConnectionState {
83
+ return fixture .HasConnectionStatus (fixture .AgentManagedName , appv1.ConnectionState {
83
84
Status : appv1 .ConnectionStatusSuccessful ,
84
85
Message : fmt .Sprintf (message , fixture .AgentManagedName , "connected" ),
85
- })
86
+ }, clusterDetail )
86
87
}, 30 * time .Second , 1 * time .Second )
87
88
88
89
// Stop the agent
@@ -91,11 +92,11 @@ func (suite *ClusterInfoTestSuite) Test_ClusterInfo_Managed() {
91
92
92
93
// Verify that connection status is updated when agent is disconnected
93
94
requires .Eventually (func () bool {
94
- return fixture .HasConnectionStatus (os . Getenv ( fixture .ManagedAgentServerKey ) , appv1.ConnectionState {
95
+ return fixture .HasConnectionStatus (fixture .AgentManagedName , appv1.ConnectionState {
95
96
Status : appv1 .ConnectionStatusFailed ,
96
97
Message : fmt .Sprintf (message , fixture .AgentManagedName , "disconnected" ),
97
98
ModifiedAt : & metav1.Time {Time : time .Now ()},
98
- })
99
+ }, clusterDetail )
99
100
}, 30 * time .Second , 1 * time .Second )
100
101
101
102
// Restart the agent
@@ -105,23 +106,24 @@ func (suite *ClusterInfoTestSuite) Test_ClusterInfo_Managed() {
105
106
106
107
// Verify that connection status is updated again when agent is re-connected
107
108
requires .Eventually (func () bool {
108
- return fixture .HasConnectionStatus (os . Getenv ( fixture .ManagedAgentServerKey ) , appv1.ConnectionState {
109
+ return fixture .HasConnectionStatus (fixture .AgentManagedName , appv1.ConnectionState {
109
110
Status : appv1 .ConnectionStatusSuccessful ,
110
111
Message : fmt .Sprintf (message , fixture .AgentManagedName , "connected" ),
111
112
ModifiedAt : & metav1.Time {Time : time .Now ()},
112
- })
113
+ }, clusterDetail )
113
114
}, 30 * time .Second , 1 * time .Second )
114
115
}
115
116
116
117
func (suite * ClusterInfoTestSuite ) Test_ClusterInfo_Autonomous () {
117
118
requires := suite .Require ()
119
+ clusterDetail := suite .ClusterDetails
118
120
119
121
// Verify the connection status is updated when agent is already connected
120
122
requires .Eventually (func () bool {
121
- return fixture .HasConnectionStatus (os . Getenv ( fixture .AutonomousAgentServerKey ) , appv1.ConnectionState {
123
+ return fixture .HasConnectionStatus (fixture .AgentAutonomousName , appv1.ConnectionState {
122
124
Status : appv1 .ConnectionStatusSuccessful ,
123
125
Message : fmt .Sprintf (message , fixture .AgentAutonomousName , "connected" ),
124
- })
126
+ }, clusterDetail )
125
127
}, 30 * time .Second , 1 * time .Second )
126
128
127
129
// Stop the agent
@@ -130,11 +132,11 @@ func (suite *ClusterInfoTestSuite) Test_ClusterInfo_Autonomous() {
130
132
131
133
// Verify that connection status is updated when agent is disconnected
132
134
requires .Eventually (func () bool {
133
- return fixture .HasConnectionStatus (os . Getenv ( fixture .AutonomousAgentServerKey ) , appv1.ConnectionState {
135
+ return fixture .HasConnectionStatus (fixture .AgentAutonomousName , appv1.ConnectionState {
134
136
Status : appv1 .ConnectionStatusFailed ,
135
137
Message : fmt .Sprintf (message , fixture .AgentAutonomousName , "disconnected" ),
136
138
ModifiedAt : & metav1.Time {Time : time .Now ()},
137
- })
139
+ }, clusterDetail )
138
140
}, 30 * time .Second , 1 * time .Second )
139
141
140
142
// Restart the agent
@@ -144,21 +146,22 @@ func (suite *ClusterInfoTestSuite) Test_ClusterInfo_Autonomous() {
144
146
145
147
// Verify that connection status is updated again when agent is re-connected
146
148
requires .Eventually (func () bool {
147
- return fixture .HasConnectionStatus (os . Getenv ( fixture .AutonomousAgentServerKey ) , appv1.ConnectionState {
149
+ return fixture .HasConnectionStatus (fixture .AgentAutonomousName , appv1.ConnectionState {
148
150
Status : appv1 .ConnectionStatusSuccessful ,
149
151
Message : fmt .Sprintf (message , fixture .AgentAutonomousName , "connected" ),
150
152
ModifiedAt : & metav1.Time {Time : time .Now ()},
151
- })
153
+ }, clusterDetail )
152
154
}, 30 * time .Second , 1 * time .Second )
153
155
}
154
156
155
157
// This test suite validates the cluster cache info reporting for managed agent.
156
158
// It checks that the cluster cache info is correctly propagated from agent to principal.
157
159
func (suite * ClusterInfoTestSuite ) Test_ClusterCacheInfo () {
158
160
requires := suite .Require ()
161
+ clusterDetail := suite .ClusterDetails
159
162
160
163
// We need to know the number of existing applications before running test
161
- agentCacheInfo , err := fixture .GetManagedAgentClusterInfo ()
164
+ agentCacheInfo , err := fixture .GetManagedAgentClusterInfo (clusterDetail )
162
165
requires .NoError (err )
163
166
appCountBefore := agentCacheInfo .ApplicationsCount
164
167
@@ -172,11 +175,11 @@ func (suite *ClusterInfoTestSuite) Test_ClusterCacheInfo() {
172
175
// Verify that cluster cache info has been updated for first application in agent cluster by Argo CD
173
176
// and then agent updated principal with this information
174
177
requires .Eventually (func () bool {
175
- return fixture .HasApplicationsCount (appCountBefore + 1 )
178
+ return fixture .HasApplicationsCount (appCountBefore + 1 , clusterDetail )
176
179
}, 90 * time .Second , 5 * time .Second )
177
180
178
181
requires .Eventually (func () bool {
179
- return fixture .HasClusterCacheInfoSynced (os . Getenv ( fixture .ManagedAgentServerKey ) )
182
+ return fixture .HasClusterCacheInfoSynced (fixture .AgentManagedName , clusterDetail )
180
183
}, 90 * time .Second , 5 * time .Second )
181
184
182
185
// Step 3:
@@ -189,11 +192,11 @@ func (suite *ClusterInfoTestSuite) Test_ClusterCacheInfo() {
189
192
// Verify that cluster cache info has been updated by Argo CD for second application in agent cluster
190
193
// and then agent again updated principal with this new information
191
194
requires .Eventually (func () bool {
192
- return fixture .HasApplicationsCount (appCountBefore + 2 )
195
+ return fixture .HasApplicationsCount (appCountBefore + 2 , clusterDetail )
193
196
}, 90 * time .Second , 5 * time .Second )
194
197
195
198
requires .Eventually (func () bool {
196
- return fixture .HasClusterCacheInfoSynced (os . Getenv ( fixture .ManagedAgentServerKey ) )
199
+ return fixture .HasClusterCacheInfoSynced (fixture .AgentManagedName , clusterDetail )
197
200
}, 90 * time .Second , 5 * time .Second )
198
201
199
202
// Step 5:
@@ -210,37 +213,37 @@ func (suite *ClusterInfoTestSuite) Test_ClusterCacheInfo() {
210
213
// Verify that cluster cache info has been updated again by Argo CD after deleting the first application
211
214
// and then agent again updated principal with this new information
212
215
requires .Eventually (func () bool {
213
- return fixture .HasApplicationsCount (appCountBefore + 1 )
216
+ return fixture .HasApplicationsCount (appCountBefore + 1 , clusterDetail )
214
217
}, 90 * time .Second , 5 * time .Second )
215
218
216
219
requires .Eventually (func () bool {
217
- return fixture .HasClusterCacheInfoSynced (os . Getenv ( fixture .ManagedAgentServerKey ) )
220
+ return fixture .HasClusterCacheInfoSynced (fixture .AgentManagedName , clusterDetail )
218
221
}, 90 * time .Second , 5 * time .Second )
219
222
220
223
// Step 7:
221
224
// Verify that existing agent connection status is preserved when cluster cache info is updated
222
225
requires .Eventually (func () bool {
223
- return fixture .HasConnectionStatus (os . Getenv ( fixture .ManagedAgentServerKey ) , appv1.ConnectionState {
226
+ return fixture .HasConnectionStatus (fixture .AgentManagedName , appv1.ConnectionState {
224
227
Status : appv1 .ConnectionStatusSuccessful ,
225
228
Message : fmt .Sprintf (message , fixture .AgentManagedName , "connected" ),
226
- })
229
+ }, clusterDetail )
227
230
}, 30 * time .Second , 1 * time .Second )
228
231
229
232
// Step 8:
230
233
// Disconnect agent and verify that connection status is changed to Failed
231
234
requires .NoError (fixture .StopProcess (fixture .AgentManagedName ))
232
235
requires .Eventually (func () bool {
233
- return fixture .HasConnectionStatus (os . Getenv ( fixture .ManagedAgentServerKey ) , appv1.ConnectionState {
236
+ return fixture .HasConnectionStatus (fixture .AgentManagedName , appv1.ConnectionState {
234
237
Status : appv1 .ConnectionStatusFailed ,
235
238
Message : fmt .Sprintf (message , fixture .AgentManagedName , "disconnected" ),
236
239
ModifiedAt : & metav1.Time {Time : time .Now ()},
237
- })
240
+ }, clusterDetail )
238
241
}, 60 * time .Second , 2 * time .Second )
239
242
240
243
// Step 9:
241
244
// Since agent is disconnected, cluster cache info should reset to default
242
245
requires .Eventually (func () bool {
243
- ci , err := fixture .GetPrincipalClusterInfo (os . Getenv ( fixture .ManagedAgentServerKey ) )
246
+ ci , err := fixture .GetPrincipalClusterInfo (fixture .AgentManagedName , clusterDetail )
244
247
if err != nil {
245
248
return false
246
249
}
@@ -253,14 +256,14 @@ func (suite *ClusterInfoTestSuite) Test_ClusterCacheInfo() {
253
256
fixture .CheckReadiness (suite .T (), fixture .AgentManagedName )
254
257
255
258
requires .Eventually (func () bool {
256
- return fixture .HasConnectionStatus (os . Getenv ( fixture .ManagedAgentServerKey ) , appv1.ConnectionState {
259
+ return fixture .HasConnectionStatus (fixture .AgentManagedName , appv1.ConnectionState {
257
260
Status : appv1 .ConnectionStatusSuccessful ,
258
261
Message : fmt .Sprintf (message , fixture .AgentManagedName , "connected" ),
259
262
ModifiedAt : & metav1.Time {Time : time .Now ()},
260
- })
263
+ }, clusterDetail )
261
264
}, 60 * time .Second , 2 * time .Second )
262
265
263
266
requires .Eventually (func () bool {
264
- return fixture .HasClusterCacheInfoSynced (os . Getenv ( fixture .ManagedAgentServerKey ) )
267
+ return fixture .HasClusterCacheInfoSynced (fixture .AgentManagedName , clusterDetail )
265
268
}, 90 * time .Second , 5 * time .Second )
266
269
}
0 commit comments