Skip to content

Commit

Permalink
tft: rename "main.py" to "tft.py"
Browse files Browse the repository at this point in the history
We have multple python scripts that are directly executable (i.e. they
have a main() function).

When running the test, it's not obvious why this program is called
`main.py`. Rename it to `tft.py`. You should now run `tft.py`.

Add a symlink `main.py` that points to the new script. This is for
backward compatibility, so that the various callers don't need to update
their code (yet).
  • Loading branch information
thom311 committed Nov 27, 2024
1 parent 9c0c5af commit e4069a9
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 75 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ tool will try to autopopulate resource_name based on the secondary+network_nad p
Simply run the python application as so:

```
python main.py config.yaml
./tft.py config.yaml
```

## Environment variables
Expand Down
74 changes: 0 additions & 74 deletions main.py

This file was deleted.

1 change: 1 addition & 0 deletions main.py
74 changes: 74 additions & 0 deletions tft.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python3

import argparse

from pathlib import Path

from ktoolbox import common

from testConfig import TestConfig
from testConfig import ConfigDescriptor
from trafficFlowTests import TrafficFlowTests


def parse_args() -> argparse.Namespace:

parser = argparse.ArgumentParser(
description="test Traffic Flows in an OVN-Kubernetes cluster."
)
parser.add_argument(
"config",
metavar="config",
type=str,
help="YAML file with test configuration (see config.yaml)",
)
parser.add_argument(
"evaluator_config",
nargs="?",
metavar="evaluator_config",
type=str,
help="YAML file with configuration for scoring test results (see eval-config.yaml). "
"This parameter is optional. If provided, this effectively runs "
"./evaluator.py ${evaluator_config} ${test_result} ${evaluator_result}` on "
"the result file. You can run this step separately.",
)
parser.add_argument(
"-o",
"--output-base",
type=str,
default=None,
help="The base name for the result files. If specified, the result will be "
'written to "${output_base}$(printf \'%%03d\' "$number").json" where ${number} is the '
"zero-based index of the test. This can include the directory name and is relative to "
'the current directory. If unspecified, the files are written to "${logs}/${timestamp}.json" '
'where "${logs}" can be specified in the config file (and defaults to "./ft-logs/").',
)

common.log_argparse_add_argument_verbosity(parser)

args = parser.parse_args()

common.log_config_logger(args.verbosity, "tft", "ktoolbox")

if not Path(args.config).exists():
raise ValueError("Must provide a valid config.yaml file (see config.yaml)")

return args


def main() -> None:
args = parse_args()

tc = TestConfig(
config_path=args.config,
evaluator_config=args.evaluator_config,
output_base=args.output_base,
)
tft = TrafficFlowTests()

for cfg_descr in ConfigDescriptor(tc).describe_all_tft():
tft.test_run(cfg_descr)


if __name__ == "__main__":
main()

0 comments on commit e4069a9

Please sign in to comment.