Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fe10e73
Implement test orchestrator (#4)
jhughesoti Apr 25, 2023
6f3a7fe
Add issue report templates (#7)
jboddey Apr 26, 2023
e05c383
Discover devices on the network (#5)
jboddey Apr 26, 2023
823709e
Test run sync (#8)
jhughesoti Apr 28, 2023
ba6afc4
Quick refactor (#9)
jboddey Apr 28, 2023
c87a976
Fix duplicate sleep calls
jhughesoti Apr 28, 2023
34ce211
Add net orc (#11)
jhughesoti May 2, 2023
ceba453
Add the DNS test module (#12)
jhughesoti May 4, 2023
0837a9c
Add baseline and pylint tests (#25)
noursaidi May 16, 2023
4171e5f
Discover devices on the network (#22)
jboddey May 16, 2023
be829a3
Build dependencies first (#21)
jboddey May 16, 2023
84d9ff9
Port scan test module (#23)
jhughesoti May 17, 2023
07432ee
Fix device configs
jboddey May 17, 2023
7b27e23
Remove unecessary files
jhughesoti May 17, 2023
5ac8726
Cleanup duplicate properties
jhughesoti May 17, 2023
2c4efe8
Cleanup install script
jhughesoti May 17, 2023
25fd8a5
Formatting (#26)
jhughesoti May 22, 2023
41aaaf7
Test results (#27)
jhughesoti May 23, 2023
ea60b41
Test results (#28)
jhughesoti May 25, 2023
b6a6cdc
Fix pylint test and skip internet tests so CI passes (#29)
noursaidi May 25, 2023
3d53ecb
Increase pylint score (#31)
jboddey May 25, 2023
b91fff5
Pylint (#32)
jhughesoti May 30, 2023
b84a026
Add license header (#36)
jhughesoti May 30, 2023
622b12d
merge main
jhughesoti May 31, 2023
38d71aa
Ovs (#35)
jhughesoti May 31, 2023
00be9cb
remove ovs files added back in during merge
jhughesoti May 31, 2023
f331239
Nmap (#38)
jhughesoti Jun 5, 2023
2a68fba
Create startup capture (#37)
jboddey Jun 5, 2023
8e8e154
Connection (#40)
jhughesoti Jun 7, 2023
6ff220b
Conn mac oui (#42)
jhughesoti Jun 8, 2023
4ca8f44
Con mac address (#43)
jhughesoti Jun 8, 2023
ff04f43
Dns (#44)
jhughesoti Jun 8, 2023
752f701
File permissions (#45)
jhughesoti Jun 9, 2023
f6e4e93
Add connection single ip test (#47)
jhughesoti Jun 12, 2023
bca0db8
Nmap results (#49)
jhughesoti Jun 15, 2023
5b56a79
Framework restructure (#50)
jboddey Jun 15, 2023
7bb9366
Ip control (#51)
jhughesoti Jun 20, 2023
b0d14c2
Move config to /local (#52)
jboddey Jun 23, 2023
94e937f
Add documentation (#53)
jboddey Jun 23, 2023
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
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ venv/
.vscode/
error
pylint.out
local/
__pycache__/
__pycache__/
build/
4 changes: 0 additions & 4 deletions cmd/install
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ source venv/bin/activate

pip3 install -r framework/requirements.txt

pip3 install -r net_orc/python/requirements.txt

pip3 install -r test_orc/python/requirements.txt

deactivate
4 changes: 3 additions & 1 deletion cmd/start
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ rm -rf runtime
source venv/bin/activate

# TODO: Execute python code
python -u framework/test_runner.py $@
# Set the PYTHONPATH to include the "src" directory
export PYTHONPATH="$PWD/framework/python/src"
python -u framework/python/src/core/test_runner.py $@

# TODO: Work in progress code for containerization of OVS module
# asyncRun() {
Expand Down
1 change: 0 additions & 1 deletion conf/.gitignore

This file was deleted.

41 changes: 41 additions & 0 deletions docs/configure_device.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Device Configuration

The device configuration file allows you to customize the testing behavior for a specific device. This file is located at `local/devices/{Device Name}/device_config.json`. Below is an overview of how to configure the device tests.

## Device Information

The device information section includes the manufacturer, model, and MAC address of the device. These details help identify the specific device being tested.

## Test Modules

Test modules are groups of tests that can be enabled or disabled as needed. You can choose which test modules to include for your device. The device configuration file contains the following test module:

- DNS Test Module

### Enabling and Disabling Test Modules

To enable or disable a test module, modify the `enabled` field within the respective module. Setting it to `true` enables the module, while setting it to `false` disables the module.

## Individual Tests

Within the DNS test module, there are individual tests that can be enabled or disabled. These tests focus on specific aspects of network behavior. You can customize the tests based on your device and testing requirements.

### Enabling and Disabling Tests

To enable or disable an individual test, modify the `enabled` field within the respective test. Setting it to `true` enables the test, while setting it to `false` disables the test.

> Note: The example device configuration file (`resources/devices/template/device_config.json`) provides a complete usage example, including the structure and configuration options for the DNS test module and its tests. You can refer to this file to understand how to configure your device tests effectively.

## Customizing the Device Configuration

To customize the device configuration for your specific device, follow these steps:

1. Copy the default configuration file provided in the `resources/devices/template` folder.
- Create a new folder for your device under `local/devices` directory.
- Copy the `device_config.json` file from `resources/devices/template` to the newly created device folder.

This ensures that you have a copy of the default configuration file, which you can then modify for your specific device.

> Note: Ensure that the device configuration file is properly formatted, and the changes made align with the intended test behavior. Incorrect settings or syntax may lead to unexpected results during testing.

If you encounter any issues or need assistance with the device configuration, refer to the Test Run documentation or ask a question on the Issues page.
53 changes: 53 additions & 0 deletions docs/get_started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Getting Started

## Prerequisites

### Hardware

Before starting with Test Run, ensure you have the following hardware:

- PC running Ubuntu LTS (laptop or desktop)
- 2x USB Ethernet adapter (one may be a built-in Ethernet port)
- Internet connection

### Software

Ensure the following software is installed on your Ubuntu LTS PC:

- Python 3 (already available on Ubuntu LTS)
- Docker - Installation Guide: [https://docs.docker.com/engine/install/](https://docs.docker.com/engine/install/)
- Open vSwitch ``sudo apt-get install openvswitch-common openvswitch-switch``

## Installation

1. Download Test Run from the releases page or the appropriate source.

2. Run the install script.

## Configuration

1. Copy the default configuration file.

2. Open the `local/system.json` file and modify the configuration as needed. Specify the interface names for the internet and device interfaces.

## Test Your Device

1. Attach network interfaces:

- Connect one USB Ethernet adapter to the internet source (e.g., router or switch) using an Ethernet cable.
- Connect the other USB Ethernet adapter directly to the IoT device you want to test using an Ethernet cable.

2. Start Test Run.

- To run Test Run in network-only mode (without running any tests), use the `--net-only` option.

- To skip network validation before use and not launch the faux device on startup, use the `--no-validate` option.

# Troubleshooting

If you encounter any issues or need assistance, consider the following:

- Ensure that all hardware and software prerequisites are met.
- Verify that the network interfaces are connected correctly.
- Check the configuration in the `local/system.json` file.
- Refer to the Test Run documentation or ask for further assistance from the support team.
13 changes: 0 additions & 13 deletions framework/device.py

This file was deleted.

49 changes: 0 additions & 49 deletions framework/logger.py

This file was deleted.

60 changes: 60 additions & 0 deletions framework/python/src/common/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Sets up the logger to be used for the test modules."""
import json
import logging
import os

LOGGERS = {}
_LOG_FORMAT = '%(asctime)s %(name)-8s %(levelname)-7s %(message)s'
_DATE_FORMAT = '%b %02d %H:%M:%S'
_DEFAULT_LEVEL = logging.INFO
_CONF_DIR = 'conf'
_CONF_FILE_NAME = 'system.json'

# Set log level
try:
with open(os.path.join(_CONF_DIR, _CONF_FILE_NAME),
encoding='UTF-8') as config_json_file:
system_conf_json = json.load(config_json_file)

log_level_str = system_conf_json['log_level']
log_level = logging.getLevelName(log_level_str)
except OSError:
# TODO: Print out warning that log level is incorrect or missing
log_level = _DEFAULT_LEVEL

log_format = logging.Formatter(fmt=_LOG_FORMAT, datefmt=_DATE_FORMAT)

def add_file_handler(log, log_file, log_dir):
handler = logging.FileHandler(log_dir + log_file + '.log')
handler.setFormatter(log_format)
log.addHandler(handler)


def add_stream_handler(log):
handler = logging.StreamHandler()
handler.setFormatter(log_format)
log.addHandler(handler)


def get_logger(name, log_file=None, log_dir=None):
if name not in LOGGERS:
LOGGERS[name] = logging.getLogger(name)
LOGGERS[name].setLevel(log_level)
add_stream_handler(LOGGERS[name])
if log_file is not None and log_dir is not None:
add_file_handler(LOGGERS[name], log_file, log_dir)
return LOGGERS[name]
96 changes: 55 additions & 41 deletions net_orc/python/src/util.py → framework/python/src/common/util.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,55 @@
"""Provides basic utilities for the network orchestrator."""
import subprocess
import shlex
import logger
import netifaces

LOGGER = logger.get_logger('util')


def run_command(cmd, output=True):
"""Runs a process at the os level
By default, returns the standard output and error output
If the caller sets optional output parameter to False,
will only return a boolean result indicating if it was
succesful in running the command. Failure is indicated
by any return code from the process other than zero."""

success = False
process = subprocess.Popen(shlex.split(cmd),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = process.communicate()

if process.returncode != 0 and output:
err_msg = f'{stderr.strip()}. Code: {process.returncode}'
LOGGER.error('Command Failed: ' + cmd)
LOGGER.error('Error: ' + err_msg)
else:
success = True
if output:
return stdout.strip().decode('utf-8'), stderr
else:
return success


def interface_exists(interface):
return interface in netifaces.interfaces()


def prettify(mac_string):
return ':'.join([f'{ord(b):02x}' for b in mac_string])
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Provides basic utilities for the network orchestrator."""
import subprocess
import shlex
from common import logger
import netifaces

LOGGER = logger.get_logger('util')


def run_command(cmd, output=True):
"""Runs a process at the os level
By default, returns the standard output and error output
If the caller sets optional output parameter to False,
will only return a boolean result indicating if it was
succesful in running the command. Failure is indicated
by any return code from the process other than zero."""

success = False
process = subprocess.Popen(shlex.split(cmd),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = process.communicate()

if process.returncode != 0 and output:
err_msg = f'{stderr.strip()}. Code: {process.returncode}'
LOGGER.error('Command Failed: ' + cmd)
LOGGER.error('Error: ' + err_msg)
else:
success = True
if output:
return stdout.strip().decode('utf-8'), stderr
else:
return success


def interface_exists(interface):
return interface in netifaces.interfaces()


def prettify(mac_string):
return ':'.join([f'{ord(b):02x}' for b in mac_string])
27 changes: 27 additions & 0 deletions framework/python/src/core/device.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Track device object information."""

from net_orc.network_device import NetworkDevice
from dataclasses import dataclass


@dataclass
class Device(NetworkDevice):
"""Represents a physical device and it's configuration."""

make: str = None
model: str = None
test_modules: str = None
Loading