コード例 #1
0
 def testPartitionInsert(self):
   """
   TestPartitionedTable.testPartitionInsert():
   - check that we automagically create the needed partition on insert
   """
   global me
   tz = UTC
   cursor = self.connection.cursor()
   me.logger.debug("DEBUG before createDB")
   # test in this order, because other things depend on reports
   insertRows = [              # uuid,                                 client_crash_date,                 date_processed,            install_age,last_crash,uptime,user_comments, app_notes, distributor, distributor_version,productdims_id,urldims_id
     #[schema.CrashReportsTable,['0bba61c5-dfc3-43e7-dead-8afd20071025',dt.datetime(2007,12,25,5,4,3,21,tz),dt.datetime(2007,12,25,5,4,3,33,tz),10000,100,110,"","","","",1,1]],
     [schema.ReportsTable, ['0bba61c5-dfc3-43e7-dead-8afd20071025',dt.datetime(2007,12,25,5,4,3,21,tz),dt.datetime(2007,12,25,5,4,3,33,tz),'Firefox','1.0b4', '200403041354','http://www.a.com', 10000,       100,        110,    "",    dt.datetime(2004,3,4,13,54,tzinfo=tz),"",      "",            "",        "",          "",None,None,None,'bogus_hangid',None,'some_chonnel']],
     [schema.ExtensionsTable,[1,dt.datetime(2007,12,25,5,4,3,33,tz),1,'extensionid','version']],
     [schema.FramesTable,[1,2,dt.datetime(2007,12,25,5,4,3,33,tz),'somesignature']],
     #[schema.DumpsTable,[1,dt.datetime(2007,12,25,5,4,3,33,tz),"data"]],
     ]
   # call insert, expecting auto-creation of partitions
   me.dsn = "host=%s dbname=%s user=%s password=%s" % (me.config.databaseHost,me.config.databaseName,
                                                     me.config.databaseUserName,me.config.databasePassword)
   me.testDB.createDB(me.config,me.logger)
   dbtestutil.fillDimsTables(cursor)
   before = set([x for x in socorro_psg.tablesMatchingPattern('%',cursor) if not 'pg_toast' in x])
   for t in insertRows:
     obj = t[0](logger=me.logger)
     obj.insert(cursor,t[1],self.altConnectionCursor,date_processed=dt.datetime(2007,12,25,5,4,3,33,tz))
     self.connection.commit()
     current = set([x for x in socorro_psg.tablesMatchingPattern('%',cursor) if not 'pg_toast' in x])
     diff = current - before
     assert set(['%s_20071224'%obj.name]) == diff,'Expected set([%s_20071224]), got %s'%(obj.name,diff)
     before = current
コード例 #2
0
 def setUp(self):
   global me
   if not me:
     createMe()
   self.connection = me.database.connection()
   #self.connection = psycopg2.connect(me.dsn)
   self.testDB = TestDB()
   self.testDB.removeDB(me.config, me.logger)
   self.testDB.createDB(me.config, me.logger)
   dbtestutil.fillDimsTables(self.connection.cursor())
   self.connection.commit()
コード例 #3
0
ファイル: testDbtestutil.py プロジェクト: Meghashyamt/socorro
def testFillDimsTables_MyData():
  global me
  cursor = me.connection.cursor()
  dimsTables = [db_schema.ProductDimsTable, db_schema.UrlDimsTable, db_schema.OsDimsTable]
  toBeCleanedInstances = [x(logger) for x in db_schema.getOrderedSetupList(dimsTables)]
  data = {
    'productdims':[
    {'product':'P1','version':'V1','release':'major','branch':'b1'},
    {'product':'P2','version':'V2','release':'milestone','branch':'b2'},
    {'product':'P1','version':'V3','release':'development','branch':'b3'}
    ],
    'urldims':[
    {'domain':'www.woot.com','url':'http://www.woot.com/patootie#bleep'},
    {'domain':'google.com','url':'http://google.com/search'}
    ],
    'osdims':[
    {'os_name':'AnOS','os_version':'6.6.6'}
    ],
    }
  try:
    dbtu.fillDimsTables(cursor,data)
    for table,filler in data.items():
      got = []
      colList = filler[0].keys()
      cols = ','.join(colList)
      cursor.execute("SELECT %s from %s ORDER BY id"%(cols,table))
      me.connection.commit()
      gotData = cursor.fetchall()
      for d in gotData:
        got.append(dict(zip(colList,d)))
      assert data[table] == got, 'expected %s, got %s'%(data[table],got)
  finally:
    for inst in toBeCleanedInstances:
      inst.drop(cursor)
    me.connection.commit()
    for inst in toBeCleanedInstances:
      inst._createSelf(cursor)
    me.connection.commit()
コード例 #4
0
ファイル: testDbtestutil.py プロジェクト: Meghashyamt/socorro
def testFillDimsTables_Default():
  global me
  cursor = me.connection.cursor()
  dimsTables = [db_schema.ProductDimsTable, db_schema.UrlDimsTable, db_schema.OsDimsTable]
  toBeCleanedInstances = [x(logger) for x in db_schema.getOrderedSetupList(dimsTables)]
  try:
    dbtu.fillDimsTables(cursor)
    for table,filler in dbtu.dimsData.items():
      got = []
      colList = filler[0].keys()
      cols = ','.join(colList)
      cursor.execute("SELECT %s from %s ORDER BY id"%(cols,table))
      gotData = cursor.fetchall()
      for d in gotData:
        got.append(dict(zip(colList,d)))
      assert dbtu.dimsData[table] == got
    me.connection.commit()
  finally:
    for inst in toBeCleanedInstances:
      inst.drop(cursor)
    me.connection.commit()
    for inst in toBeCleanedInstances:
      inst._createSelf(cursor)
    me.connection.commit()