Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CURRENT_YEAR ?= $(shell date +%Y)
# Quarto settings
QUARTO ?= quarto
# quartodoc doesn't like py3.8; Run using `--with` as it can conflict with the project's dependencies
QUARTODOC ?= --no-cache --with "quartodoc==0.8.1" quartodoc
QUARTODOC ?= --no-cache --with "quartodoc==0.11.1" quartodoc

# Netlify settings
NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee
Expand Down
1 change: 1 addition & 0 deletions integration/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ PYTEST_ARGS ?= "-s"

# Versions
CONNECT_VERSIONS := \
2025.07.0 \
2025.06.0 \
2025.05.0 \
2025.04.0 \
Expand Down
1 change: 1 addition & 0 deletions integration/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
- CONNECT_BOOTSTRAP_ENABLED=true
- CONNECT_BOOTSTRAP_SECRETKEY=${CONNECT_BOOTSTRAP_SECRETKEY}
- CONNECT_APPLICATIONS_PACKAGEAUDITINGENABLED=true
- CONNECT_TENSORFLOW_ENABLED=false
networks:
- test
privileged: true
Expand Down
66 changes: 27 additions & 39 deletions integration/tests/posit/connect/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,62 +11,50 @@


@pytest.mark.skipif(
# Added to the v2023.05.0 milestone
# https://github.com/rstudio/connect/pull/23148
CONNECT_VERSION < version.parse("2023.05.0"),
CONNECT_VERSION < version.parse("2024.05.0"),
reason="Cache runtimes not implemented",
)
class TestSystem:
@classmethod
def setup_class(cls):
cls.client = Client()
assert cls.client.content.count() == 0
cls.content_item = cls.client.content.create(name="Content_A")

# Copied from from integration/tests/posit/connect/test_packages.py
def _deploy_python_bundle(self):
cls.content = cls.client.content.create(name=cls.__name__)
path = Path("../../../resources/connect/bundles/example-flask-minimal/bundle.tar.gz")
path = (Path(__file__).parent / path).resolve()
bundle = self.content_item.bundles.create(str(path))
bundle = cls.content.bundles.create(str(path))
task = bundle.deploy()
task.wait_for()

def _remove_all_caches(self):
caches: list[SystemRuntimeCache] = self.client.system.caches.runtime.find()
for cache in caches:
assert isinstance(cache, SystemRuntimeCache)
none_val = cache.destroy(dry_run=True)
assert none_val is None
task: Task = cache.destroy()
assert isinstance(task, Task)
task.wait_for()
assert len(self.client.system.caches.runtime.find()) == 0

@classmethod
def teardown_class(cls):
cls.content_item.delete()
assert cls.client.content.count() == 0
cls.content.delete()

def test_runtime_caches(self):
# Get current caches
caches: list[SystemRuntimeCache] = self.client.system.caches.runtime.find()
assert isinstance(caches, list)
runtimes = self.client.system.caches.runtime.find()
assert len(runtimes) > 0

# Remove all caches
self._remove_all_caches()
def test_runtime_cache_destroy(self):
# Find existing runtime caches
runtimes: list[SystemRuntimeCache] = self.client.system.caches.runtime.find()
assert len(runtimes) > 0

# Deploy a new cache
self._deploy_python_bundle()
# Get the first cache for testing
cache = runtimes[0]
assert isinstance(cache, SystemRuntimeCache)

# Check if the cache is deployed
caches = self.client.system.caches.runtime.find()
# Test dry run destroy (should return None and not actually destroy)
result = cache.destroy(dry_run=True)
assert result is None

# Barret 2024/12:
# Caches only showing up in Connect versions >= 2024.05.0
# I do not know why.
# Since we are not logic testing Connect, we can confirm our code works given more recent versions of Connect.
if CONNECT_VERSION >= version.parse("2024.05.0"):
assert len(caches) > 0
# Verify cache still exists after dry run
runtimes_after_dry_run = self.client.system.caches.runtime.find()
assert len(runtimes_after_dry_run) == len(runtimes)

# Test actual destroy
task: Task = cache.destroy()
assert isinstance(task, Task)
task.wait_for()

# Remove all caches
self._remove_all_caches()
# Verify cache was removed
runtimes_after_destroy = self.client.system.caches.runtime.find()
assert len(runtimes_after_destroy) == len(runtimes) - 1