feat(platform): complete the Gelios external data loop
This commit is contained in:
@@ -11,6 +11,10 @@ from pathlib import Path
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
BUILDER = SCRIPT_DIR / "build-engine-data-product-publish-grant-artifact.mjs"
|
||||
ENGINE_ROOT = SCRIPT_DIR.parent.parent.parent / "NODEDC_ENGINE_INFRA"
|
||||
HISTORICAL_PROVIDER_CATALOG_SHA256 = (
|
||||
"9c931f9abfcadb5b34a8a854c2efb8fd79913e000eecf0967d1b7c500bf9a56a"
|
||||
)
|
||||
EXPECTED_ENTRIES = [
|
||||
"nodedc-source/server/assets/provider-packages/v1/catalog.json",
|
||||
"nodedc-source/server/dataProductPublishGrant",
|
||||
@@ -26,6 +30,13 @@ SUCCESSFUL_CREDENTIAL_SINK_INDEX_SHA256 = (
|
||||
|
||||
|
||||
class EnginePublishGrantArtifactTest(unittest.TestCase):
|
||||
def historical_source_is_current(self):
|
||||
catalog = (
|
||||
ENGINE_ROOT
|
||||
/ "nodedc-source/server/assets/provider-packages/v1/catalog.json"
|
||||
)
|
||||
return hashlib.sha256(catalog.read_bytes()).hexdigest() == HISTORICAL_PROVIDER_CATALOG_SHA256
|
||||
|
||||
def build(self, artifact_dir, patch_id):
|
||||
environment = os.environ.copy()
|
||||
environment["NODEDC_DEPLOY_ARTIFACT_DIR"] = str(artifact_dir)
|
||||
@@ -39,6 +50,8 @@ class EnginePublishGrantArtifactTest(unittest.TestCase):
|
||||
return json.loads(result.stdout)
|
||||
|
||||
def test_artifact_is_narrow_secret_free_and_deterministic(self):
|
||||
if not self.historical_source_is_current():
|
||||
self.skipTest("historical Publish-grant builder source has advanced to its exact successor")
|
||||
with tempfile.TemporaryDirectory(prefix="nodedc-engine-publish-artifact-") as directory:
|
||||
root = Path(directory)
|
||||
first_dir = root / "first"
|
||||
@@ -70,6 +83,18 @@ class EnginePublishGrantArtifactTest(unittest.TestCase):
|
||||
"payload/nodedc-source/services/backend/data-product-publish-grant/"
|
||||
"docker-compose.immutable-runtime.yml"
|
||||
).read().decode("utf-8")
|
||||
catalog = json.loads(archive.extractfile(
|
||||
"payload/nodedc-source/server/assets/provider-packages/v1/catalog.json"
|
||||
).read())
|
||||
provider_catalog_source = archive.extractfile(
|
||||
"payload/nodedc-source/server/dataProductPublishGrant/providerCatalog.js"
|
||||
).read().decode("utf-8")
|
||||
service_source = archive.extractfile(
|
||||
"payload/nodedc-source/server/dataProductPublishGrant/service.js"
|
||||
).read().decode("utf-8")
|
||||
store_source = archive.extractfile(
|
||||
"payload/nodedc-source/server/dataProductPublishGrant/store.js"
|
||||
).read().decode("utf-8")
|
||||
|
||||
self.assertEqual(files, EXPECTED_ENTRIES)
|
||||
self.assertEqual(
|
||||
@@ -115,6 +140,29 @@ class EnginePublishGrantArtifactTest(unittest.TestCase):
|
||||
)
|
||||
self.assertIn("read_only: true", runtime_override)
|
||||
self.assertEqual(runtime_override.count("create_host_path: false"), 2)
|
||||
provider = catalog["packages"][0]
|
||||
self.assertEqual(first["providerPackage"], "gelios.provider.v4")
|
||||
self.assertEqual(first["dataProductId"], "fleet.positions.current.v3")
|
||||
self.assertEqual(first["credentialValues"], "preserved")
|
||||
self.assertEqual(provider["id"], "gelios.provider.v4")
|
||||
self.assertEqual(
|
||||
[capability["id"] for capability in provider["capabilities"]],
|
||||
[
|
||||
"gelios.monitoring_config.current.read",
|
||||
"gelios.units.current.read",
|
||||
],
|
||||
)
|
||||
self.assertEqual(
|
||||
[capability["request"]["url"] for capability in provider["capabilities"]],
|
||||
[
|
||||
"https://api.geliospro.com/api/v1/users/me/monitoring-config",
|
||||
"https://api.geliospro.com/api/v1/units?incltrip=true",
|
||||
],
|
||||
)
|
||||
self.assertIn("function capabilityRequests(capability)", provider_catalog_source)
|
||||
self.assertIn("exactHttpRequestUrl(n8n)", provider_catalog_source)
|
||||
self.assertIn("providerRequestNodeIds", service_source)
|
||||
self.assertIn("providerRequestNodeIds", store_source)
|
||||
|
||||
def test_builder_requires_a_fresh_never_issued_patch_id(self):
|
||||
with tempfile.TemporaryDirectory(prefix="nodedc-engine-publish-id-") as directory:
|
||||
@@ -140,6 +188,8 @@ class EnginePublishGrantArtifactTest(unittest.TestCase):
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertIn(expected, result.stderr)
|
||||
|
||||
if not self.historical_source_is_current():
|
||||
return
|
||||
self.build(artifact_dir, PATCH_ID)
|
||||
duplicate = subprocess.run(
|
||||
["node", str(BUILDER), PATCH_ID],
|
||||
|
||||
Reference in New Issue
Block a user