示例#1
0
    def test_scheduler_enable_explicit(self):
        self._append_to_cfg_file(cfg_path=self.cfg_path,
                                 content='\n[scheduler]\nenable = True')
        process = None
        seen_line = False

        try:
            process = self._start_notifier(cmd=self.cmd)
            lines = 0

            while lines < 100:
                line = process.stdout.readline().decode('utf-8')
                lines += 1
                sys.stdout.write(line)

                if SCHEDULER_ENABLED_LOG_LINE in line:
                    seen_line = True
                    break
        finally:
            if process:
                kill_process(process)
                self.remove_process(process=process)

        if not seen_line:
            raise AssertionError(
                'Didn\'t see "%s" log line in scheduler output' %
                (SCHEDULER_DISABLED_LOG_LINE))
示例#2
0
    def test_scheduler_enable_implicit(self):
        process = None
        seen_line = False

        try:
            process = self._start_notifier(cmd=self.cmd)
            lines = 0

            while lines < 100:
                line = process.stdout.readline().decode('utf-8')
                lines += 1
                sys.stdout.write(line)

                if SCHEDULER_ENABLED_LOG_LINE in line:
                    seen_line = True
                    break
        finally:
            if process:
                kill_process(process)
                self.remove_process(process=process)

        if not seen_line:
            print(process.stdout.read())
            print(process.stderr.read())
            raise AssertionError(
                'Didn\'t see "%s" log line in scheduler output' %
                (SCHEDULER_ENABLED_LOG_LINE))
示例#3
0
 def test_st2auth(self):
     port = random.randint(10000, 30000)
     cmd = ('gunicorn st2auth.wsgi:application -k eventlet -b "127.0.0.1:%s" --workers 1' % port)
     env = os.environ.copy()
     env['ST2_CONFIG_PATH'] = ST2_CONFIG_PATH
     process = subprocess.Popen(cmd, env=env, shell=True, preexec_fn=os.setsid)
     try:
         self.add_process(process=process)
         eventlet.sleep(8)
         self.assertProcessIsRunning(process=process)
         response = requests.post('http://127.0.0.1:%s/tokens' % (port))
         self.assertEqual(response.status_code, http_client.UNAUTHORIZED)
     finally:
         kill_process(process)
示例#4
0
 def test_st2auth(self):
     port = random.randint(10000, 30000)
     cmd = ('gunicorn st2auth.wsgi:application -k eventlet -b "127.0.0.1:%s" --workers 1' % port)
     env = os.environ.copy()
     env['ST2_CONFIG_PATH'] = ST2_CONFIG_PATH
     process = subprocess.Popen(cmd, env=env, shell=True, preexec_fn=os.setsid)
     try:
         self.add_process(process=process)
         eventlet.sleep(10)
         self.assertProcessIsRunning(process=process)
         response = requests.post('http://127.0.0.1:%s/tokens' % (port))
         self.assertEqual(response.status_code, httplib.UNAUTHORIZED)
     finally:
         kill_process(process)
 def test_st2api_wsgi_entry_point(self):
     port = random.randint(10000, 30000)
     config_path = os.path.join(BASE_DIR, '../../../st2api/st2api/gunicorn_config.py')
     cmd = ('gunicorn_pecan %s -k eventlet -w 1 -b 127.0.0.1:%s' % (config_path, port))
     env = os.environ.copy()
     env['ST2_CONFIG_PATH'] = ST2_CONFIG_PATH
     process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env,
                                shell=True, preexec_fn=os.setsid)
     self.add_process(process=process)
     eventlet.sleep(5)
     self.assertProcessIsRunning(process=process)
     response = requests.get('http://127.0.0.1:%s/v1/actions' % (port))
     self.assertEqual(response.status_code, httplib.OK)
     kill_process(process)
示例#6
0
    def test_st2auth(self):
        port = random.randint(10000, 30000)
        config_path = os.path.join(BASE_DIR, '../../../st2auth/st2auth/gunicorn_config.py')
        st2_config_path = os.path.join(BASE_DIR, '../../../conf/st2.dev.conf')
        cmd = ('gunicorn_pecan %s -k eventlet -w 1 -b 127.0.0.1:%s' % (config_path, port))
        env = os.environ.copy()
        env['ST2_CONFIG_PATH'] = st2_config_path
        process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env,
                                   shell=True, preexec_fn=os.setsid)

        eventlet.sleep(5)
        response = requests.post('http://127.0.0.1:%s/tokens' % (port))
        self.assertEqual(response.status_code, httplib.UNAUTHORIZED)
        kill_process(process)
示例#7
0
 def test_st2api_wsgi_entry_point(self):
     port = random.randint(10000, 30000)
     cmd = (
         'gunicorn st2api.wsgi:application -k eventlet -b "127.0.0.1:%s" --workers 1'
         % port)
     env = os.environ.copy()
     env["ST2_CONFIG_PATH"] = ST2_CONFIG_PATH
     process = subprocess.Popen(cmd,
                                env=env,
                                shell=True,
                                preexec_fn=os.setsid)
     try:
         self.add_process(process=process)
         eventlet.sleep(8)
         self.assertProcessIsRunning(process=process)
         response = requests.get("http://127.0.0.1:%s/v1/actions" % (port))
         self.assertEqual(response.status_code, http_client.OK)
     finally:
         kill_process(process)
示例#8
0
 def test_st2api_wsgi_entry_point(self):
     port = random.randint(10000, 30000)
     config_path = os.path.join(
         BASE_DIR, '../../../st2api/st2api/gunicorn_config.py')
     cmd = ('gunicorn_pecan %s -k eventlet -w 1 -b 127.0.0.1:%s' %
            (config_path, port))
     env = os.environ.copy()
     env['ST2_CONFIG_PATH'] = ST2_CONFIG_PATH
     process = subprocess.Popen(cmd,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE,
                                env=env,
                                shell=True,
                                preexec_fn=os.setsid)
     self.add_process(process=process)
     eventlet.sleep(5)
     self.assertProcessIsRunning(process=process)
     response = requests.get('http://127.0.0.1:%s/v1/actions' % (port))
     self.assertEqual(response.status_code, httplib.OK)
     kill_process(process)
示例#9
0
    def test_st2auth(self):
        port = random.randint(10000, 30000)
        config_path = os.path.join(
            BASE_DIR, '../../../st2auth/st2auth/gunicorn_config.py')
        st2_config_path = os.path.join(BASE_DIR, '../../../conf/st2.dev.conf')
        cmd = ('gunicorn_pecan %s -k eventlet -w 1 -b 127.0.0.1:%s' %
               (config_path, port))
        env = os.environ.copy()
        env['ST2_CONFIG_PATH'] = st2_config_path
        process = subprocess.Popen(cmd,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE,
                                   env=env,
                                   shell=True,
                                   preexec_fn=os.setsid)

        eventlet.sleep(5)
        response = requests.post('http://127.0.0.1:%s/tokens' % (port))
        self.assertEqual(response.status_code, httplib.UNAUTHORIZED)
        kill_process(process)