示例#1
0
 def test_should_not_kill_execs(self):
     """``container_shell`` '_should_not_kill' returns True if execs are running against the container"""
     self.container.attrs['ExecIDs'] = [MagicMock(), MagicMock()]
     answer = container_shell._should_not_kill(self.container, self.persist,
                                               self.persist_egrep,
                                               self.ps_path, self.logger)
     self.assertTrue(answer)
示例#2
0
 def test_should_not_kill_no_persist(self):
     """``container_shell`` '_should_not_kill' returns False if no running execs and persist is false"""
     self.persist = 'false'
     answer = container_shell._should_not_kill(self.container, self.persist,
                                               self.persist_egrep,
                                               self.ps_path, self.logger)
     self.assertFalse(answer)
示例#3
0
    def test_should_not_kill_background_jobs(self):
        """``container_shell`` '_should_not_kill' returns True if persist is true and background jobs are found"""
        ps_output = b'USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND\nsally\t20\t0.0\t.0.0\t0\t0\t?\tS\tFed08\t0:00\t screen'
        self.container.exec_run.return_value = ('', ps_output)
        answer = container_shell._should_not_kill(self.container, self.persist,
                                                  self.persist_egrep,
                                                  self.ps_path, self.logger)

        self.assertTrue(answer)
示例#4
0
    def test_container_not_found(self):
        """``container_shell`` '_should_not_kill' returns None if the container doesn't exist"""
        docker.errors.NotFound = Exception
        self.container.exec_run.side_effect = Exception('Testing')

        answer = container_shell._should_not_kill(self.container, self.persist,
                                                  self.persist_egrep,
                                                  self.ps_path, self.logger)

        self.assertTrue(answer is None)
示例#5
0
 def test_should_not_kill(self):
     """``container_shell`` '_should_not_kill' returns False if no running execs, persist is false, and no background jobs are found"""
     answer = container_shell._should_not_kill(self.container, self.persist,
                                               self.persist_egrep,
                                               self.ps_path, self.logger)
     self.assertFalse(answer)