Beispiel #1
0
 def setUpClass(cls):
     SignerTestCase.setUpClass()
     cls.templates = TemplateLookup(directories=[os.path.join(cls.datadir, 'mdx')])
     cls.mdx = tempfile.NamedTemporaryFile('w').name
     cls.mdx_template = cls.templates.get_template('mdx.fd')
     cls.pidfile = tempfile.NamedTemporaryFile('w').name
     with open(cls.mdx, "w") as fd:
         fd.write(cls.mdx_template.render(ctx=cls))
     cls.curdir = os.getcwd()
     cls.port = find_unbound_port()
     print "Using port %d" % cls.port
     cls.pyffd_thread = Thread(target=run_pyffd,
                               name="pyffd-test",
                               args=["--loglevel=DEBUG",
                                     "--dir=%s" % cls.curdir,
                                     '-f',
                                     '-a',
                                     '-P', "%s" % cls.port,
                                     '-C',
                                     '-p', cls.pidfile,
                                     "--terminator",
                                     cls.mdx])
     cls.pyffd_thread.start()
     sleep(1)
     for i in range(0,120):
         try:
             r = requests.get("http://127.0.0.1:%s/status" % cls.port)
             if r.json() and 'running' in r.json()['status']:
                 return
         except Exception:
             pass
         sleep(1)
     raise ValueError("unable to start test pyffd server on port %d" % cls.port)
Beispiel #2
0
 def tearDownClass(cls):
     SignerTestCase.tearDownClass()
     try:
         requests.get("http://127.0.0.1:%s/shutdown" % cls.port)
     except Exception, ex:
         from traceback import print_exc
         print_exc(ex)
Beispiel #3
0
 def tearDownClass(cls):
     SignerTestCase.tearDownClass()
     try:
         requests.get("http://127.0.0.1:%s/shutdown" % cls.port)
     except Exception, ex:
         from traceback import print_exc
         print_exc(ex)
Beispiel #4
0
 def tearDownClass(cls):
     SignerTestCase.tearDownClass()
     requests.get("http://127.0.0.1:8080/shutdown")
     if os.path.exists(cls.mdx):
         os.unlink(cls.mdx)
     if os.path.exists(cls.pidfile):
         os.unlink(cls.pidfile)
     cls.pyffd_thread.join()
Beispiel #5
0
 def tearDownClass(cls):
     SignerTestCase.tearDownClass()
     requests.get("http://127.0.0.1:8080/shutdown")
     if os.path.exists(cls.mdx):
         os.unlink(cls.mdx)
     if os.path.exists(cls.pidfile):
         os.unlink(cls.pidfile)
     cls.pyffd_thread.join()
Beispiel #6
0
 def setUpClass(cls):
     SignerTestCase.setUpClass()
     cls.templates = TemplateLookup(directories=[os.path.join(cls.datadir, 'mdx')])
     cls.mdx = tempfile.NamedTemporaryFile('w').name
     cls.mdx_template = cls.templates.get_template('mdx.fd')
     with open(cls.mdx, "w") as fd:
         fd.write(cls.mdx_template.render(ctx=cls))
     with open(cls.mdx, 'r') as r:
         print("".join(r.readlines()))
     cls._app = mkapp(cls.mdx)
     cls.app = lambda *args, **kwargs: cls._app
Beispiel #7
0
 def tearDownClass(cls):
     SignerTestCase.tearDownClass()
     try:
         requests.get("http://127.0.0.1:%s/shutdown" % cls.port)
     except Exception as ex:
         from traceback import print_exc
         print_exc(ex)
     finally:
         if os.path.exists(cls.mdx):
             os.unlink(cls.mdx)
         if os.path.exists(cls.pidfile):
             os.unlink(cls.pidfile)
         if os.path.exists(cls.logfile):
             os.unlink(cls.logfile)
     cls.pyffd_thread.join()
Beispiel #8
0
 def tearDownClass(cls):
     SignerTestCase.tearDownClass()
     try:
         requests.get("http://127.0.0.1:%s/shutdown" % cls.port)
     except Exception as ex:
         from traceback import print_exc
         print_exc(ex)
     finally:
         if os.path.exists(cls.mdx):
             os.unlink(cls.mdx)
         if os.path.exists(cls.pidfile):
             os.unlink(cls.pidfile)
         if os.path.exists(cls.logfile):
             os.unlink(cls.logfile)
     cls.pyffd_thread.join()
Beispiel #9
0
 def setUpClass(cls):
     SignerTestCase.setUpClass()
     cls.templates = TemplateLookup(directories=[os.path.join(cls.datadir, 'mdx')])
     cls.mdx = tempfile.NamedTemporaryFile('w').name
     cls.mdx_template = cls.templates.get_template('mdx.fd')
     cls.pidfile = tempfile.NamedTemporaryFile('w').name
     with open(cls.mdx, "w") as fd:
         fd.write(cls.mdx_template.render(ctx=cls))
     cls.curdir = os.getcwd()
     cls.pyffd_thread = Thread(target=run_pyffd,
                               name="pyffd-test",
                               args=["--loglevel=INFO", "--dir=%s" % cls.curdir, '-f', '-a',
                                     '-C', '-p', cls.pidfile, "--terminator", cls.mdx])
     cls.pyffd_thread.start()
     sleep(20)
Beispiel #10
0
    def setUpClass(cls):
        SignerTestCase.setUpClass()
        cls.templates = TemplateLookup(directories=[os.path.join(cls.datadir, "mdx")])
        cls.mdx = tempfile.NamedTemporaryFile("w").name
        cls.mdx_template = cls.templates.get_template("mdx.fd")
        cls.pidfile = tempfile.NamedTemporaryFile("w").name
        cls.logfile = tempfile.NamedTemporaryFile("w").name
        with open(cls.mdx, "w") as fd:
            fd.write(cls.mdx_template.render(ctx=cls))
        cls.curdir = os.getcwd()
        cls.port = find_unbound_port()
        print "Using port %d, logging to %s" % (cls.port, cls.logfile)
        cls.pyffd_thread = Thread(
            target=run_pyffd,
            name="pyffd-test",
            args=[
                "--loglevel=DEBUG",
                "--log=%s" % cls.logfile,
                "--dir=%s" % cls.curdir,
                "-f",
                "-a",
                "-P",
                "%s" % cls.port,
                "-C",
                "-p",
                cls.pidfile,
                "--allow_shutdown",
                cls.mdx,
            ],
        )
        cls.pyffd_thread.start()
        sleep(1)
        for i in range(0, 60):
            try:
                r = requests.get("http://127.0.0.1:%s/status" % cls.port)
                if r.json() and "running" in r.json()["status"]:
                    return

                print r.json()
                sleep(1)
            except Exception, ex:
                from traceback import print_exc

                print print_exc(ex)
                pass
            sleep(1)
Beispiel #11
0
 def tearDownClass(cls):
     SignerTestCase.tearDownClass()
     try:
         requests.get("http://127.0.0.1:%s/shutdown" % cls.port)
         with open(cls.logfile) as fd:
             print ("+++ DEBUG log +++")
             print("\n".join(fd.readlines()))
     except Exception as ex:
         from traceback import print_exc
         print_exc(ex)
     finally:
         if os.path.exists(cls.mdx):
             os.unlink(cls.mdx)
         if os.path.exists(cls.pidfile):
             os.unlink(cls.pidfile)
         if os.path.exists(cls.logfile):
             os.unlink(cls.logfile)
     cls.pyffd_thread.join()
Beispiel #12
0
    def setUpClass(cls):
        SignerTestCase.setUpClass()
        config.local_copy_dir = tempfile.TemporaryDirectory()
        cls.templates = TemplateLookup(
            directories=[os.path.join(cls.datadir, 'mdx')])
        cls.mdx = tempfile.NamedTemporaryFile('w').name
        # cls.mdx_template = cls.templates.get_template('mdx.fd')
        cls.test01 = os.path.join(cls.datadir, 'metadata', 'test01.xml')
        with open(cls.mdx, "w") as fd:
            fd.write(f"""
- when update:
    - load:
        - {cls.test01}
""")
        with open(cls.mdx, 'r') as r:
            print("".join(r.readlines()))
        cls._app = mkapp(cls.mdx)
        cls.app = lambda *args, **kwargs: cls._app
Beispiel #13
0
 def tearDownClass(cls):
     SignerTestCase.tearDownClass()
     try:
         requests.get("http://127.0.0.1:%s/shutdown" % cls.port)
         with open(cls.logfile) as fd:
             print("+++ DEBUG log +++")
             print("\n".join(fd.readlines()))
     except Exception as ex:
         from traceback import print_exc
         print_exc(ex)
     finally:
         if os.path.exists(cls.mdx):
             os.unlink(cls.mdx)
         if os.path.exists(cls.pidfile):
             os.unlink(cls.pidfile)
         if os.path.exists(cls.logfile):
             os.unlink(cls.logfile)
     cls.pyffd_thread.join()
Beispiel #14
0
 def setUpClass(cls):
     SignerTestCase.setUpClass()
     cls.templates = TemplateLookup(
         directories=[os.path.join(cls.datadir, 'mdx')])
     cls.mdx = tempfile.NamedTemporaryFile('w').name
     cls.mdx_template = cls.templates.get_template('mdx.fd')
     cls.pidfile = tempfile.NamedTemporaryFile('w').name
     with open(cls.mdx, "w") as fd:
         fd.write(cls.mdx_template.render(ctx=cls))
     cls.curdir = os.getcwd()
     cls.pyffd_thread = Thread(target=run_pyffd,
                               name="pyffd-test",
                               args=[
                                   "--loglevel=INFO",
                                   "--dir=%s" % cls.curdir, '-f', '-a',
                                   '-C', '-p', cls.pidfile, "--terminator",
                                   cls.mdx
                               ])
     cls.pyffd_thread.start()
     sleep(20)
Beispiel #15
0
    def setUpClass(cls):
        SignerTestCase.setUpClass()
        cls.templates = TemplateLookup(
            directories=[os.path.join(cls.datadir, 'mdx')])
        cls.mdx = tempfile.NamedTemporaryFile('w').name
        cls.mdx_template = cls.templates.get_template('mdx.fd')
        cls.pidfile = tempfile.NamedTemporaryFile('w').name
        cls.logfile = tempfile.NamedTemporaryFile('w').name
        with open(cls.mdx, "w") as fd:
            fd.write(cls.mdx_template.render(ctx=cls))
        with open(cls.mdx, 'r') as r:
            print("".join(r.readlines()))
        cls.curdir = os.getcwd()
        cls.port = find_unbound_port()
        print("Using port {:d}, logging to {}".format(cls.port, cls.logfile))
        cls.pyffd_thread = Thread(target=run_pyffd,
                                  name="pyffd-test",
                                  args=[
                                      "--loglevel=DEBUG",
                                      "--log=%s" % cls.logfile,
                                      "--dir=%s" % cls.curdir, '-f', '-a',
                                      '-P',
                                      "%s" % cls.port, '-C', '-p', cls.pidfile,
                                      "--allow_shutdown", cls.mdx
                                  ])
        cls.pyffd_thread.start()
        sleep(1)
        for i in range(0, 60):
            try:
                r = requests.get("http://127.0.0.1:%s/status" % cls.port)
                if r.json() and 'running' in r.json()['status']:
                    return

                print(r.json())
                sleep(1)
            except Exception as ex:
                print(ex)
                pass
            sleep(1)
        raise ValueError("unable to start test pyffd server on port %d" %
                         cls.port)
Beispiel #16
0
    def setUpClass(cls):
        SignerTestCase.setUpClass()
        cls.templates = TemplateLookup(
            directories=[os.path.join(cls.datadir, 'mdx')])
        cls.mdx = tempfile.NamedTemporaryFile('w').name
        cls.mdx_template = cls.templates.get_template('mdx.fd')
        cls.pidfile = tempfile.NamedTemporaryFile('w').name
        cls.logfile = tempfile.NamedTemporaryFile('w').name
        with open(cls.mdx, "w") as fd:
            fd.write(cls.mdx_template.render(ctx=cls))
        cls.curdir = os.getcwd()
        cls.port = find_unbound_port()
        print "Using port %d, logging to %s" % (cls.port, cls.logfile)
        cls.pyffd_thread = Thread(target=run_pyffd,
                                  name="pyffd-test",
                                  args=[
                                      "--loglevel=DEBUG",
                                      "--log=%s" % cls.logfile,
                                      "--dir=%s" % cls.curdir, '-f', '-a',
                                      '-P',
                                      "%s" % cls.port, '-C', '-p', cls.pidfile,
                                      "--allow_shutdown", cls.mdx
                                  ])
        cls.pyffd_thread.start()
        sleep(1)
        for i in range(0, 60):
            try:
                r = requests.get("http://127.0.0.1:%s/status" % cls.port)
                if r.json() and 'running' in r.json()['status']:
                    return

                print r.json()
                sleep(1)
            except Exception, ex:
                from traceback import print_exc
                print print_exc(ex)
                pass
            sleep(1)
Beispiel #17
0
 def setUp(self):
     SignerTestCase.setUpClass()
     print "setup called for PipeLineTest"
     self.templates = TemplateLookup(directories=[os.path.join(self.datadir, 'simple-pipeline')])
Beispiel #18
0
 def setUpClass(cls):
     SignerTestCase.setUpClass()
Beispiel #19
0
 def setUp(self):
     SignerTestCase.setUpClass()
     self.templates = TemplateLookup(
         directories=[os.path.join(self.datadir, 'simple-pipeline')])
Beispiel #20
0
 def setUpClass(cls):
     SignerTestCase.setUpClass()
Beispiel #21
0
 def setUp(self):
     SignerTestCase.setUpClass()
     print("setup called for PipeLineTest")
     self.templates = TemplateLookup(
         directories=[os.path.join(self.datadir, 'simple-pipeline')])
Beispiel #22
0
 def setUp(self):
     SignerTestCase.setUpClass()
     self.templates = TemplateLookup(directories=[os.path.join(self.datadir, 'simple-pipeline')])
Beispiel #23
0
 def tearDownClass(cls):
     SignerTestCase.tearDownClass()
     if os.path.exists(cls.mdx):
         os.unlink(cls.mdx)
     if os.path.exists(config.local_copy_dir):
         shutil.rmtree(config.local_copy_dir)
Beispiel #24
0
 def tearDownClass(cls):
     SignerTestCase.tearDownClass()
     if os.path.exists(cls.mdx):
         os.unlink(cls.mdx)