Skip to content

Commit

Permalink
fix(test): UploadAndStartMission_StrictSequenceExecuting
Browse files Browse the repository at this point in the history
On some slow platforms, start the mission before busy flag is released.
  • Loading branch information
asvol committed Dec 26, 2024
1 parent 7c04074 commit 9d016d6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,9 @@ public async Task SendCommandInt_DifferentMavResults_Success(MavResult mavResult
{
called++;
_taskCompletionSource.TrySetResult(args);
packetFromClient = args;
return Task.FromResult(CommandResult.FromResult(mavResult));
};
using var sub = Link.Client.OnTxMessage.Subscribe(p =>
{
packetFromClient = p as CommandIntPacket;
});

// Act
await _client.SendCommandInt(
Expand Down Expand Up @@ -785,13 +782,10 @@ public async Task CommandInt_WithCustomConfig_Success(int maxCommandAttempts, in
called++;
var result = MavResult.MavResultAccepted;
_taskCompletionSource.TrySetResult(args);
packetFromClient = args;
return Task.FromResult(CommandResult.FromResult(result));
};
using var sub = Link.Client.OnTxMessage.Subscribe(p =>
{
packetFromClient = p as CommandIntPacket;
});


// Act
var result = await client.CommandInt(
MavCmd.MavCmdUser1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,21 @@ public async Task UploadAndStartMission_StrictSequenceExecuting_Success(ushort s
});

// Act
_server.StartMission(skip);

// On some slow platforms, start the mission before the upload is complete.
// We attempt to start it multiple times. It's impossible in real life with async communication
start:
try
{
_server.StartMission(skip);
}
catch (MavlinkException e)
{
Log.WriteLine("====> tests is slow. Trying to start mission multiple times <===");
await Task.Delay(10);
goto start;
}

await tcs.Task;

// Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public async Task Upload(CancellationToken cancel, Action<double>? progress = nu

await _client.MissionSetCount((ushort) _missionSource.Count, cancel).ConfigureAwait(false);
await tcs.Task.ConfigureAwait(false);
progress?.Invoke(1);
_isMissionSynced.OnNext(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public enum MissionServerState

public interface IMissionServerEx : IMavlinkMicroserviceServer
{

IMissionServer Base { get; }
ReadOnlyReactiveProperty<ushort> Current { get; }
ReadOnlyReactiveProperty<ushort> Reached { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ public sealed class MissionServerEx : MavlinkMicroserviceServer, IMissionServerE
private const int InternalBusyStateClearAll = 1;
private const int InternalBusyStateUploadMission = 2;
private const int InternalBusyStateStartMission = 3;


private int _internalBusyState;

private int _internalBusyState = InternalBusyStateIdle;

private readonly IStatusTextServer _statusLogger;
private readonly ILogger _logger;
Expand Down

0 comments on commit 9d016d6

Please sign in to comment.