@@ -533,7 +533,7 @@ func TestSetEffectiveConfig(t *testing.T) {
533
533
t ,
534
534
func () bool {
535
535
return rcvConfig .Load () != nil &&
536
- proto .Equal (sendConfig , rcvConfig .Load ().(* protobufs.EffectiveConfig ))
536
+ proto .Equal (sendConfig , rcvConfig .Load ().(* protobufs.EffectiveConfig ))
537
537
},
538
538
)
539
539
@@ -546,7 +546,7 @@ func TestSetEffectiveConfig(t *testing.T) {
546
546
t ,
547
547
func () bool {
548
548
return rcvConfig .Load () != nil &&
549
- proto .Equal (sendConfig , rcvConfig .Load ().(* protobufs.EffectiveConfig ))
549
+ proto .Equal (sendConfig , rcvConfig .Load ().(* protobufs.EffectiveConfig ))
550
550
},
551
551
)
552
552
@@ -765,18 +765,18 @@ func TestServerOfferConnectionSettings(t *testing.T) {
765
765
},
766
766
767
767
OnOpampConnectionSettingsFunc : func (
768
- ctx context.Context , settings * protobufs.OpAMPConnectionSettings ,
768
+ ctx context.Context , settings * protobufs.OpAMPConnectionSettings ,
769
769
) error {
770
770
assert .True (t , proto .Equal (opampSettings , settings ))
771
771
atomic .AddInt64 (& gotOpampSettings , 1 )
772
772
return nil
773
773
},
774
774
},
775
775
Capabilities : protobufs .AgentCapabilities_AgentCapabilities_ReportsOwnTraces |
776
- protobufs .AgentCapabilities_AgentCapabilities_ReportsOwnMetrics |
777
- protobufs .AgentCapabilities_AgentCapabilities_ReportsOwnLogs |
778
- protobufs .AgentCapabilities_AgentCapabilities_AcceptsOtherConnectionSettings |
779
- protobufs .AgentCapabilities_AgentCapabilities_AcceptsOpAMPConnectionSettings ,
776
+ protobufs .AgentCapabilities_AgentCapabilities_ReportsOwnMetrics |
777
+ protobufs .AgentCapabilities_AgentCapabilities_ReportsOwnLogs |
778
+ protobufs .AgentCapabilities_AgentCapabilities_AcceptsOtherConnectionSettings |
779
+ protobufs .AgentCapabilities_AgentCapabilities_AcceptsOpAMPConnectionSettings ,
780
780
}
781
781
settings .OpAMPServerURL = "ws://" + srv .Endpoint
782
782
prepareClient (t , & settings , client )
@@ -823,7 +823,7 @@ func TestClientRequestConnectionSettings(t *testing.T) {
823
823
settings := types.StartSettings {
824
824
Callbacks : types.CallbacksStruct {
825
825
OnOpampConnectionSettingsFunc : func (
826
- ctx context.Context , settings * protobufs.OpAMPConnectionSettings ,
826
+ ctx context.Context , settings * protobufs.OpAMPConnectionSettings ,
827
827
) error {
828
828
assert .True (t , proto .Equal (opampSettings , settings ))
829
829
atomic .AddInt64 (& clientGotOpampSettings , 1 )
@@ -929,7 +929,7 @@ func TestReportAgentHealth(t *testing.T) {
929
929
settings := types.StartSettings {
930
930
OpAMPServerURL : "ws://" + srv .Endpoint ,
931
931
Capabilities : protobufs .AgentCapabilities_AgentCapabilities_ReportsEffectiveConfig |
932
- protobufs .AgentCapabilities_AgentCapabilities_ReportsHealth ,
932
+ protobufs .AgentCapabilities_AgentCapabilities_ReportsHealth ,
933
933
}
934
934
prepareClient (t , & settings , client )
935
935
@@ -1090,7 +1090,7 @@ func verifyRemoteConfigUpdate(t *testing.T, successCase bool, expectStatus *prot
1090
1090
},
1091
1091
},
1092
1092
Capabilities : protobufs .AgentCapabilities_AgentCapabilities_AcceptsRemoteConfig |
1093
- protobufs .AgentCapabilities_AgentCapabilities_ReportsRemoteConfig ,
1093
+ protobufs .AgentCapabilities_AgentCapabilities_ReportsRemoteConfig ,
1094
1094
}
1095
1095
prepareClient (t , & settings , client )
1096
1096
@@ -1208,12 +1208,15 @@ type packageTestCase struct {
1208
1208
const packageUpdateErrorMsg = "cannot update packages"
1209
1209
1210
1210
func assertPackageStatus (t * testing.T ,
1211
- testCase packageTestCase ,
1212
- msg * protobufs.AgentToServer ) (* protobufs.ServerToAgent , bool ) {
1211
+ testCase packageTestCase ,
1212
+ msg * protobufs.AgentToServer ) (* protobufs.ServerToAgent , bool ) {
1213
1213
expectedStatusReceived := false
1214
1214
1215
1215
status := msg .PackageStatuses
1216
- require .NotNil (t , status )
1216
+ if status == nil {
1217
+ // PackageStatuses is not yet reported, keep waiting.
1218
+ return nil , false
1219
+ }
1217
1220
assert .EqualValues (t , testCase .expectedStatus .ServerProvidedAllPackagesHash , status .ServerProvidedAllPackagesHash )
1218
1221
1219
1222
if testCase .expectedError != "" {
@@ -1286,7 +1289,7 @@ func verifyUpdatePackages(t *testing.T, testCase packageTestCase) {
1286
1289
},
1287
1290
PackagesStateProvider : localPackageState ,
1288
1291
Capabilities : protobufs .AgentCapabilities_AgentCapabilities_AcceptsPackages |
1289
- protobufs .AgentCapabilities_AgentCapabilities_ReportsPackageStatuses ,
1292
+ protobufs .AgentCapabilities_AgentCapabilities_ReportsPackageStatuses ,
1290
1293
}
1291
1294
prepareClient (t , & settings , client )
1292
1295
@@ -1309,7 +1312,7 @@ func verifyUpdatePackages(t *testing.T, testCase packageTestCase) {
1309
1312
// ---> Server
1310
1313
// Wait for the expected package statuses to be received.
1311
1314
srv .EventuallyExpect ("full PackageStatuses" , func (msg * protobufs.AgentToServer ) (* protobufs.ServerToAgent ,
1312
- bool ) {
1315
+ bool ) {
1313
1316
return assertPackageStatus (t , testCase , msg )
1314
1317
})
1315
1318
@@ -1470,7 +1473,7 @@ func TestMissingCapabilities(t *testing.T) {
1470
1473
assert .Nil (t , msg .PackagesAvailable )
1471
1474
},
1472
1475
OnOpampConnectionSettingsFunc : func (
1473
- ctx context.Context , settings * protobufs.OpAMPConnectionSettings ,
1476
+ ctx context.Context , settings * protobufs.OpAMPConnectionSettings ,
1474
1477
) error {
1475
1478
assert .Fail (t , "should not be called since capability is not set to accept it" )
1476
1479
return nil
@@ -1532,7 +1535,7 @@ func TestMissingPackagesStateProvider(t *testing.T) {
1532
1535
settings := types.StartSettings {
1533
1536
Callbacks : types.CallbacksStruct {},
1534
1537
Capabilities : protobufs .AgentCapabilities_AgentCapabilities_AcceptsPackages |
1535
- protobufs .AgentCapabilities_AgentCapabilities_ReportsPackageStatuses ,
1538
+ protobufs .AgentCapabilities_AgentCapabilities_ReportsPackageStatuses ,
1536
1539
}
1537
1540
prepareClient (t , & settings , client )
1538
1541
@@ -1590,7 +1593,7 @@ func TestOfferUpdatedVersion(t *testing.T) {
1590
1593
},
1591
1594
PackagesStateProvider : localPackageState ,
1592
1595
Capabilities : protobufs .AgentCapabilities_AgentCapabilities_AcceptsPackages |
1593
- protobufs .AgentCapabilities_AgentCapabilities_ReportsPackageStatuses ,
1596
+ protobufs .AgentCapabilities_AgentCapabilities_ReportsPackageStatuses ,
1594
1597
}
1595
1598
prepareClient (t , & settings , client )
1596
1599
@@ -1612,7 +1615,7 @@ func TestOfferUpdatedVersion(t *testing.T) {
1612
1615
// ---> Server
1613
1616
// Wait for the expected package statuses to be received.
1614
1617
srv .EventuallyExpect ("full PackageStatuses" , func (msg * protobufs.AgentToServer ) (* protobufs.ServerToAgent ,
1615
- bool ) {
1618
+ bool ) {
1616
1619
return assertPackageStatus (t , testCase , msg )
1617
1620
})
1618
1621
@@ -1639,7 +1642,7 @@ func TestOfferUpdatedVersion(t *testing.T) {
1639
1642
// ---> Server
1640
1643
// Wait for the expected package statuses to be received.
1641
1644
srv .EventuallyExpect ("full PackageStatuses updated version" , func (msg * protobufs.AgentToServer ) (* protobufs.ServerToAgent ,
1642
- bool ) {
1645
+ bool ) {
1643
1646
return assertPackageStatus (t , testCase , msg )
1644
1647
})
1645
1648
0 commit comments