def test_addAndRemove(self): """ Some test cases """ systemName = 'TestSystem' subSystemName = 'TestSubSystem' level = 10 time = toString() msgTest = 'Hello' variableText = time frameInfo = "" message = tupleToMessage((systemName, level, time, msgTest, variableText, frameInfo, subSystemName)) site = 'somewehere' longSite = 'somewehere1234567890123456789012345678901234567890123456789012345678901234567890' nodeFQDN = '127.0.0.1' userDN = 'Yo' userGroup = 'Us' remoteAddress = 'elsewhere' records = 10 db = SystemLoggingDB() res = db._connect() self.assertTrue(res['OK']) gLogger.info('\n Inserting some records\n') for k in xrange(records): result = db.insertMessage(message, site, nodeFQDN, userDN, userGroup, remoteAddress) self.assertTrue(result['OK']) self.assertEqual(result['lastRowId'], k + 1) self.assertEqual(result['Value'], 1) result = db._queryDB(showFieldList=['SiteName']) self.assertTrue(result['OK']) self.assertEqual(result['Value'][0][0], site) result = db._queryDB(showFieldList=['SystemName']) self.assertTrue(result['OK']) self.assertEqual(result['Value'][0][0], systemName) result = db._queryDB(showFieldList=['SubSystemName']) self.assertTrue(result['OK']) self.assertEqual(result['Value'][0][0], subSystemName) result = db._queryDB(showFieldList=['OwnerGroup']) self.assertTrue(result['OK']) self.assertEqual(result['Value'][0][0], userGroup) result = db._queryDB(showFieldList=['FixedTextString']) self.assertTrue(result['OK']) self.assertEqual(result['Value'][0][0], msgTest) result = db._queryDB(showFieldList=['VariableText', 'SiteName'], count=True, groupColumn='VariableText') self.assertTrue(result['OK']) self.assertEqual(result['Value'][0][1], site) self.assertEqual(result['Value'][0][2], records) result = db.insertMessage(message, longSite, nodeFQDN, userDN, userGroup, remoteAddress) self.assertFalse(result['OK'])
def initializeSystemLoggingHandler( serviceInfo ): """ Check that we can connect to the DB and that the tables are properly created or updated """ global gLogDB gLogDB = SystemLoggingDB() res = gLogDB._connect() if not res['OK']: return res return S_OK()
def initializeSystemLoggingHandler(serviceInfo): """ Check that we can connect to the DB and that the tables are properly created or updated """ global gLogDB gLogDB = SystemLoggingDB() res = gLogDB._connect() if not res['OK']: return res return S_OK()
def initializeSystemLoggingHandler( serviceInfo ): """ Check that we can connect to the DB and that the tables are properly created or updated """ global gLogDB gLogDB = SystemLoggingDB() res = gLogDB._connect() if not res['OK']: return res res = gLogDB._checkTable() if not res['OK'] and not res['Message'] == 'The requested table already exist': return res return S_OK()
def initializeSystemLoggingHandler(serviceInfo): """ Check that we can connect to the DB and that the tables are properly created or updated :param dict serviceInfo: service information dictionary :return: S_OK()/S_ERROR() """ global gLogDB gLogDB = SystemLoggingDB() res = gLogDB._connect() if not res['OK']: return res return S_OK()