feat: add domain models for test configuration and results
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
/// Raw result from an iperf3 execution.
|
||||
class Iperf3Result {
|
||||
final String rawOutput;
|
||||
final int exitCode;
|
||||
|
||||
const Iperf3Result({
|
||||
required this.rawOutput,
|
||||
required this.exitCode,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/// Configuration for an iperf3 client test.
|
||||
class TestConfiguration {
|
||||
final String server;
|
||||
final int port;
|
||||
final Duration duration;
|
||||
final int interval;
|
||||
final int parallelStreams;
|
||||
|
||||
const TestConfiguration({
|
||||
this.server = 'iperf.es.net',
|
||||
this.port = 5201,
|
||||
this.duration = const Duration(seconds: 10),
|
||||
this.interval = 1,
|
||||
this.parallelStreams = 1,
|
||||
});
|
||||
|
||||
/// Convert to iperf3 CLI arguments.
|
||||
List<String> toCliArgs() {
|
||||
return <String>[
|
||||
'-c', server,
|
||||
'-p', '$port',
|
||||
'-t', '${duration.inSeconds}',
|
||||
'-i', '$interval',
|
||||
'-P', '$parallelStreams',
|
||||
];
|
||||
}
|
||||
|
||||
/// Validate the configuration.
|
||||
bool get isValid {
|
||||
if (server.isEmpty) return false;
|
||||
if (port < 1 || port > 65535) return false;
|
||||
if (duration.inSeconds < 1) return false;
|
||||
if (interval < 1) return false;
|
||||
if (parallelStreams < 1) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user