def testModuleCreatePartitions():
  """
  testModuleCreatePartitions():
  """
  global me
  connection = psycopg2.connect(me.dsn)
  try:
    cursor = connection.cursor()
    me.testDB.removeDB(me.config,me.logger)
    me.testDB.createDB(me.config,me.logger)
    me.config.startDate = dt.date(2008,1,1)
    me.config.endDate = dt.date(2008,1,1)
    reportSet = set(socorro_psg.tablesMatchingPattern('reports%',cursor))
    extensionSet = set(socorro_psg.tablesMatchingPattern('extensions%',cursor))
    frameSet0 = set(socorro_psg.tablesMatchingPattern('frames%',cursor))
    schema.databaseObjectClassListForWeeklyPartitions = [schema.ExtensionsTable]
    schema.createPartitions(me.config,me.logger)
    moreReportSet = set(socorro_psg.tablesMatchingPattern('report%',cursor))-reportSet
    moreExtensionSet = set(socorro_psg.tablesMatchingPattern('extensions%',cursor))-extensionSet
    assert set(['reports_20071231']) == moreReportSet
    assert set(['extensions_20071231']) == moreExtensionSet
    frameSet = set(socorro_psg.tablesMatchingPattern('frames%',cursor))
    assert frameSet0 == frameSet
    schema.databaseObjectClassListForWeeklyPartitions = [schema.FramesTable]
    schema.createPartitions(me.config,me.logger)
    moreFrameSet = set(socorro_psg.tablesMatchingPattern('frames%',cursor))-frameSet
    assert set(['frames_20071231']) == moreFrameSet
  finally:
    connection.close()
Beispiel #2
0
def testModuleCreatePartitions():
    """
  testModuleCreatePartitions():
  """
    global me
    connection = psycopg2.connect(me.dsn)
    try:
        cursor = connection.cursor()
        me.testDB.removeDB(me.config, me.logger)
        me.testDB.createDB(me.config, me.logger)
        me.config['startDate'] = dt.date(2008, 1, 1)
        me.config['endDate'] = dt.date(2008, 1, 1)
        reportSet = set(socorro_psg.tablesMatchingPattern('reports%', cursor))
        extensionSet = set(
            socorro_psg.tablesMatchingPattern('extensions%', cursor))
        frameSet0 = set(socorro_psg.tablesMatchingPattern('frames%', cursor))
        schema.databaseObjectClassListForWeeklyPartitions = [
            schema.ExtensionsTable
        ]
        schema.createPartitions(me.config, me.logger)
        moreReportSet = set(
            socorro_psg.tablesMatchingPattern('reports%', cursor)) - reportSet
        moreExtensionSet = set(
            socorro_psg.tablesMatchingPattern('extensions%',
                                              cursor)) - extensionSet
        assert set(['reports_20071231'
                    ]) == moreReportSet, 'but got %s' % moreReportSet
        assert set(['extensions_20071231'
                    ]) == moreExtensionSet, 'but got %s' % moreExtensionSet
        frameSet = set(socorro_psg.tablesMatchingPattern('frames%', cursor))
        assert frameSet0 == frameSet
        schema.databaseObjectClassListForWeeklyPartitions = [
            schema.FramesTable
        ]
        schema.createPartitions(me.config, me.logger)
        moreFrameSet = set(socorro_psg.tablesMatchingPattern(
            'frames%', cursor)) - frameSet
        assert set(['frames_20071231'
                    ]) == moreFrameSet, 'but got %s' % moreFrameSet
    finally:
        connection.close()
Beispiel #3
0
import datetime as dt

try:
  import config.createpartitionsconfig as configModule
except ImportError:
    import createpartitionsconfig as configModule

import socorro.lib.ConfigurationManager as configurationManager
import socorro.database.schema as schema
import socorro.lib.util as sutil

try:
  config = configurationManager.newConfiguration(configurationModule=configModule, applicationName="startNextPartition")
except configurationManager.NotAnOptionError, x:
  print >>sys.stderr, x
  print >>sys.stderr, "for usage, try --help"
  sys.exit(1)

logger = logging.getLogger("nextPartition")
logger.setLevel(logging.DEBUG)

sutil.setupLoggingHandlers(logger, config)
sutil.echoConfig(logger, config)

try:
  config["endDate"] = config.startDate + dt.timedelta(config.weeksIntoFuture * 7)
  print
  schema.createPartitions(config, logger)
finally:
  logger.info("done.")