More fixes for CI/CD

This commit is contained in:
Daniel Pupius committed 2025-05-02 13:20:57 -07:00
1 parent 5cae8fd5cf
commit 23deefe061
5 files changed
+35 -24

No files matched your search

-3
View File
@@ -23,9 +23,6 @@ jobs:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Cleanup any old data
run: make clean
- name: Install Protocol Buffers Compiler
run: |
sudo apt-get update
+5
View File
@@ -26,6 +26,11 @@ jobs:
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Install protoc-gen-go
run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Generate Protocol Buffers
run: make gen-proto
+24 -20
View File
@@ -8,6 +8,7 @@ import (
meshtreampb "meshstream/generated/meshstream"
pb "meshstream/generated/meshtastic"
"google.golang.org/protobuf/proto"
)
@@ -27,7 +28,8 @@ func TestManualDecode(t *testing.T) {
if err != nil {
fmt.Printf("Failed to unmarshal as MapReport: %v\n", err)
} else {
fmt.Printf("Successfully decoded as MapReport: %+v\n", mapReport)
// Use the pointer to avoid copying mutex
fmt.Printf("Successfully decoded as MapReport: %v\n", mapReport.String())
}
// Try decoding as ServiceEnvelope
@@ -37,7 +39,8 @@ func TestManualDecode(t *testing.T) {
if err != nil {
fmt.Printf("Failed to unmarshal as ServiceEnvelope: %v\n", err)
} else {
fmt.Printf("Successfully decoded as ServiceEnvelope: %+v\n", serviceEnvelope)
// Use the pointer to avoid copying mutex
fmt.Printf("Successfully decoded as ServiceEnvelope: %v\n", serviceEnvelope.String())
}
// Try decoding as MeshPacket
@@ -47,7 +50,8 @@ func TestManualDecode(t *testing.T) {
if err != nil {
fmt.Printf("Failed to unmarshal as MeshPacket: %v\n", err)
} else {
fmt.Printf("Successfully decoded as MeshPacket: %+v\n", meshPacket)
// Use the pointer to avoid copying mutex
fmt.Printf("Successfully decoded as MeshPacket: %v\n", meshPacket.String())
}
}
@@ -60,28 +64,28 @@ func TestDecodeMapReport(t *testing.T) {
// Try to decode as different message types
testCases := []struct {
name string
unmarshal func([]byte, proto.Message) error
message proto.Message
shouldPass bool
name string
unmarshal func([]byte, proto.Message) error
message proto.Message
shouldPass bool
}{
{
name: "MapReport",
unmarshal: proto.Unmarshal,
message: &pb.MapReport{},
shouldPass: false, // Expected to fail based on our findings
name: "MapReport",
unmarshal: proto.Unmarshal,
message: &pb.MapReport{},
shouldPass: false, // Expected to fail based on our findings
},
{
name: "ServiceEnvelope",
unmarshal: proto.Unmarshal,
message: &pb.ServiceEnvelope{},
shouldPass: true, // This should work
name: "ServiceEnvelope",
unmarshal: proto.Unmarshal,
message: &pb.ServiceEnvelope{},
shouldPass: true, // This should work
},
{
name: "MeshPacket",
unmarshal: proto.Unmarshal,
message: &pb.MeshPacket{},
shouldPass: true, // This also works - but with unparsed fields
name: "MeshPacket",
unmarshal: proto.Unmarshal,
message: &pb.MeshPacket{},
shouldPass: true, // This also works - but with unparsed fields
},
}
@@ -92,7 +96,7 @@ func TestDecodeMapReport(t *testing.T) {
if tc.shouldPass && err != nil {
t.Errorf("Expected %s to parse successfully, but got error: %v", tc.name, err)
} else if !tc.shouldPass && err == nil {
t.Errorf("Expected %s to fail parsing, but it succeeded: %+v", tc.name, tc.message)
t.Errorf("Expected %s to fail parsing, but it succeeded", tc.name)
}
if err == nil {
+4 -1
View File
@@ -9,6 +9,9 @@ import (
"github.com/dpup/prefab/logging"
)
// Time to wait before giving up on sending cached packets
var cacheGracePeriod = 1500 * time.Millisecond
// CircularBuffer implements a fixed-size circular buffer for caching packets
type CircularBuffer struct {
buffer []*meshtreampb.Packet // Fixed size buffer to store packets
@@ -128,7 +131,7 @@ func (b *Broker) Subscribe(bufferSize int) <-chan *meshtreampb.Packet {
select {
case subscriberChan <- packet:
// Successfully sent packet
case <-time.After(1500 * time.Millisecond):
case <-time.After(cacheGracePeriod):
// Give up after waiting some time to avoid blocking indefinitely
b.logger.Warn("Timeout when sending cached packet to new subscriber")
return
+2
View File
@@ -420,6 +420,8 @@ func TestBrokerCacheOverflow(t *testing.T) {
// TestSubscriberBufferFull tests the behavior when a subscriber's buffer is full
func TestSubscriberBufferFull(t *testing.T) {
cacheGracePeriod = 300
// Create a test source channel
sourceChan := make(chan *meshtreampb.Packet, 10)