Skip to content

Commit

Permalink
Offline license (#7804)
Browse files Browse the repository at this point in the history
Co-authored-by: Michał Bartoszkiewicz <[email protected]>
GitOrigin-RevId: 24be4beadca59a176d0749fba5b0aa1048df4a16
  • Loading branch information
2 people authored and Manul from Pathway committed Dec 5, 2024
1 parent e04670c commit 6fc1998
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 80 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ csv = "1.3.0"
deltalake = { version = "0.19.0", features = ["datafusion", "s3-native-tls"] }
derivative = "2.2.0"
differential-dataflow = { path = "./external/differential-dataflow" }
ed25519-dalek = { version = "2.1.1", features = ["serde", "pkcs8"] }
elasticsearch = "8.15.0-alpha.1"
futures = "0.3.30"
glob = "0.3.1"
hex = "0.4.3"
hyper = { version = "0.14", features = ["server"] }
id-arena = "2.2.1"
itertools = "0.13.0"
Expand Down
Empty file.
77 changes: 77 additions & 0 deletions integration_tests/license/test_license.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# import pathway.internals as pw
import json
import logging
import os
import re

import pytest

import pathway as pw
from pathway.internals.config import _check_entitlements
from pathway.tests.utils import run_all

PATHWAY_LICENSES = json.loads(os.environ.get("PATHWAY_LICENSES", "{}"))


def test_license_malformed():
pw.set_license_key(PATHWAY_LICENSES["malformed"])
with pytest.raises(
RuntimeError,
match=r"unable to validate license",
):
pw.run_all()


def test_license_wrong_signature():
pw.set_license_key(PATHWAY_LICENSES["wrong-signature"])
with pytest.raises(
RuntimeError,
match=r"unable to validate license: license file is invalid",
):
pw.run_all()


@pytest.mark.parametrize("license", ["default", "default-key"])
def test_license_default_key(license, caplog):
caplog.set_level(level=logging.INFO)
pw.set_license_key(PATHWAY_LICENSES[license])
run_all()
assert "Telemetry enabled" in caplog.text
assert "Monitoring server:" in caplog.text


@pytest.mark.parametrize("license", ["default", "default-key"])
def test_license_default_key_insufficient_entitlements(license, caplog):
pw.set_license_key(PATHWAY_LICENSES[license])
with pytest.raises(
RuntimeError,
match=re.escape(
'one of the features you used ["XPACK-SPATIAL"] requires upgrading your Pathway license.'
),
):
_check_entitlements("xpack-spatial")


def test_license_enterprise(caplog):
caplog.set_level(level=logging.INFO)
pw.set_license_key(PATHWAY_LICENSES["enterprise-no-expire"])

_check_entitlements("xpack-spatial")
run_all()

assert "Telemetry enabled" not in caplog.text
assert "Monitoring server:" in caplog.text


def test_license_enterprise_expired(caplog):
caplog.set_level(level=logging.INFO)
pw.set_license_key(PATHWAY_LICENSES["enterprise-expired"])

_check_entitlements("xpack-spatial")
run_all()

assert (
"License has expired. Please renew to continue using the service" in caplog.text
)
assert "Telemetry enabled" not in caplog.text
assert "Monitoring server:" in caplog.text
2 changes: 1 addition & 1 deletion python/pathway/tests/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_monitoring_insufficient_license():
with pytest.raises(
api.EngineError,
match=re.escape(
'one of the features you used ["monitoring"] requires upgrading your Pathway license'
'one of the features you used ["MONITORING"] requires upgrading your Pathway license'
),
):
run_all()
Loading

0 comments on commit 6fc1998

Please sign in to comment.