Exemplo n.º 1
0
    def test_executor_fs_lock(self):
        # First, run the process normaly.
        data = self.run_process('test-save-number', {'number': 42})

        # Make sure that process was successfully ran first time.
        self.assertEqual(data.output['number'], 42)
        data.output = {}
        data.save()

        process = subprocess.run(
            ['python', '-m', 'executors', '.docker'],
            cwd=data.location.get_runtime_path(),
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            timeout=5,
        )

        # Drain control events generated by this executor.
        manager.reset(keep_state=True)

        self.assertEqual(process.returncode, 0)

        # Check the status of the data object.
        data.refresh_from_db()
        # Check that output is empty and thus process didn't ran.
        self.assertEqual(data.output, {})
        self.assertEqual(data.status, Data.STATUS_DONE)
        self.assertEqual(data.process_error, [])
Exemplo n.º 2
0
    def test_executor_fs_lock(self):
        # First, run the process normaly.
        data = self.run_process('test-save-number', {'number': 42})

        # Make sure that process was successfully ran first time.
        self.assertEqual(data.output['number'], 42)
        data.output = {}
        data.save()

        process = subprocess.run(
            ['python', '-m', 'executors', '.docker'],
            cwd=os.path.join(settings.FLOW_EXECUTOR['RUNTIME_DIR'],
                             str(data.pk)),
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            timeout=5,
        )

        # Drain control events generated by this executor.
        manager.reset(keep_state=True)

        self.assertEqual(process.returncode, 0)

        # Check the status of the data object.
        data.refresh_from_db()
        # Check that output is empty and thus process didn't ran.
        self.assertEqual(data.output, {})
        self.assertEqual(data.status, Data.STATUS_DONE)
        self.assertEqual(data.process_error, [])
Exemplo n.º 3
0
    def test_executor_fs_lock(self):
        # First, run the process normaly.
        data = self.run_process("test-save-number", {"number": 42})

        # Make sure that process was successfully ran first time.
        self.assertEqual(data.output["number"], 42)
        data.output = {}
        data.save()

        process = subprocess.run(
            ["python", "-m", "executors", ".docker"],
            cwd=data.location.get_runtime_path(),
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            timeout=5,
        )

        # Drain control events generated by this executor.
        manager.reset(keep_state=True)

        self.assertEqual(process.returncode, 0)

        # Check the status of the data object.
        data.refresh_from_db()
        # Check that output is empty and thus process didn't ran.
        self.assertEqual(data.output, {})
        self.assertEqual(data.status, Data.STATUS_DONE)
        self.assertEqual(data.process_error, [])
Exemplo n.º 4
0
def _manager_setup():
    """Execute setup operations common to serial and parallel testing.

    This mostly means state cleanup, such as resetting database
    connections and clearing the shared state.
    """
    if TESTING_CONTEXT.get("manager_reset", False):
        return
    TESTING_CONTEXT["manager_reset"] = True
    state.update_constants()
    manager.reset()
Exemplo n.º 5
0
def _manager_setup():
    """Execute setup operations common to serial and parallel testing.

    This mostly means state cleanup, such as resetting database
    connections and clearing the shared state.
    """
    if TESTING_CONTEXT.get('manager_reset', False):
        return
    TESTING_CONTEXT['manager_reset'] = True
    state.update_constants()
    manager.reset()
Exemplo n.º 6
0
def _manager_setup():
    """Execute setup operations common to serial and parallel testing.

    This mostly means state cleanup, such as resetting database
    connections and clearing the shared state.
    """
    for alias in db.connections:
        conn = db.connections[alias]
        conn.close()
        # Make very sure the connection is actually closed here, or the
        # same descriptor might be used in the processes we fork off in
        # the runner. In particular, the django_db_geventpool pools have
        # a closeall() method which isn't a no-op and actually shuts
        # down the pool.
        if hasattr(conn, 'closeall'):
            conn.closeall()
    state.update_constants()
    manager.reset()