Exemplo n.º 1
0
    def test_resolver_init_and_connections_contexts(self):
        store = V1ConnectionType(
            name="test_claim",
            kind=V1ConnectionKind.VOLUME_CLAIM,
            schema=V1ClaimConnection(
                mount_path="/claim/path", volume_claim="claim", read_only=True
            ),
        )

        compiled_operation = V1CompiledOperation.read(
            {
                "version": 1.05,
                "kind": kinds.COMPILED_OPERATION,
                "plugins": {
                    "auth": False,
                    "shm": False,
                    "collectLogs": False,
                    "collectArtifacts": False,
                    "collectResources": False,
                },
                "run": {
                    "kind": V1RunKind.JOB,
                    "container": {"image": "test"},
                    "connections": [store.name],
                    "init": [{"connection": store.name}],
                },
            }
        )
        spec = resolve_contexts(
            namespace="test",
            owner_name="user",
            project_name="project",
            project_uuid="uuid",
            run_uuid="uuid",
            run_name="run",
            run_path="test",
            compiled_operation=compiled_operation,
            artifacts_store=store,
            connection_by_names={store.name: store},
            iteration=12,
        )
        assert spec == {
            "globals": {
                "owner_name": "user",
                "project_unique_name": "user.project",
                "project_name": "project",
                "project_uuid": "uuid",
                "name": "run",
                "uuid": "uuid",
                "artifacts_path": "/claim/path/test",
                "namespace": "test",
                "iteration": 12,
                "run_info": "user.project.runs.uuid",
            },
            "init": {"test_claim": store.schema.to_dict()},
            "connections": {"test_claim": store.schema.to_dict()},
        }
Exemplo n.º 2
0
 def test_resolver_default_service_ports(self):
     compiled_operation = V1CompiledOperation.read({
         "version": 1.1,
         "kind": kinds.COMPILED_OPERATION,
         "plugins": {
             "auth": False,
             "shm": False,
             "collectLogs": False,
             "collectArtifacts": True,
             "collectResources": True,
         },
         "run": {
             "kind": V1RunKind.SERVICE,
             "ports": [1212, 1234],
             "container": {
                 "image": "test",
                 "command": "{{ ports[0] }}"
             },
         },
     })
     spec = resolve_contexts(
         namespace="test",
         owner_name="user",
         project_name="project",
         project_uuid="uuid",
         run_uuid="uuid",
         run_name="run",
         run_path="test",
         compiled_operation=compiled_operation,
         artifacts_store=None,
         connection_by_names={},
         iteration=12,
     )
     assert spec == {
         "globals": {
             "owner_name": "user",
             "project_name": "project",
             "project_unique_name": "user.project",
             "project_uuid": "uuid",
             "run_info": "user.project.runs.uuid",
             "name": "run",
             "uuid": "uuid",
             "context_path": "/plx-context",
             "artifacts_path": "/plx-context/artifacts",
             "run_artifacts_path": "/plx-context/artifacts/test",
             "run_outputs_path": "/plx-context/artifacts/test/outputs",
             "namespace": "test",
             "iteration": 12,
             "ports": [1212, 1234],
             "base_url": "/services/v1/test/user/project/runs/uuid",
         },
         "init": {},
         "connections": {},
     }
Exemplo n.º 3
0
 def resolve_contexts(self):
     self.contexts = resolve_contexts(
         namespace=self.namespace,
         owner_name=self.owner_name,
         project_name=self.project_name,
         project_uuid=self.project_uuid,
         run_name=self.run_name,
         run_path=self.run_path,
         run_uuid=self.run_uuid,
         compiled_operation=self.compiled_operation,
         connection_by_names=self.connection_by_names,
         artifacts_store=self.artifacts_store,
         iteration=self.iteration,
     )
Exemplo n.º 4
0
 def test_resolver_default_contexts(self):
     compiled_operation = V1CompiledOperation.read({
         "version": 1.1,
         "kind": kinds.COMPILED_OPERATION,
         "plugins": {
             "auth": False,
             "shm": False,
             "collectLogs": False,
             "collectArtifacts": False,
             "collectResources": False,
         },
         "run": {
             "kind": V1RunKind.JOB,
             "container": {
                 "image": "test"
             }
         },
     })
     spec = resolve_contexts(
         namespace="test",
         owner_name="user",
         project_name="project",
         project_uuid="uuid",
         run_uuid="uuid",
         run_name="run",
         run_path="test",
         compiled_operation=compiled_operation,
         artifacts_store=None,
         connection_by_names={},
         iteration=None,
     )
     assert spec == {
         "globals": {
             "owner_name": "user",
             "project_unique_name": "user.project",
             "project_name": "project",
             "project_uuid": "uuid",
             "run_info": "user.project.runs.uuid",
             "context_path": "/plx-context",
             "artifacts_path": "/plx-context/artifacts",
             "name": "run",
             "uuid": "uuid",
             "namespace": "test",
             "iteration": None,
         },
         "init": {},
         "connections": {},
     }