fix: protocol v1

This commit is contained in:
2024-08-02 12:57:07 +02:00
parent 8f89ed7e77
commit b976bde363
23 changed files with 392 additions and 85 deletions

View File

@ -2,7 +2,9 @@ package testsuite
import (
"context"
"math/rand"
"os"
"strconv"
"testing"
"time"
@ -52,6 +54,17 @@ var testCases = []operationTestCase{
Run: func(t *testing.T, ops protocol.Operations) {
ctx := context.Background()
if err := ops.Connect(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
return
}
defer func() {
if err := ops.Close(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
}
}()
version, stable, err := ops.Version(ctx)
if err != nil {
t.Errorf("%+v", errors.WithStack(err))
@ -104,6 +117,17 @@ var testCases = []operationTestCase{
Run: func(t *testing.T, ops protocol.Operations) {
ctx := context.Background()
if err := ops.Connect(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
return
}
defer func() {
if err := ops.Close(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
}
}()
config, err := ops.Configuration(ctx)
if err != nil {
t.Errorf("%+v", errors.WithStack(err))
@ -118,13 +142,32 @@ var testCases = []operationTestCase{
Run: func(t *testing.T, ops protocol.Operations) {
ctx := context.Background()
if err := ops.Connect(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
return
}
defer func() {
if err := ops.Close(ctx); err != nil {
t.Errorf("%+v", errors.WithStack(err))
}
}()
latitude := -90 + rand.Float64()*180
longitude := -180 + rand.Float64()*360
height := rand.Float64() * 1000
antennaOffset := rand.Float64() * 2
opts := []protocol.SetBaseOptionFunc{
protocol.WithBaseLatitude(47.72769),
protocol.WithBaseLongitude(4.72783),
protocol.WithBaseHeight(101),
protocol.WithBaseLatitude(latitude),
protocol.WithBaseLongitude(longitude),
protocol.WithBaseHeight(height),
protocol.WithBaseAntennaOffset(antennaOffset),
protocol.WithBaseMode("manual"),
}
t.Logf("setting base (latitude: %v, longitude: %v, height: %v, antennaOffset: %v", latitude, longitude, height, antennaOffset)
if err := ops.SetBase(ctx, opts...); err != nil {
t.Errorf("%+v", errors.WithStack(err))
return
@ -132,10 +175,26 @@ var testCases = []operationTestCase{
},
},
{
Name: "Reboot",
Run: func(t *testing.T, ops protocol.Operations) {
const doRebootEnvVar = "DO_REBOOT"
rawDoReboot := os.Getenv(doRebootEnvVar)
if rawDoReboot == "" {
rawDoReboot = "false"
}
doReboot, err := strconv.ParseBool(rawDoReboot)
if err != nil {
t.Fatalf("could not parse %s environment variable: %+v", doRebootEnvVar, errors.WithStack(err))
return
}
if !doReboot {
t.Skipf("Reboot test case disabled. To enable, set environment variable %s=true", doRebootEnvVar)
return
}
ctx := context.Background()
if err := ops.Connect(ctx); err != nil {