Skip to content

Commit

Permalink
Added test for raw_container
Browse files Browse the repository at this point in the history
Signed-off-by: Yuvraj <[email protected]>
  • Loading branch information
yindia committed Jun 11, 2021
1 parent 648e7de commit e5c8fe5
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 9 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ jobs:
- name: Generate Serialize proto
run: |
make -C cookbook/core serialize
- name: Register core example workflow
run : make -C cookbook/core register
- name: run pytest #TODO
run: echo "Hello"
run: make -C coonbook/core test
integrations-build:
name: Build Integrations example
runs-on: ubuntu-latest
Expand All @@ -44,10 +42,8 @@ jobs:
- name: Generate Serialize proto
run: |
make -C cookbook/integrations serialize
- name: Register integrations example workflow
run : make -C cookbook/integrations register
- name: run pytest #TODO
run: echo "Hello"
run: make -C coonbook/core test
case_studies-build:
name: Build Case studies example
runs-on: ubuntu-latest
Expand All @@ -65,7 +61,5 @@ jobs:
- name: Generate Serialize proto
run: |
make -C cookbook/case_studies serialize
- name: Register case_studies example workflow
run : make -C cookbook/case_studies register
- name: run pytest #TODO
run: echo "Hello"
run: make -C coonbook/core test
7 changes: 7 additions & 0 deletions cookbook/common/leaf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ register: clean _pb_output docker_push
-v ${CURDIR}/_pb_output:/tmp/output \
${TAGGED_IMAGE} make register

.PHONY: test
test:
@echo ${VERSION}
@echo ${CURDIR}
cd test
coverage run -m pytest tests --proto-path=${CURDIR}/_pb_output/* -vv -s --trace-config

_pb_output:
mkdir -p _pb_output

Expand Down
8 changes: 8 additions & 0 deletions cookbook/common/parent.mk
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ serialize: ## Builds and serializes all docker images, workflows and tasks in al
$(MAKE) -C $$dir serialize; \
done

.PHONY: test
test:
@for dir in $(SUBDIRS) ; do \
echo "processing ${PWD}/$$dir"; \
test -f $$dir/Makefile && \
$(MAKE) -C $$dir test; \
done

.PHONY: docker_push
docker_push: ## Builds and pushes all docker images.
@for dir in $(SUBDIRS) ; do \
Expand Down
44 changes: 44 additions & 0 deletions cookbook/core/tests/core_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import pathlib
import subprocess

import pytest
from flytekit.common import launch_plan
from flytekit.models import literals
from flytekit.models.core.identifier import Identifier, ResourceType

PROJECT = "flytesnacks"
DOMAIN = "development"
VERSION = os.getpid()


@pytest.fixture(scope="session")
def flyte_workflows_source_dir():
return pathlib.Path("../" / os.path.dirname(__file__)) / "containerization"


@pytest.fixture(scope="session")
def flyte_workflows_register(request):
proto_path = request.config.getoption("--proto-path")
subprocess.check_call(
f"flytectl register files {proto_path} -p {PROJECT} -d {DOMAIN} -v v{VERSION}",
shell=True,
)

def test_stub(flyteclient, flyte_workflows_register):
projects = flyteclient.list_projects_paginated(limit=5, token=None)
assert len(projects) <= 5


def test_launch_workflow(flyteclient, flyte_workflows_register):
lp = launch_plan.SdkLaunchPlan.fetch(
"flytesnacks",
"development",
"workflows.raw_container.raw_container_wf",
f"v{VERSION}",
)
execution = lp.launch_with_literals(
"flytesnacks", "development", literals.LiteralMap({})
)
print(execution.id.name)

0 comments on commit e5c8fe5

Please sign in to comment.