def setUpModule(): """Sets up the environment for testing.""" global server_thread server_port = get_free_port() FLAGS.fetch_frequency = 100 FLAGS.fetch_threads = 1 FLAGS.phantomjs_timeout = 60 FLAGS.polltime = 1 FLAGS.queue_idle_poll_seconds = 1 FLAGS.queue_busy_poll_seconds = 1 FLAGS.queue_server_prefix = "http://localhost:%d/api/work_queue" % server_port FLAGS.release_server_prefix = "http://localhost:%d/api" % server_port db_path = tempfile.mktemp(suffix=".db") logging.info("sqlite path used in tests: %s", db_path) server.app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + db_path db.drop_all() db.create_all() server.app.config["CSRF_ENABLED"] = False server.app.config["IGNORE_AUTH"] = True server.app.config["TESTING"] = True run = lambda: server.app.run(debug=False, host="0.0.0.0", port=server_port) server_thread = threading.Thread(target=run) server_thread.setDaemon(True) server_thread.start() run_server.run_workers()
def start_server(): """Starts the dpxdt server and returns its main thread.""" server_port = get_free_port() FLAGS.fetch_frequency = 100 FLAGS.fetch_threads = 1 FLAGS.capture_timeout = 60 FLAGS.polltime = 1 FLAGS.queue_idle_poll_seconds = 1 FLAGS.queue_busy_poll_seconds = 1 FLAGS.queue_server_prefix = ( 'http://localhost:%d/api/work_queue' % server_port) FLAGS.release_server_prefix = 'http://localhost:%d/api' % server_port db_path = tempfile.mktemp(suffix='.db') logging.info('sqlite path used in tests: %s', db_path) server.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + db_path db.drop_all() db.create_all() server.app.config['CSRF_ENABLED'] = False server.app.config['IGNORE_AUTH'] = True server.app.config['TESTING'] = True run = lambda: server.app.run(debug=False, host='0.0.0.0', port=server_port) server_thread = threading.Thread(target=run) server_thread.setDaemon(True) server_thread.start() return server_thread
def start_server(): """Starts the dpxdt server and returns its main thread.""" server_port = get_free_port() FLAGS.fetch_frequency = 100 FLAGS.fetch_threads = 1 FLAGS.phantomjs_timeout = 60 FLAGS.polltime = 1 FLAGS.queue_idle_poll_seconds = 1 FLAGS.queue_busy_poll_seconds = 1 FLAGS.queue_server_prefix = ( 'http://localhost:%d/api/work_queue' % server_port) FLAGS.release_server_prefix = 'http://localhost:%d/api' % server_port db_path = tempfile.mktemp(suffix='.db') logging.info('sqlite path used in tests: %s', db_path) server.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + db_path db.drop_all() db.create_all() server.app.config['CSRF_ENABLED'] = False server.app.config['IGNORE_AUTH'] = True server.app.config['TESTING'] = True run = lambda: server.app.run(debug=False, host='0.0.0.0', port=server_port) server_thread = threading.Thread(target=run) server_thread.setDaemon(True) server_thread.start() return server_thread
def setUpModule(): """Sets up the environment for testing.""" global server_thread server_port = get_free_port() FLAGS.fetch_frequency = 100 FLAGS.fetch_threads = 1 FLAGS.phantomjs_timeout = 60 FLAGS.polltime = 1 FLAGS.queue_poll_seconds = 1 FLAGS.queue_server_prefix = ( 'http://localhost:%d/api/work_queue' % server_port) FLAGS.release_server_prefix = 'http://localhost:%d/api' % server_port db_path = tempfile.mktemp(suffix='.db') logging.info('sqlite path used in tests: %s', db_path) server.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + db_path db.drop_all() db.create_all() server.app.config['CSRF_ENABLED'] = False server.app.config['IGNORE_AUTH'] = True server.app.config['TESTING'] = True run = lambda: server.app.run(debug=False, host='0.0.0.0', port=server_port) server_thread = threading.Thread(target=run) server_thread.setDaemon(True) server_thread.start() runworker.run_workers()
def setUpModule(): """Sets up the environment for testing.""" global server_thread server_port = get_free_port() FLAGS.fetch_frequency = 100 FLAGS.fetch_threads = 1 FLAGS.phantomjs_timeout = 60 FLAGS.polltime = 1 FLAGS.queue_poll_seconds = 1 FLAGS.queue_server_prefix = ( 'http://localhost:%d/api/work_queue' % server_port) FLAGS.release_server_prefix = 'http://localhost:%d/api' % server_port db.drop_all() db.create_all() server.app.config['CSRF_ENABLED'] = False server.app.config['IGNORE_AUTH'] = True server.app.config['TESTING'] = True run = lambda: server.app.run(debug=False, host='0.0.0.0', port=server_port) server_thread = threading.Thread(target=run) server_thread.setDaemon(True) server_thread.start() runworker.run_workers()
# 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. """Bootstraps a new installation by setting up the production environment.""" import os os.environ['YOURAPPLICATION_SETTINGS'] = '../../settings.cfg' os.environ['SQLITE_PRODUCTION'] = 'Yes' from dpxdt.server import db from dpxdt.server import models from dpxdt.server import utils db.create_all() build = models.Build(name='Primary build') db.session.add(build) db.session.commit() api_key = models.ApiKey( id=utils.human_uuid(), secret=utils.password_uuid(), purpose='Local workers', superuser=True, build_id=build.id) db.session.add(api_key) db.session.commit() db.session.flush()
import argparse os.environ['YOURAPPLICATION_SETTINGS'] = '../../settings.cfg' os.environ['SQLITE_PRODUCTION'] = 'Yes' from dpxdt.server import db from dpxdt.server import models from dpxdt.server import utils parser = argparse.ArgumentParser(description="Configure startup behaviour") parser.add_argument('-d','--dbexists', help='does db exist already',required=False) args = parser.parse_args() print "Argument --dbexists=%s" % args.dbexists #See if we need to initialize the database if args.dbexists == "false" or args.dbexists == None: db.create_all() build = models.Build(name='Primary build') db.session.add(build) db.session.commit() api_key = models.ApiKey( id=utils.human_uuid(), secret=utils.password_uuid(), purpose='Local workers', superuser=True, build_id=build.id) db.session.add(api_key) db.session.commit() db.session.flush()
def setUpModule(): """Sets up the environment for testing.""" db_path = tempfile.mktemp(suffix='.db') db.drop_all() db.create_all()