backend: serve single-agent task templates with their status and results, rename the kinds in storage
This commit is contained in:
1 parent
e77880d372
commit
3a9ea46d6f
45 files changed
+763
-216
No files matched your search
@@ -138,7 +138,7 @@ public sealed class DialerSimulator : IAsyncDisposable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>对一个 udp_echo 线路任务发 <paramref name="count"/> 个回显包,等回复,然后交出一个列块。返回交给 Agent 的列块的序号范围。</summary>
|
||||
/// <summary>对一个 quic_ping 线路任务发 <paramref name="count"/> 个回显包,等回复,然后交出一个列块。返回交给 Agent 的列块的序号范围。</summary>
|
||||
public async Task<(int Sent, int Received)> RunUdpEchoAsync(LineTask task, int count, TimeSpan interval, CancellationToken ct = default)
|
||||
{
|
||||
int size = (int)task.Params["size"].GetInt64();
|
||||
@@ -166,12 +166,12 @@ public sealed class DialerSimulator : IAsyncDisposable
|
||||
msg.Add(seq, size, 1, t1, collector.Received.TryGetValue(seq, out long t4) ? t4 : null);
|
||||
}
|
||||
|
||||
RawChunkHeader header = Header("udp_echo", task.Id, null, null, startUtc, (int)Math.Max(1, count * interval.TotalMilliseconds), task.Params);
|
||||
RawChunkHeader header = Header("quic_ping", task.Id, null, null, startUtc, (int)Math.Max(1, count * interval.TotalMilliseconds), task.Params);
|
||||
await ShipAsync(new RawChunk(header, [msg.Build()]), ct: ct);
|
||||
return (count, collector.Received.Count);
|
||||
}
|
||||
|
||||
/// <summary>对一个 tcp_echo 线路任务建立一条 TCP(可选 TLS)连接,发 <paramref name="count"/> 条回显消息,然后交出一个列块。</summary>
|
||||
/// <summary>对一个 tcp_ping 线路任务建立一条 TCP(可选 TLS)连接,发 <paramref name="count"/> 条回显消息,然后交出一个列块。</summary>
|
||||
public async Task<(int Sent, int Received)> RunTcpEchoAsync(LineTask task, int tcpPort, int count, TimeSpan interval, bool tls, CancellationToken ct = default)
|
||||
{
|
||||
using var timeout = CancellationTokenSource.CreateLinkedTokenSource(ct);
|
||||
@@ -211,7 +211,7 @@ public sealed class DialerSimulator : IAsyncDisposable
|
||||
await Task.Delay(interval, ct);
|
||||
}
|
||||
|
||||
RawChunkHeader header = Header("tcp_echo", task.Id, null, null, startUtc, (int)Math.Max(1, count * interval.TotalMilliseconds), task.Params);
|
||||
RawChunkHeader header = Header("tcp_ping", task.Id, null, null, startUtc, (int)Math.Max(1, count * interval.TotalMilliseconds), task.Params);
|
||||
await ShipAsync(new RawChunk(header, [msg.Build()]), ct: ct);
|
||||
return (count, received);
|
||||
}
|
||||
@@ -394,7 +394,7 @@ public sealed class DialerSimulator : IAsyncDisposable
|
||||
}
|
||||
|
||||
_activePhases[start.StreamId] = start;
|
||||
if (start.Kind == "udp_train")
|
||||
if (start.Kind == "quic_stream")
|
||||
{
|
||||
_trains[start.StreamId] = new TrainCollector { StartUtcMs = TimeProvider.System.GetUtcNow().ToUnixTimeMilliseconds() };
|
||||
_quic!.Register(start.StreamId, OnDatagram);
|
||||
@@ -424,7 +424,7 @@ public sealed class DialerSimulator : IAsyncDisposable
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (start.Kind == "udp_train" && _trains.TryRemove(end.StreamId, out TrainCollector? train))
|
||||
if (start.Kind == "quic_stream" && _trains.TryRemove(end.StreamId, out TrainCollector? train))
|
||||
{
|
||||
await Task.Delay(200, ct); // 最后一批包还在路上
|
||||
// 单块的记录数有上限(ProtocolLimits.MaxRecordsPerChunk):按序号范围切成多个列块,Agent 一侧按同样的范围取行
|
||||
@@ -443,12 +443,12 @@ public sealed class DialerSimulator : IAsyncDisposable
|
||||
var streams = new List<RawStream> { pkt.Build() };
|
||||
if (fragments == 0)
|
||||
{
|
||||
var step = new StreamBuilder(Kinds.UdpTrain.FindStream("step")!);
|
||||
var step = new StreamBuilder(Kinds.QuicStream.FindStream("step")!);
|
||||
step.Add(0, (long)start.Params["mbps"].GetDouble(), NowUs() - (start.DurationSeconds * 1_000_000L), NowUs());
|
||||
streams.Add(step.Build());
|
||||
}
|
||||
|
||||
RawChunkHeader header = Header("udp_train", null, start.TestId, start.Phase, train.StartUtcMs, start.DurationSeconds * 1000, start.Params);
|
||||
RawChunkHeader header = Header("quic_stream", null, start.TestId, start.Phase, train.StartUtcMs, start.DurationSeconds * 1000, start.Params);
|
||||
header.Params[FragmentKeys.SeqFrom] = JsonSerializer.SerializeToElement(from);
|
||||
header.Params[FragmentKeys.SeqTo] = JsonSerializer.SerializeToElement(to);
|
||||
// 不能在这里等确认:确认是 Agent 的通知,由同一个入站队列顺序处理,而当前正处在 phase_end 的处理函数里
|
||||
|
||||
Reference in new issue
Block a user