Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuke testing class #2364

Merged
merged 52 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
fabfaac
OP-2019 - extracted headless_publish function to lib
kalisp Nov 16, 2021
939eabf
OP-2019 - remote publish needs to have order of methods flipped
kalisp Nov 16, 2021
6b45101
OP-2019 - added test classes for remote publish
kalisp Nov 16, 2021
af1a06c
OP-2019 - bump up version of PS
kalisp Nov 18, 2021
04fd46f
OP-2019 - added AE 2022
kalisp Nov 18, 2021
1369098
OP-2019 - added IS_TEST env var
kalisp Nov 18, 2021
30e39be
OP-2019 - removed setting env vars in class
kalisp Nov 18, 2021
35153fc
OP-2019 - added working test case for After Effects
kalisp Nov 18, 2021
7456d0c
OP-2019 - added remote publishing method for automatic tests
kalisp Nov 18, 2021
bcdca93
OP-2019 - removed unwanted host
kalisp Nov 18, 2021
1154f61
OP-2019 - added details into documentation
kalisp Nov 19, 2021
fab3b02
Merge remote-tracking branch 'origin/develop' into feature/OP-2042_nu…
kalisp Nov 30, 2021
5795636
OP-2042 - updates to db dumps and loads
kalisp Nov 30, 2021
3fa0b39
OP-2042 - wip testing in Nuke
kalisp Nov 30, 2021
d48fdae
Fix - missing extension for new workfile
kalisp Dec 1, 2021
d65431c
OP-2042 - remove pytest deprecation warnings
kalisp Dec 2, 2021
9dbae0e
OP-2042 - added NUKE_PATH to settings
kalisp Dec 2, 2021
591e81a
OP-2042 - comment out examples
kalisp Dec 2, 2021
fe86bbd
OP-2042 - working example of test publish in Nuke
kalisp Dec 2, 2021
e35920f
OP-2042 - replaced testing zip files
kalisp Dec 2, 2021
d4e5ab9
OP-2042 - added better documentation how to run it
kalisp Dec 2, 2021
5d85503
OP-2042 - removed forgotten app for debugging
kalisp Dec 2, 2021
1762f46
OP-2042 - fixed wrong value
kalisp Dec 2, 2021
49a6e8c
OP-2019 - merge origin/develop
kalisp Dec 2, 2021
9a5f906
Commit current develop avalon-core
kalisp Dec 2, 2021
ceeaf28
OP-2042 - clean up files from different PR
kalisp Dec 3, 2021
486966e
Reverting change to avalon-core
kalisp Dec 3, 2021
68b5078
OP-2042 - always capture stdout in pytest
kalisp Dec 3, 2021
d55d996
OP-2042 - added functionality to reuse existing folder for testdata
kalisp Dec 3, 2021
d0ada90
OP-2042 - added functionality to implicit choose variant
kalisp Dec 3, 2021
b61b363
OP-2042 - Hound
kalisp Dec 3, 2021
efa7bff
OP-2042 - added a bit of documentation
kalisp Dec 3, 2021
8eb7a30
OP-2042 - added a functionality to inject additional command line arg…
kalisp Dec 3, 2021
04c5053
OP-2042 - added a functionality to run tests either with start.py or …
kalisp Dec 6, 2021
150f6ef
OP-2042 - explicitly sort variants alphabetically
kalisp Dec 6, 2021
eda5ff6
OP-2042 - better format of asserts
kalisp Dec 6, 2021
4a93c69
OP-2042 - added mention of possibility to trigger it via executables
kalisp Dec 6, 2021
c0ad1b5
OP-2042 - use existing value of env var OPENPYPE_DATABASE_NAME if pos…
kalisp Dec 7, 2021
709d0ee
OP-2042 - reset connection to openpype DB
kalisp Dec 7, 2021
23ed14a
OP-2042 - remove superfluous logging
kalisp Dec 8, 2021
9e2760c
OP-2042 - better handling of reusing deployed workfile
kalisp Dec 8, 2021
a3638ef
OP-2042 - injection of TEST_SOURCE_FOLDER
kalisp Dec 8, 2021
e680a36
OP-2042 - additions to developer documentation
kalisp Dec 8, 2021
2f2116b
OP-2042 - added test_data_folder to command line
kalisp Dec 9, 2021
53bbae2
OP-2042 - better error message in validator
kalisp Dec 9, 2021
06a8f50
OP-2042 - evaluate paths in write nodes
kalisp Dec 10, 2021
00d9681
OP-2042 - better cleanup of test DBs before start of test
kalisp Dec 10, 2021
6e9c9c0
OP-2042 - adding persist, app_variant to cli
kalisp Dec 10, 2021
9a0d55e
OP-2042 - added new fixture output_folder_url
kalisp Dec 10, 2021
c754521
OP-2042 - added new handling of asserts
kalisp Dec 10, 2021
ec15b48
OP-2042 - added additional class wrapper per host
kalisp Dec 10, 2021
daa8eb5
OP-2042 - fix tested output path
kalisp Dec 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion openpype/hooks/pre_foundry_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LaunchFoundryAppsWindows(PreLaunchHook):

# Should be as last hook because must change launch arguments to string
order = 1000
app_groups = ["nuke", "nukex", "hiero", "nukestudio", "photoshop"]
app_groups = ["nuke", "nukex", "hiero", "nukestudio"]
platforms = ["windows"]

def execute(self):
Expand Down
29 changes: 29 additions & 0 deletions openpype/hosts/aftereffects/plugins/publish/closeAE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
"""Close AE after publish. For Webpublishing only."""
import os

import pyblish.api

from avalon import aftereffects
kalisp marked this conversation as resolved.
Show resolved Hide resolved


class CloseAE(pyblish.api.ContextPlugin):
"""Close AE after publish. For Webpublishing only.
"""

order = pyblish.api.IntegratorOrder + 14
label = "Close AE"
optional = True
active = True

hosts = ["aftereffects"]
targets = ["remotepublish"]

def process(self, context):
self.log.info("CloseAE")

stub = aftereffects.stub()
self.log.info("Shutting down AE")
stub.save()
stub.close()
self.log.info("AE closed")
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ def process(self, instance):
staging_dir = instance.data["stagingDir"]
self.log.info("staging_dir::{}".format(staging_dir))
kalisp marked this conversation as resolved.
Show resolved Hide resolved

stub.render(staging_dir)

# pull file name from Render Queue Output module
render_q = stub.get_render_info()
stub.render(staging_dir)
if not render_q:
raise ValueError("No file extension set in Render Queue")
_, ext = os.path.splitext(os.path.basename(render_q.file_name))
Expand Down
46 changes: 46 additions & 0 deletions openpype/lib/remote_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@
from openpype.lib.plugin_tools import parse_json


def headless_publish(log, close_plugin_name=None, is_test=False):
kalisp marked this conversation as resolved.
Show resolved Hide resolved
"""Runs publish in a opened host with a context and closes Python process.

Host is being closed via ClosePS pyblish plugin which triggers 'exit'
method in ConsoleTrayApp.
"""
if not is_test:
dbcon = get_webpublish_conn()
_id = os.environ.get("BATCH_LOG_ID")
if not _id:
log.warning("Unable to store log records, "
"batch will be unfinished!")
return

publish_and_log(dbcon, _id, log, close_plugin_name)
else:
publish(log, close_plugin_name)


def get_webpublish_conn():
"""Get connection to OP 'webpublishes' collection."""
mongo_client = OpenPypeMongoConnection.get_mongo_client()
Expand All @@ -37,6 +56,33 @@ def start_webpublish_log(dbcon, batch_id, user):
}).inserted_id


def publish(log, close_plugin_name=None):
"""Loops through all plugins, logs to console. Used for tests.

Args:
log (OpenPypeLogger)
close_plugin_name (str): name of plugin with responsibility to
close host app
"""
# Error exit as soon as any error occurs.
error_format = "Failed {plugin.__name__}: {error} -- {error.traceback}"

close_plugin = _get_close_plugin(close_plugin_name, log)

for result in pyblish.util.publish_iter():
for record in result["records"]:
log.info("{}: {}".format(
result["plugin"].label, record.msg))

if result["error"]:
log.error(error_format.format(**result))
uninstall()
if close_plugin: # close host app explicitly after error
context = pyblish.api.Context()
close_plugin().process(context)
sys.exit(1)


def publish_and_log(dbcon, _id, log, close_plugin_name=None):
"""Loops through all plugins, logs ok and fails into OP DB.

Expand Down
6 changes: 5 additions & 1 deletion openpype/pype_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def remotepublishfromapp(project, batch_dir, host_name,
task_name,
app_name
)
print("env:: {}".format(env))
os.environ.update(env)

os.environ["OPENPYPE_PUBLISH_DATA"] = batch_dir
Expand Down Expand Up @@ -364,7 +365,10 @@ def run_tests(self, folder, mark, pyargs):
if pyargs:
pyargs_str = "--pyargs {}".format(pyargs)

cmd = "pytest {} {} {}".format(folder, mark_str, pyargs_str)
depr_str = "--disable-pytest-warnings"

cmd = "pytest {} {} {} {}".format(depr_str, folder,
mark_str, pyargs_str)
print("Running {}".format(cmd))
subprocess.run(cmd)

Expand Down
21 changes: 19 additions & 2 deletions openpype/settings/defaults/system_settings/applications.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"icon": "{}/app_icons/nuke.png",
"host_name": "nuke",
"environment": {
"NUKE_PATH": "{OPENPYPE_STUDIO_PLUGINS}/nuke"
"NUKE_PATH": ["{NUKE_PATH}", "{OPENPYPE_STUDIO_PLUGINS}/nuke"]
},
"variants": {
"13-0": {
Expand Down Expand Up @@ -245,7 +245,7 @@
"icon": "{}/app_icons/nuke.png",
"host_name": "nuke",
"environment": {
"NUKE_PATH": "{OPENPYPE_STUDIO_PLUGINS}/nuke"
"NUKE_PATH": ["{NUKE_PATH}", "{OPENPYPE_STUDIO_PLUGINS}/nuke"]
},
"variants": {
"13-0": {
Expand Down Expand Up @@ -1098,6 +1098,23 @@
"linux": []
},
"environment": {}
},
"2022": {
"enabled": true,
"variant_label": "2022",
"executables": {
"windows": [
"C:\\Program Files\\Adobe\\Adobe After Effects 2022\\Support Files\\AfterFX.exe"
],
"darwin": [],
"linux": []
},
"arguments": {
"windows": [],
"darwin": [],
"linux": []
},
"environment": {}
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion repos/avalon-core
6 changes: 3 additions & 3 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ How to run:
----------
- single test class could be run by PyCharm and its pytest runner directly
- OR
- use Openpype command 'runtests' from command line
-- `${OPENPYPE_ROOT}/start.py runtests`
- use Openpype command 'runtests' from command line (`.venv` in ${OPENPYPE_ROOT} must be activated to use configured Python!)
-- `${OPENPYPE_ROOT}/python start.py runtests`

By default, this command will run all tests in ${OPENPYPE_ROOT}/tests.

Specific location could be provided to this command as an argument, either as absolute path, or relative path to ${OPENPYPE_ROOT}.
(eg. `${OPENPYPE_ROOT}/start.py runtests ../tests/integration`) will trigger only tests in `integration` folder.
(eg. `${OPENPYPE_ROOT}/python start.py runtests ../tests/integration`) will trigger only tests in `integration` folder.

See `${OPENPYPE_ROOT}/cli.py:runtests` for other arguments.
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import pytest
import os
import shutil

from tests.lib.testing_classes import PublishTest


class TestPublishInAfterEffects(PublishTest):
"""Basic test case for publishing in AfterEffects

Uses generic TestCase to prepare fixtures for test data, testing DBs,
env vars.

Opens AfterEffects, run publish on prepared workile.

Then checks content of DB (if subset, version, representations were
created.
Checks tmp folder if all expected files were published.

"""
PERSIST = True

TEST_FILES = [
("1qsrq6OJWVpOeXE2LTWrdbsLqEVu155Uf",
"test_aftereffects_publish.zip",
"")
]

APP = "aftereffects"
APP_VARIANT = "2021"

APP_NAME = "{}/{}".format(APP, APP_VARIANT)

TIMEOUT = 120 # publish timeout

@pytest.fixture(scope="module")
def last_workfile_path(self, download_test_data):
"""Get last_workfile_path from source data.

Maya expects workfile in proper folder, so copy is done first.
"""
src_path = os.path.join(download_test_data,
"input",
"workfile",
"test_project_test_asset_TestTask_v001.aep")
dest_folder = os.path.join(download_test_data,
self.PROJECT,
self.ASSET,
"work",
self.TASK)
os.makedirs(dest_folder)
dest_path = os.path.join(dest_folder,
"test_project_test_asset_TestTask_v001.aep")
shutil.copy(src_path, dest_path)

yield dest_path

@pytest.fixture(scope="module")
def startup_scripts(self, monkeypatch_session, download_test_data):
"""Points AfterEffects to userSetup file from input data"""
pass

def test_db_asserts(self, dbcon, publish_finished):
"""Host and input data dependent expected results in DB."""
print("test_db_asserts")
assert 5 == dbcon.count_documents({"type": "version"}), \
"Not expected no of versions"

assert 0 == dbcon.count_documents({"type": "version",
"name": {"$ne": 1}}), \
"Only versions with 1 expected"

assert 1 == dbcon.count_documents({"type": "subset",
"name": "modelMain"}), \
"modelMain subset must be present"

assert 1 == dbcon.count_documents({"type": "subset",
"name": "workfileTest_task"}), \
"workfileTest_task subset must be present"

assert 11 == dbcon.count_documents({"type": "representation"}), \
"Not expected no of representations"

assert 2 == dbcon.count_documents({"type": "representation",
"context.subset": "modelMain",
"context.ext": "abc"}), \
"Not expected no of representations with ext 'abc'"

assert 2 == dbcon.count_documents({"type": "representation",
"context.subset": "modelMain",
"context.ext": "ma"}), \
"Not expected no of representations with ext 'abc'"


if __name__ == "__main__":
test_case = TestPublishInAfterEffects()
10 changes: 8 additions & 2 deletions tests/integration/hosts/maya/test_publish_in_maya.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ class TestPublishInMaya(PublishTest):
Uses generic TestCase to prepare fixtures for test data, testing DBs,
env vars.

Opens Maya, run publish on prepared workile.
Always pulls and uses test data from GDrive!

Opens Maya, runs publish on prepared workile.

Then checks content of DB (if subset, version, representations were
created.
Checks tmp folder if all expected files were published.

How to run:
(in cmd with activated {OPENPYPE_ROOT}/.venv)
{OPENPYPE_ROOT}/.venv/Scripts/python.exe {OPENPYPE_ROOT}/start.py runtests ../tests/integration/hosts/maya # noqa: E501

"""
PERSIST = True

TEST_FILES = [
("1pOwjA_VVBc6ooTZyFxtAwLS2KZHaBlkY", "test_maya_publish.zip", "")
("1BTSIIULJTuDc8VvXseuiJV_fL6-Bu7FP", "test_maya_publish.zip", "")
]

APP = "maya"
Expand Down