Exemplo n.º 1
0
    def test_PilotsDB(self):

        wmsAdministrator = RPCClient('WorkloadManagement/WMSAdministrator')
        pilotAgentDB = PilotAgentsDB()

        res = wmsAdministrator.addPilotTQReference(['aPilot'], 1, '/a/ownerDN',
                                                   'a/owner/Group')
        self.assert_(res['OK'])
        res = wmsAdministrator.getCurrentPilotCounters({})
        self.assert_(res['OK'])
        self.assertEqual(res['Value'], {'Submitted': 1L})
        res = pilotAgentDB.deletePilot('aPilot')
        self.assert_(res['OK'])
        res = wmsAdministrator.getCurrentPilotCounters({})
        self.assert_(res['OK'])
        self.assertEqual(res['Value'], {})

        res = wmsAdministrator.addPilotTQReference(['anotherPilot'], 1,
                                                   '/a/ownerDN',
                                                   'a/owner/Group')
        self.assert_(res['OK'])
        res = wmsAdministrator.storePilotOutput('anotherPilot',
                                                'This is an output',
                                                'this is an error')
        self.assert_(res['OK'])
        res = wmsAdministrator.getPilotOutput('anotherPilot')
        self.assert_(res['OK'])
        self.assertEqual(
            res['Value'], {
                'OwnerDN': '/a/ownerDN',
                'OwnerGroup': 'a/owner/Group',
                'StdErr': 'this is an error',
                'FileList': [],
                'StdOut': 'This is an output'
            })
        # need a job for the following
        #     res = wmsAdministrator.getJobPilotOutput( 1 )
        #     self.assertEqual( res['Value'], {'OwnerDN': '/a/ownerDN', 'OwnerGroup': 'a/owner/Group',
        #                                      'StdErr': 'this is an error', 'FileList': [], 'StdOut': 'This is an output'} )
        #     self.assert_( res['OK'] )
        res = wmsAdministrator.getPilotInfo('anotherPilot')
        self.assert_(res['OK'])
        self.assertEqual(res['Value']['anotherPilot']['AccountingSent'],
                         'False')
        self.assertEqual(res['Value']['anotherPilot']['PilotJobReference'],
                         'anotherPilot')

        res = wmsAdministrator.selectPilots({})
        self.assert_(res['OK'])
        #     res = wmsAdministrator.getPilotLoggingInfo( 'anotherPilot' )
        #     self.assert_( res['OK'] )
        res = wmsAdministrator.getPilotSummary('', '')
        self.assert_(res['OK'])
        self.assertEqual(res['Value']['Total']['Submitted'], 1)
        res = wmsAdministrator.getPilotMonitorWeb({}, [], 0, 100)
        self.assert_(res['OK'])
        self.assertEqual(res['Value']['TotalRecords'], 1)
        res = wmsAdministrator.getPilotMonitorSelectors()
        self.assert_(res['OK'])
        self.assertEqual(
            res['Value'], {
                'GridType': ['DIRAC'],
                'OwnerGroup': ['a/owner/Group'],
                'DestinationSite': ['NotAssigned'],
                'Broker': ['Unknown'],
                'Status': ['Submitted'],
                'OwnerDN': ['/a/ownerDN'],
                'GridSite': ['Unknown'],
                'Owner': []
            })
        res = wmsAdministrator.getPilotSummaryWeb({}, [], 0, 100)
        self.assert_(res['OK'])
        self.assertEqual(res['Value']['TotalRecords'], 1)

        res = wmsAdministrator.setAccountingFlag('anotherPilot', 'True')
        self.assert_(res['OK'])
        res = wmsAdministrator.setPilotStatus('anotherPilot', 'Running')
        self.assert_(res['OK'])
        res = wmsAdministrator.getPilotInfo('anotherPilot')
        self.assert_(res['OK'])
        self.assertEqual(res['Value']['anotherPilot']['AccountingSent'],
                         'True')
        self.assertEqual(res['Value']['anotherPilot']['Status'], 'Running')

        res = wmsAdministrator.setJobForPilot(123, 'anotherPilot')
        self.assert_(res['OK'])
        res = wmsAdministrator.setPilotBenchmark('anotherPilot', 12.3)
        self.assert_(res['OK'])
        res = wmsAdministrator.countPilots({})
        self.assert_(res['OK'])
        #     res = wmsAdministrator.getCounters()
        #     # getPilotStatistics

        res = pilotAgentDB.deletePilot('anotherPilot')
        self.assert_(res['OK'])
        res = wmsAdministrator.getCurrentPilotCounters({})
        self.assert_(res['OK'])
        self.assertEqual(res['Value'], {})
Exemplo n.º 2
0
  def test_PilotsDB( self ):

    wmsAdministrator = RPCClient( 'WorkloadManagement/WMSAdministrator' )
    pilotAgentDB = PilotAgentsDB()


    res = wmsAdministrator.addPilotTQReference( ['aPilot'], 1, '/a/ownerDN', 'a/owner/Group' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.getCurrentPilotCounters( {} )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value'], {'Submitted': 1L} )
    res = pilotAgentDB.deletePilot( 'aPilot' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.getCurrentPilotCounters( {} )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value'], {} )

    res = wmsAdministrator.addPilotTQReference( ['anotherPilot'], 1, '/a/ownerDN', 'a/owner/Group' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.storePilotOutput( 'anotherPilot', 'This is an output', 'this is an error' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.getPilotOutput( 'anotherPilot' )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value'], {'OwnerDN': '/a/ownerDN',
                                     'OwnerGroup': 'a/owner/Group',
                                     'StdErr': 'this is an error',
                                     'FileList': [],
                                     'StdOut': 'This is an output'} )
    # need a job for the following
#     res = wmsAdministrator.getJobPilotOutput( 1 )
#     self.assertEqual( res['Value'], {'OwnerDN': '/a/ownerDN', 'OwnerGroup': 'a/owner/Group',
#                                      'StdErr': 'this is an error', 'FileList': [], 'StdOut': 'This is an output'} )
#     self.assert_( res['OK'] )
    res = wmsAdministrator.getPilotInfo( 'anotherPilot' )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value']['anotherPilot']['AccountingSent'], 'False' )
    self.assertEqual( res['Value']['anotherPilot']['PilotJobReference'], 'anotherPilot' )

    res = wmsAdministrator.selectPilots( {} )
    self.assert_( res['OK'] )
#     res = wmsAdministrator.getPilotLoggingInfo( 'anotherPilot' )
#     self.assert_( res['OK'] )
    res = wmsAdministrator.getPilotSummary( '', '' )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value']['Total']['Submitted'], 1 )
    res = wmsAdministrator.getPilotMonitorWeb( {}, [], 0, 100 )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value']['TotalRecords'], 1 )
    res = wmsAdministrator.getPilotMonitorSelectors()
    self.assert_( res['OK'] )
    self.assertEqual( res['Value'], {'GridType': ['DIRAC'], 
                                     'OwnerGroup': ['a/owner/Group'], 
                                     'DestinationSite': ['NotAssigned'], 
                                     'Broker': ['Unknown'], 'Status': ['Submitted'], 
                                     'OwnerDN': ['/a/ownerDN'], 
                                     'GridSite': ['Unknown'], 
                                     'Owner': []} )
    res = wmsAdministrator.getPilotSummaryWeb( {}, [], 0, 100 )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value']['TotalRecords'], 1 )

    res = wmsAdministrator.setAccountingFlag( 'anotherPilot', 'True' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.setPilotStatus( 'anotherPilot', 'Running' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.getPilotInfo( 'anotherPilot' )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value']['anotherPilot']['AccountingSent'], 'True' )
    self.assertEqual( res['Value']['anotherPilot']['Status'], 'Running' )

    res = wmsAdministrator.setJobForPilot( 123, 'anotherPilot' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.setPilotBenchmark( 'anotherPilot', 12.3 )
    self.assert_( res['OK'] )
    res = wmsAdministrator.countPilots( {} )
    self.assert_( res['OK'] )
#     res = wmsAdministrator.getCounters()
#     # getPilotStatistics

    res = pilotAgentDB.deletePilot( 'anotherPilot' )
    self.assert_( res['OK'] )
    res = wmsAdministrator.getCurrentPilotCounters( {} )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value'], {} )