From 82b9382f69db208d8d557c5230592b29c5810820 Mon Sep 17 00:00:00 2001 From: Amol Bhave Date: Thu, 18 Apr 2019 20:28:37 -0700 Subject: [PATCH] remove integration_tests Summary: These tests don't really work, deleting Reviewed By: mariof Differential Revision: D14972292 fbshipit-source-id: 179e7706b629c686e004dbbe958a7e7ca50d2b69 --- .../integration_tests/fbmeshd_launcher.py | 113 ------------------ .../integration_tests/integration_tests.py | 79 ------------ 2 files changed, 192 deletions(-) delete mode 100644 openr/fbmeshd/integration_tests/fbmeshd_launcher.py delete mode 100644 openr/fbmeshd/integration_tests/integration_tests.py diff --git a/openr/fbmeshd/integration_tests/fbmeshd_launcher.py b/openr/fbmeshd/integration_tests/fbmeshd_launcher.py deleted file mode 100644 index a739c5ebf98..00000000000 --- a/openr/fbmeshd/integration_tests/fbmeshd_launcher.py +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. -# - -import argparse -import os -import select -import signal -import tempfile -import textwrap -import threading -from subprocess import PIPE, Popen - -import libfb.py.pathutils as pathutils -from nsenter import Namespace - - -class FbMeshd(threading.Thread): - def __init__(self, namespace, encrypted=True, verbosity=0, logfile=None): - - self.fbmeshd = pathutils.get_build_rule_output_path( - "//openr/fbmeshd:fbmeshd", pathutils.BuildRuleTypes.CXX_BINARY - ) - self.encrypted = encrypted - cfg = self.gen_config(encrypted=self.encrypted, verbosity=verbosity) - self.cmd = [ - self.fbmeshd, - "-config", - cfg, - "-v", - str(verbosity), - "-logtostderr", - "1", - "-enable_openr_metric_manager=true", - ] - self.namespace = namespace - self.logfile = logfile - self.verbosity = verbosity - threading.Thread.__init__(self) - - def run(self): - with Namespace(self.namespace, "net"): - self.proc = Popen(self.cmd, stderr=PIPE) - p = select.poll() - p.register(self.proc.stderr, select.POLLIN) - more = True - while more: - if p.poll(): # blocking call - line = self.proc.stderr.readline() - if self.verbosity > 0: - print(line.decode("utf-8"), end="") - more = len(line) > 0 - else: - more = False - self.proc.stderr.close() - - def stop(self): - self.proc.terminate() - self.proc.wait() - - def gen_config(self, encrypted=False, verbosity=0): - encstr = "true" if encrypted else "false" - debugmask = 965 if verbosity else 0 - fd, path = tempfile.mkstemp(text=True, prefix="fbmeshd") - with os.fdopen(fd, mode="w") as f: - f.write( - textwrap.dedent( - """ - {{ - "meshList": [ - {{ - "meshId": "bazookaTEST", - "ifName": "mesh0", - "frequency": 2412, - "channelType": "HT20", - "rssiThreshold": -80, - "maxPeerLinks": 13, - "encryption": {{ - "enabled": {}, - "password": "thisisreallyquitesecretisitnot", - "saeGroups": [19, 26, 21, 25, 20], - "debugVerbosity": {} - }} - }} - ] - }} - """.format( - encstr, debugmask - ) - ) - ) - return path - - -def sighandler(signum, frame): - fbmd.stop() - - -if __name__ == "__main__": - - parser = argparse.ArgumentParser() - parser.add_argument("--verbosity", type=int, default=0) - args = parser.parse_args() - - signal.signal(signal.SIGTERM, sighandler) - signal.signal(signal.SIGINT, sighandler) - # launch on default namespace (pid=1) - fbmd = FbMeshd(1, verbosity=args.verbosity) - fbmd.run() diff --git a/openr/fbmeshd/integration_tests/integration_tests.py b/openr/fbmeshd/integration_tests/integration_tests.py deleted file mode 100644 index a03e767ccd9..00000000000 --- a/openr/fbmeshd/integration_tests/integration_tests.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. -# - -import os -import time -import unittest -from subprocess import check_call, check_output - -from nsenter import Namespace - -from .fbmeshd_launcher import FbMeshd - - -class TestFbmeshdIntegration(unittest.TestCase): - def setUp(self): - lsmod_out = check_output("/usr/sbin/lsmod") - if b"mac80211_hwsim" in lsmod_out: - check_call(["/usr/sbin/modprobe", "-r", "mac80211-hwsim"]) - check_call(["/usr/sbin/modprobe", "mac80211-hwsim"]) - self.ns_names = {"phy0": "fbmeshd-ns0", "phy1": "fbmeshd-ns1"} - self.ns_paths = { - key: "/var/run/netns/" + name for (key, name) in self.ns_names.items() - } - for phy, ns_name in self.ns_names.items(): - if not os.path.exists(self.ns_paths[phy]): - check_call(["/usr/sbin/ip", "netns", "add", ns_name]) - check_call(["/usr/sbin/iw", "phy", phy, "set", "netns", "name", ns_name]) - - def tearDown(self): - self.stop_fbmeshds() - check_call(["/usr/sbin/modprobe", "-r", "mac80211-hwsim"]) - for phy in self.ns_paths: - if os.path.exists(self.ns_paths[phy]): - check_call(["/usr/sbin/ip", "netns", "delete", self.ns_names[phy]]) - - def start_fbmeshds(self, encrypted=False): - self.fbmd = [FbMeshd(ns, encrypted=encrypted) for ns in self.ns_paths.values()] - [t.start() for t in self.fbmd] - time.sleep(1) - - def stop_fbmeshds(self): - [t.stop() for t in self.fbmd] - [t.join() for t in self.fbmd] - - def test_open_plink_establishment(self): - - # launch fbmeshd in separate namespaces - self.start_fbmeshds() - - # now test things in each namespace - with Namespace(self.ns_paths["phy0"], "net"): - iw_out = check_output(["/usr/sbin/iw", "mesh0", "station", "dump"]) - self.assertTrue(b"ESTAB" in iw_out) - with Namespace(self.ns_paths["phy1"], "net"): - iw_out = check_output(["/usr/sbin/iw", "mesh0", "station", "dump"]) - self.assertTrue(b"ESTAB" in iw_out) - - def test_secure_plink_establishment(self): - - # launch fbmeshd in separate namespaces - self.start_fbmeshds(encrypted=True) - time.sleep(10) - - # now test things in each namespace - with Namespace(self.ns_paths["phy0"], "net"): - iw_out = check_output(["/usr/sbin/iw", "mesh0", "station", "dump"]) - self.assertTrue(b"ESTAB" in iw_out) - with Namespace(self.ns_paths["phy1"], "net"): - iw_out = check_output(["/usr/sbin/iw", "mesh0", "station", "dump"]) - self.assertTrue(b"ESTAB" in iw_out) - - -if __name__ == "__main__": - unittest.main()