Skip to content

Commit

Permalink
pba: Update agent tests to include GS's gtw admin/tech contacts priority
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspcr committed Aug 2, 2023
1 parent 7099bda commit 00d1e3e
Showing 1 changed file with 118 additions and 50 deletions.
168 changes: 118 additions & 50 deletions pkg/packetbrokeragent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
})
})
}

Expand Down

0 comments on commit 00d1e3e

Please sign in to comment.