Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add no-trace on config, test_set and scenario level #35

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,33 @@ The data that is being captured depends on the networking mode the scenario
runs with. If it is using a `host` network adapter, then the entire traffic of
the host is traced. Otherwise, if a `bridged` adaptor is being used, then only
the traffic going through the bridge network device is being traced.

By default tracer is always on. You can change this behavior by disabling
tracer on global, test_set or scenario level with desc order priority.
Disabling tracer on global level has highest priority.


1. To disable tracer on global level by passing command line arg, use:

`-x|--no-trace` - do not trace call

2. To disable tracer on global level by defining configuration parameter in config file, edit:

run.yml
```yaml
tracer: off
```

3. To disable tracer on test_set level, edit config.yml on test_set level:

config.yml
```yaml
tracer: off
```

4. To disable tracer on scenario level, edit scenario.yml:

scenario.yml
```yaml
tracer: off
```
3 changes: 2 additions & 1 deletion sipssert/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def __init__(self, args):
tests_filters.ParseTestsFilters(exclude_filters))
self.logs_dir = args.logs_dir
self.no_delete = args.no_delete
self.no_trace = args.no_trace
self.no_trace = not self.config.get("tracer", True) \
if not args.no_trace else args.no_trace
current_date = datetime.now().strftime("%Y-%m-%d.%H:%M:%S.%f")
self.run_logs_dir = os.path.join(self.logs_dir, current_date)
self.link_file = os.path.join(self.logs_dir, "latest")
Expand Down
12 changes: 11 additions & 1 deletion sipssert/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, scenario_file, controller, test_set, set_logs_dir, set_defaul
nets = self.networks if self.networks else []
if self.network:
nets.append(self.network)
self.no_trace = self.controller.no_trace
self.no_trace = self.is_no_trace(test_set)
if not self.no_trace:
self.tracer = tracer.Tracer(self.scen_logs_dir, "capture", nets, self.name)
self.timeout = self.config.get("timeout", 0)
Expand All @@ -79,6 +79,16 @@ def create_scen_logs_dir(self):
if not os.path.isdir(self.scen_logs_dir):
os.mkdir(self.scen_logs_dir)

def is_no_trace(self, test_set):
"""Return True if scenario should not be traced"""
if self.controller.no_trace:
return True
if not test_set.config.get("tracer", True):
return True
if not self.config.get("tracer", True):
return True
return False

def run(self):
"""Runs a scenario with all its prerequisits"""
start_time = time.time()
Expand Down
Loading