Skip to content

Commit

Permalink
Fix broken tests (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
grafnu authored Nov 11, 2021
1 parent 1d49d5a commit 4ee4173
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ ignored-classes=
BuildingSchema, LacpState, LacpRole, AuthResult, DVAState, AuthMode,
DevicesState, DevicePlacement, DeviceBehavior, SegmentsToVlans,
ForchConfig, SiteConfig, OrchestrationConfig, AuthConfig, HttpConfig,
PortBehavior, FaucetConfigSummary, SessionResult, SessionParams
PortBehavior, FaucetConfigSummary, SessionResult, SessionParams,
FaucetConfig
6 changes: 6 additions & 0 deletions bin/setup_stack
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ echo Letting system settle...
sleep 20

if [ -z "$skip_conn_check" ]; then

if [[ -z $ip_faux_1 || -z $ip_faux_2 || -z $ip_faux_3 ]]; then
echo Missing required faux ip addresses.
false
fi

echo Starting connection warm-up...
# Do faux-1 synchronously to prevent race condition with vid assignment.
docker exec forch-faux-1 ping -q -c 10 $ip_faux_3 || true
Expand Down
19 changes: 18 additions & 1 deletion testing/python_lib/build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def create_scale_faucet_config(self, t1_switches, t2_switches, access_ports):
port_acl='uniform_acl', lacp=True)
dps[dp_name] = self._build_datapath_config(
T2_DP_ID_START + dp_index, interfaces, self._generate_dp_mac(T2_DP, dp_index))

return FaucetConfig(dps=dps, version=2, include=['uniform.yaml'], vlans=vlans)

def create_flat_faucet_config(self, num_switches, num_access_ports):
Expand Down Expand Up @@ -201,6 +202,21 @@ def create_corp_faucet_config(self):
return FaucetConfig(dps=dps, version=2)


def cleanup_keys(map_in):
"""proto_dict converts int keys to strings, which isn't always semantically correct"""
return dict(iter((int(k), v) for k, v in map_in.items()))


def cleanup_config(config_map):
"""cleanup the necessary dict entries for a faucet config"""
for dp_id in config_map['dps']:
bad_map = config_map['dps'][dp_id]['interfaces']
config_map['dps'][dp_id]['interfaces'] = cleanup_keys(bad_map)
if 'vlans' in config_map:
config_map['vlans'] = cleanup_keys(config_map['vlans'])
return config_map


def main(argv):
"""main method for standalone run"""
config_generator = FaucetConfigGenerator()
Expand Down Expand Up @@ -246,7 +262,8 @@ def main(argv):
else:
raise Exception('Unkown topology type: %s' % topo_type)

config_map = proto_dict(faucet_config)
config_map = cleanup_config(proto_dict(faucet_config))

with open(filepath, 'w') as config_file:
yaml.dump(config_map, config_file)

Expand Down
7 changes: 4 additions & 3 deletions testing/python_lib/test_failscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import yaml

from integration_base import IntegrationTestBase
from build_config import FaucetConfigGenerator
from build_config import FaucetConfigGenerator, cleanup_config

from forch.utils import proto_dict

Expand All @@ -20,8 +20,9 @@ def __init__(self, *args, **kwargs):
self.sim_setup_cmd = 'bin/setup_scale'
self.config_path = '/tmp/scale_config'

config = proto_dict(
FaucetConfigGenerator().create_scale_faucet_config(2, self.switches, self.devices))
config = cleanup_config(proto_dict(
FaucetConfigGenerator().create_scale_faucet_config(2, self.switches, self.devices)))

with open(self.config_path, 'w') as config_file:
yaml.dump(config, config_file)

Expand Down

0 comments on commit 4ee4173

Please sign in to comment.