rewrite prototype with unit tests
the stressant
prototype (the shell script) has served me well, but now it feels really clunky and wrong:
- the commandline has grown out of proportions and has become difficult to grasp.
- the code, also, has grown too large and functions are too big which makes them difficult to change.
- we pass globals all over the place
- it's hard to do refactoring because of the current design (e.g. I wouldn't like to implement auto disk detection in the current scenario)
- there are zero unit tests.
so I'd like to start from scratch. reimplement this with the lessons we've learnt and make the code cleaner, and unit-tested (and yes, that means running at least some of those commands).
here's the requirements:
- unit tests - might involves mocking stuff like an iperf server, loopback devices for dd and so on, but at least test dry-runs and commandline parsing, because some bugs have shown up in there recently
-
subcommands - instead of assuming we run everything then disable stuff with "--no-STUFF", just make a subcommand out of everything. argparse isn't well designed to support multiple subcommands, but that's something that should be surmountable. subcommands would be like makefile targets, except with arguments. for example:
stressant
would do theall
target, which would be something likestressant info disk cpu network
right now. another target could besmart
ormemory
. then parameters would be specific to each subcommand. -
smaller functions - right now functions have grown to lengthy things that do a billion things (like disk tests do
smart
,hdparm
,dd
,fio
... it's a mess). not sure how split things up, but maybe it could be abstracted by the subcommands? maybe thedisk
subcommand could be an alias for thehdparm
,dd
andfio
subcommands? fundamentally, stressant is a wrapper to those commands, and it just pre-populates the "proper way" of calling them. - parallelism - no sense in waiting for disks to complete testing before burning the cpu or doing network test, is there! just throw it all out there! need to figure out how to multiplex that output though.
New features I would like to see that are not fundamental to the design change also include:
-
more intuitive logfiles - right now, we have no timestamps in logs and we need to tell stressant the log filename. by default, drop a logfile in /var/log/ with the relevant filenamedone in 5c13c084 -
test all disks - we're playing it safe now, but stressant is a dangerous command, which will kill everything, and that's fine. let's do it! just hammer at all drives (with the
--force
argument provided) that we can find.
We can keep some of the current code, like the colored log output which works well, but we should just start from a fresh copy to avoid corrupting our brain with the existing codebase.
Edited by Antoine Beaupré