-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pba: Update agent tests to include GS's gtw admin/tech contacts priority
- Loading branch information
1 parent
7099bda
commit 00d1e3e
Showing
1 changed file
with
118 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -461,63 +461,131 @@ func TestForwarder(t *testing.T) { | |
return ttnpb.Empty, nil | ||
} | ||
|
||
res, err := gs.UpdateGateway(ctx, &ttnpb.UpdatePacketBrokerGatewayRequest{ | ||
Gateway: &ttnpb.PacketBrokerGateway{ | ||
Ids: &ttnpb.PacketBrokerGateway_GatewayIdentifiers{ | ||
GatewayId: "foo-gateway", | ||
Eui: types.EUI64{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}.Bytes(), | ||
}, | ||
ContactInfo: []*ttnpb.ContactInfo{ | ||
{ | ||
ContactType: ttnpb.ContactType_CONTACT_TYPE_OTHER, | ||
ContactMethod: ttnpb.ContactMethod_CONTACT_METHOD_EMAIL, | ||
Value: "[email protected]", | ||
t.Run("Only contactInfo", func(t *testing.T) { | ||
res, err := gs.UpdateGateway(ctx, &ttnpb.UpdatePacketBrokerGatewayRequest{ | ||
Gateway: &ttnpb.PacketBrokerGateway{ | ||
Ids: &ttnpb.PacketBrokerGateway_GatewayIdentifiers{ | ||
GatewayId: "foo-gateway", | ||
Eui: types.EUI64{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}.Bytes(), | ||
}, | ||
{ | ||
ContactType: ttnpb.ContactType_CONTACT_TYPE_TECHNICAL, | ||
ContactMethod: ttnpb.ContactMethod_CONTACT_METHOD_EMAIL, | ||
Value: "[email protected]", | ||
ContactInfo: []*ttnpb.ContactInfo{ | ||
{ | ||
ContactType: ttnpb.ContactType_CONTACT_TYPE_OTHER, | ||
ContactMethod: ttnpb.ContactMethod_CONTACT_METHOD_EMAIL, | ||
Value: "[email protected]", | ||
}, | ||
{ | ||
ContactType: ttnpb.ContactType_CONTACT_TYPE_TECHNICAL, | ||
ContactMethod: ttnpb.ContactMethod_CONTACT_METHOD_EMAIL, | ||
Value: "[email protected]", | ||
}, | ||
}, | ||
}, | ||
FrequencyPlanIds: []string{"EU_863_870"}, | ||
Antennas: []*ttnpb.GatewayAntenna{ | ||
{ | ||
Location: &ttnpb.Location{ | ||
Latitude: 4.85464, | ||
Longitude: 52.34562, | ||
Altitude: 16, | ||
Accuracy: 10, | ||
Source: ttnpb.LocationSource_SOURCE_REGISTRY, | ||
FrequencyPlanIds: []string{"EU_863_870"}, | ||
Antennas: []*ttnpb.GatewayAntenna{ | ||
{ | ||
Location: &ttnpb.Location{ | ||
Latitude: 4.85464, | ||
Longitude: 52.34562, | ||
Altitude: 16, | ||
Accuracy: 10, | ||
Source: ttnpb.LocationSource_SOURCE_REGISTRY, | ||
}, | ||
}, | ||
}, | ||
StatusPublic: true, | ||
LocationPublic: true, | ||
Online: true, | ||
}, | ||
StatusPublic: true, | ||
LocationPublic: true, | ||
Online: true, | ||
}, | ||
FieldMask: ttnpb.FieldMask( | ||
"antennas", | ||
"contact_info", | ||
"frequency_plan_ids", | ||
"ids", | ||
"location_public", | ||
"online", | ||
"status_public", | ||
), | ||
FieldMask: ttnpb.FieldMask( | ||
"antennas", | ||
"contact_info", | ||
"frequency_plan_ids", | ||
"ids", | ||
"location_public", | ||
"online", | ||
"status_public", | ||
), | ||
}) | ||
a.So(err, should.BeNil) | ||
a.So(res.OnlineTtl.AsDuration(), should.NotBeZeroValue) | ||
|
||
select { | ||
case update := <-updateCh: | ||
a.So(update.AdministrativeContact.GetValue().GetEmail(), should.Equal, "[email protected]") | ||
a.So(update.TechnicalContact.GetValue().GetEmail(), should.Equal, "[email protected]") | ||
a.So(update.FrequencyPlan.GetLoraMultiSfChannels(), should.HaveLength, 8) | ||
a.So(update.Online.GetValue(), should.BeTrue) | ||
a.So(update.GatewayLocation.GetLocation().GetTerrestrial().GetAntennaCount().GetValue(), should.Equal, 1) | ||
case <-time.After(timeout): | ||
t.Fatal("Expected gateway update timeout") | ||
} | ||
}) | ||
a.So(err, should.BeNil) | ||
a.So(res.OnlineTtl.AsDuration(), should.NotBeZeroValue) | ||
|
||
select { | ||
case update := <-updateCh: | ||
a.So(update.AdministrativeContact.GetValue().GetEmail(), should.Equal, "[email protected]") | ||
a.So(update.TechnicalContact.GetValue().GetEmail(), should.Equal, "[email protected]") | ||
a.So(update.FrequencyPlan.GetLoraMultiSfChannels(), should.HaveLength, 8) | ||
a.So(update.Online.GetValue(), should.BeTrue) | ||
a.So(update.GatewayLocation.GetLocation().GetTerrestrial().GetAntennaCount().GetValue(), should.Equal, 1) | ||
case <-time.After(timeout): | ||
t.Fatal("Expected gateway update timeout") | ||
} | ||
t.Run("Admin and tech contacts present", func(t *testing.T) { | ||
adminId := &ttnpb.UserIdentifiers{UserId: "admin", Email: "[email protected]"} | ||
techId := &ttnpb.UserIdentifiers{UserId: "tech", Email: "[email protected]"} | ||
res, err := gs.UpdateGateway(ctx, &ttnpb.UpdatePacketBrokerGatewayRequest{ | ||
Gateway: &ttnpb.PacketBrokerGateway{ | ||
Ids: &ttnpb.PacketBrokerGateway_GatewayIdentifiers{ | ||
GatewayId: "foo-gateway", | ||
Eui: types.EUI64{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}.Bytes(), | ||
}, | ||
ContactInfo: []*ttnpb.ContactInfo{ | ||
{ | ||
ContactType: ttnpb.ContactType_CONTACT_TYPE_OTHER, | ||
ContactMethod: ttnpb.ContactMethod_CONTACT_METHOD_EMAIL, | ||
Value: "[email protected]", | ||
}, | ||
{ | ||
ContactType: ttnpb.ContactType_CONTACT_TYPE_TECHNICAL, | ||
ContactMethod: ttnpb.ContactMethod_CONTACT_METHOD_EMAIL, | ||
Value: "[email protected]", | ||
}, | ||
}, | ||
AdministrativeContact: adminId.GetOrganizationOrUserIdentifiers(), | ||
TechnicalContact: techId.GetOrganizationOrUserIdentifiers(), | ||
FrequencyPlanIds: []string{"EU_863_870"}, | ||
Antennas: []*ttnpb.GatewayAntenna{ | ||
{ | ||
Location: &ttnpb.Location{ | ||
Latitude: 4.85464, | ||
Longitude: 52.34562, | ||
Altitude: 16, | ||
Accuracy: 10, | ||
Source: ttnpb.LocationSource_SOURCE_REGISTRY, | ||
}, | ||
}, | ||
}, | ||
StatusPublic: true, | ||
LocationPublic: true, | ||
Online: true, | ||
}, | ||
FieldMask: ttnpb.FieldMask( | ||
"antennas", | ||
"contact_info", | ||
"frequency_plan_ids", | ||
"ids", | ||
"location_public", | ||
"online", | ||
"status_public", | ||
), | ||
}) | ||
a.So(err, should.BeNil) | ||
a.So(res.OnlineTtl.AsDuration(), should.NotBeZeroValue) | ||
|
||
select { | ||
case update := <-updateCh: | ||
a.So(update.AdministrativeContact.GetValue().GetName(), should.Equal, "admin") | ||
a.So(update.AdministrativeContact.GetValue().GetEmail(), should.Equal, "[email protected]") | ||
a.So(update.TechnicalContact.GetValue().GetName(), should.Equal, "tech") | ||
a.So(update.TechnicalContact.GetValue().GetEmail(), should.Equal, "[email protected]") | ||
a.So(update.FrequencyPlan.GetLoraMultiSfChannels(), should.HaveLength, 8) | ||
a.So(update.Online.GetValue(), should.BeTrue) | ||
a.So(update.GatewayLocation.GetLocation().GetTerrestrial().GetAntennaCount().GetValue(), should.Equal, 1) | ||
case <-time.After(timeout): | ||
t.Fatal("Expected gateway update timeout") | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
|