Esempio n. 1
0
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()
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 4
0
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()
Esempio n. 5
0
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()
Esempio n. 6
0
# 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()
Esempio n. 7
0
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()
Esempio n. 8
0
def setUpModule():
    """Sets up the environment for testing."""
    db_path = tempfile.mktemp(suffix='.db')
    db.drop_all()
    db.create_all()