def test_safeAutoDeploy(self):
   """Scenario 7: isSRReady won't overwrite the existing
   Sofware Instance if it has been deployed yet"""
   # Test that SR won't be deployed with auto_deploy=False
   self.updateConfigParameter('auto_deploy', False)
   self.updateConfigParameter('autorun', False)
   project = open(os.path.join(self.app.config['etc_dir'],
                 '.project'), "w")
   project.write(self.software + 'slaprunner-test')
   project.close()
   response = isSoftwareReleaseReady(self.app.config)
   self.assertEqual(response, "0")
   # Test if auto_deploy parameter starts the deployment of SR
   self.updateConfigParameter('auto_deploy', True)
   self.setupTestSoftware()
   response = isSoftwareReleaseReady(self.app.config)
   self.assertEqual(response, "2")
   # Test that the new call to isSoftwareReleaseReady
   # doesn't overwrite the previous installed one
   sup_process.killRunningProcess(self.app.config, 'slapgrid-sr')
   completed_path = os.path.join(self.app.config['runner_workdir'],
       'softwareLink', 'slaprunner-test', '.completed')
   completed_text = ".completed file: test"
   completed = open(completed_path, "w")
   completed.write(completed_text)
   completed.close()
   response = isSoftwareReleaseReady(self.app.config)
   self.assertEqual(response, "1")
   assert completed_text in open(completed_path).read()
  def tearDown(self):
    """Remove all test data"""
    project = os.path.join(self.app.config['etc_dir'], '.project')
    users = os.path.join(self.app.config['etc_dir'], '.users')

    #reset tested parameters
    self.updateConfigParameter('autorun', False)
    self.updateConfigParameter('auto_deploy', True)

    if os.path.exists(users):
      os.unlink(users)
    if os.path.exists(project):
      os.unlink(project)
    if os.path.exists(self.app.config['workspace']):
      shutil.rmtree(self.app.config['workspace'])
    if os.path.exists(self.app.config['software_root']):
      shutil.rmtree(self.app.config['software_root'])
    if os.path.exists(self.app.config['instance_root']):
      shutil.rmtree(self.app.config['instance_root'])
    if os.path.exists(self.app.config['software_link']):
      shutil.rmtree(self.app.config['software_link'])
    #Stop process
    sup_process.killRunningProcess(self.app.config, 'slapproxy')
    sup_process.killRunningProcess(self.app.config, 'slapgrid-cp')
    sup_process.killRunningProcess(self.app.config, 'slapgrid-sr')
Beispiel #3
0
def stopSlapgrid():
  counter_file = os.path.join(app.config['runner_workdir'], '.turn-left')
  open(counter_file, 'w+').write(str(0))
  result = sup_process.killRunningProcess(app.config, request.form['type'])
  return jsonify(result=result)