Ejemplo n.º 1
0
def pytest_sessionstart(session):
    """
    Set up the test environment.

    Set DJANGO_SETTINGS_MODULE, adds the vendor lib, and sets up a test
    database.

    """
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "datazilla.settings.base")
    add_vendor_lib()

    from django.conf import settings
    from django.test.simple import DjangoTestSuiteRunner
    # we don't actually let Django run the tests, but we need to use some
    # methods of its runner for setup/teardown of dbs and some other things
    session.django_runner = DjangoTestSuiteRunner()
    # this provides templates-rendered debugging info and locmem mail storage
    session.django_runner.setup_test_environment()
    # support custom db prefix for tests for the main datazilla datasource
    # as well as for the testproj and testpushlog dbs
    prefix = getattr(settings, "TEST_DB_PREFIX", "")
    settings.DATABASES["default"]["TEST_NAME"] = "{0}test_datazilla".format(prefix)
    # this sets up a clean test-only database
    session.django_db_config = session.django_runner.setup_databases()
    # store the name of the test project/pushlog based on user custom settings
    session.perftest_name = "{0}testproj".format(prefix)
    session.pushlog_name = "{0}testpushlog".format(prefix)

    increment_cache_key_prefix()

    from datazilla.model import PerformanceTestModel, PushLogModel
    ptm = PerformanceTestModel.create(
        session.perftest_name,
        cron_batch="small",
        )
    PushLogModel.create(project=session.pushlog_name)

    # patch in additional test-only procs on the datasources
    objstore = ptm.sources["objectstore"]
    del objstore.dhub.procs[objstore.datasource.key]
    objstore.dhub.data_sources[objstore.datasource.key]["procs"].append(
        os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            "objectstore_test.json",
            )
        )
    objstore.dhub.load_procs(objstore.datasource.key)

    perftest = ptm.sources["perftest"]
    del perftest.dhub.procs[perftest.datasource.key]
    perftest.dhub.data_sources[perftest.datasource.key]["procs"].append(
        os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            "perftest_test.json",
            )
        )
    perftest.dhub.load_procs(perftest.datasource.key)
Ejemplo n.º 2
0
def pytest_sessionstart(session):
    """
    Set up the test environment.

    Set DJANGO_SETTINGS_MODULE, adds the vendor lib, and sets up a test
    database.

    """
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "datazilla.settings.base")
    add_vendor_lib()

    from django.conf import settings
    from django.test.simple import DjangoTestSuiteRunner
    # we don't actually let Django run the tests, but we need to use some
    # methods of its runner for setup/teardown of dbs and some other things
    session.django_runner = DjangoTestSuiteRunner()
    # this provides templates-rendered debugging info and locmem mail storage
    session.django_runner.setup_test_environment()
    # support custom db prefix for tests for the main datazilla datasource
    # as well as for the testproj and testpushlog dbs
    prefix = getattr(settings, "TEST_DB_PREFIX", "")
    settings.DATABASES["default"]["TEST_NAME"] = "{0}test_datazilla".format(
        prefix)
    # this sets up a clean test-only database
    session.django_db_config = session.django_runner.setup_databases()
    # store the name of the test project/pushlog based on user custom settings
    session.perftest_name = "{0}testproj".format(prefix)
    session.pushlog_name = "{0}testpushlog".format(prefix)

    increment_cache_key_prefix()

    from datazilla.model import PerformanceTestModel, PushLogModel
    ptm = PerformanceTestModel.create(
        session.perftest_name,
        cron_batch="small",
    )
    PushLogModel.create(project=session.pushlog_name)

    # patch in additional test-only procs on the datasources
    objstore = ptm.sources["objectstore"]
    del objstore.dhub.procs[objstore.datasource.key]
    objstore.dhub.data_sources[objstore.datasource.key]["procs"].append(
        os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            "objectstore_test.json",
        ))
    objstore.dhub.load_procs(objstore.datasource.key)

    perftest = ptm.sources["perftest"]
    del perftest.dhub.procs[perftest.datasource.key]
    perftest.dhub.data_sources[perftest.datasource.key]["procs"].append(
        os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            "perftest_test.json",
        ))
    perftest.dhub.load_procs(perftest.datasource.key)
Ejemplo n.º 3
0
import os
import sys

from datazilla.vendor import add_vendor_lib
add_vendor_lib()

from optparse import OptionParser
from datazilla.model.DatazillaModel import DatazillaModel

def loadTestCollection(project):

    gm = DatazillaModel(project, 'graphs.json')

    products = gm.getProducts('id')

    for productName in products:

        if products[ productName ]['product'] and \
           products[ productName ]['version'] and \
           products[ productName ]['branch']:

            name = "%s %s %s" % (products[ productName ]['product'],
                                 products[ productName ]['version'],
                                 products[ productName ]['branch'])

            id = gm.setData('set_test_collection', [ name, "", name ])
            gm.setData('set_test_collection_map', [ id, products[ productName ]['id'] ])

    gm.disconnect()

if __name__ == '__main__':
Ejemplo n.º 4
0
#!/usr/bin/env python
import os, sys

from datazilla.vendor import add_vendor_lib

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "datazilla.settings.base")

    add_vendor_lib()

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)