Ejemplo n.º 1
0
def test__failStalledJobs(mocker):
    """ Testing StalledJobAgent()._failStalledJobs()
  """

    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.AgentModule.__init__"
    )
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.AgentModule.am_getOption",
        side_effect=mockAM)
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.JobDB.__init__",
        side_effect=mockNone)
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.JobLoggingDB.__init__",
        side_effect=mockNone)

    stalledJobAgent = StalledJobAgent()
    stalledJobAgent._AgentModule__configDefaults = mockAM
    stalledJobAgent.initialize()
    stalledJobAgent.jobDB.log = gLogger
    stalledJobAgent.log = gLogger
    stalledJobAgent.log.setLevel('DEBUG')

    result = stalledJobAgent._failStalledJobs(0)

    assert not result['OK']
Ejemplo n.º 2
0
def test__markStalledJobs(mocker):
  """ Testing StalledJobAgent()._markStalledJobs()
  """

  mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.AgentModule.__init__")
  mocker.patch(
      "DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.AgentModule._AgentModule__moduleProperties",
      side_effect=lambda x, y=None: y, create=True
  )
  mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.JobDB.__init__", side_effect=mockNone)
  mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.JobLoggingDB.__init__", side_effect=mockNone)

  stalledJobAgent = StalledJobAgent()
  stalledJobAgent._AgentModule__configDefaults = mockAM
  stalledJobAgent.log = gLogger
  stalledJobAgent.initialize()
  stalledJobAgent.jobDB.log = gLogger
  stalledJobAgent.log.setLevel('DEBUG')
  stalledJobAgent.stalledTime = 120

  result = stalledJobAgent._markStalledJobs(0)

  assert not result['OK']
Ejemplo n.º 3
0
def sja(mocker):
    mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.AgentModule.__init__")
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.AgentModule._AgentModule__moduleProperties",
        side_effect=lambda x, y=None: y,
        create=True,
    )
    mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.JobDB.__init__", side_effect=mockNone)
    mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.JobLoggingDB.__init__", side_effect=mockNone)
    mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.getSystemInstance", side_effect=mockNone)

    stalledJobAgent = StalledJobAgent()
    stalledJobAgent._AgentModule__configDefaults = mockAM
    stalledJobAgent.log = gLogger
    stalledJobAgent.initialize()
    stalledJobAgent.jobDB.log = gLogger
    stalledJobAgent.log.setLevel("DEBUG")
    stalledJobAgent.stalledTime = 120

    return stalledJobAgent