From 2ebe533a626bb395eabce624d687960407b01f9e Mon Sep 17 00:00:00 2001 From: ChristianZaccaria Date: Thu, 11 Jan 2024 17:31:55 +0000 Subject: [PATCH] WIP - Convert e2e test to Python test + unpriviliged user test case --- .../PKG-INFO | 0 .../SOURCES.txt | 0 .../dependency_links.txt | 0 .../top_level.txt | 0 .../__init__.py | 0 .../cluster/__init__.py | 0 .../cluster/auth.py | 0 .../cluster/awload.py | 0 .../cluster/cluster.py | 0 .../cluster/config.py | 0 .../cluster/model.py | 0 .../job/__init__.py | 0 .../job/jobs.py | 0 .../job/ray_jobs.py | 0 .../templates/base-template.yaml | 0 .../utils/__init__.py | 0 .../utils/generate_cert.py | 0 .../utils/generate_yaml.py | 0 .../utils/kube_api_helpers.py | 0 .../utils/openshift_oauth.py | 0 .../utils/pretty_print.py | 0 poetry.lock | 2 +- tests/e2e/config | 17 ++ tests/e2e/install-codeflare-sdk.sh | 10 +- tests/e2e/kind.sh | 133 ++++++++++ tests/e2e/mnist_raycluster_sdk.py | 11 +- tests/e2e/mnist_raycluster_sdk_test.go | 249 +++++------------- 27 files changed, 224 insertions(+), 198 deletions(-) rename {src/codeflare_sdk.egg-info => codeflare_sdk.egg-info}/PKG-INFO (100%) rename {src/codeflare_sdk.egg-info => codeflare_sdk.egg-info}/SOURCES.txt (100%) rename {src/codeflare_sdk.egg-info => codeflare_sdk.egg-info}/dependency_links.txt (100%) rename {src/codeflare_sdk.egg-info => codeflare_sdk.egg-info}/top_level.txt (100%) rename {src/codeflare_sdk => codeflare_sdk}/__init__.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/cluster/__init__.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/cluster/auth.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/cluster/awload.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/cluster/cluster.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/cluster/config.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/cluster/model.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/job/__init__.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/job/jobs.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/job/ray_jobs.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/templates/base-template.yaml (100%) rename {src/codeflare_sdk => codeflare_sdk}/utils/__init__.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/utils/generate_cert.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/utils/generate_yaml.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/utils/kube_api_helpers.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/utils/openshift_oauth.py (100%) rename {src/codeflare_sdk => codeflare_sdk}/utils/pretty_print.py (100%) create mode 100644 tests/e2e/config mode change 100644 => 100755 tests/e2e/install-codeflare-sdk.sh create mode 100755 tests/e2e/kind.sh diff --git a/src/codeflare_sdk.egg-info/PKG-INFO b/codeflare_sdk.egg-info/PKG-INFO similarity index 100% rename from src/codeflare_sdk.egg-info/PKG-INFO rename to codeflare_sdk.egg-info/PKG-INFO diff --git a/src/codeflare_sdk.egg-info/SOURCES.txt b/codeflare_sdk.egg-info/SOURCES.txt similarity index 100% rename from src/codeflare_sdk.egg-info/SOURCES.txt rename to codeflare_sdk.egg-info/SOURCES.txt diff --git a/src/codeflare_sdk.egg-info/dependency_links.txt b/codeflare_sdk.egg-info/dependency_links.txt similarity index 100% rename from src/codeflare_sdk.egg-info/dependency_links.txt rename to codeflare_sdk.egg-info/dependency_links.txt diff --git a/src/codeflare_sdk.egg-info/top_level.txt b/codeflare_sdk.egg-info/top_level.txt similarity index 100% rename from src/codeflare_sdk.egg-info/top_level.txt rename to codeflare_sdk.egg-info/top_level.txt diff --git a/src/codeflare_sdk/__init__.py b/codeflare_sdk/__init__.py similarity index 100% rename from src/codeflare_sdk/__init__.py rename to codeflare_sdk/__init__.py diff --git a/src/codeflare_sdk/cluster/__init__.py b/codeflare_sdk/cluster/__init__.py similarity index 100% rename from src/codeflare_sdk/cluster/__init__.py rename to codeflare_sdk/cluster/__init__.py diff --git a/src/codeflare_sdk/cluster/auth.py b/codeflare_sdk/cluster/auth.py similarity index 100% rename from src/codeflare_sdk/cluster/auth.py rename to codeflare_sdk/cluster/auth.py diff --git a/src/codeflare_sdk/cluster/awload.py b/codeflare_sdk/cluster/awload.py similarity index 100% rename from src/codeflare_sdk/cluster/awload.py rename to codeflare_sdk/cluster/awload.py diff --git a/src/codeflare_sdk/cluster/cluster.py b/codeflare_sdk/cluster/cluster.py similarity index 100% rename from src/codeflare_sdk/cluster/cluster.py rename to codeflare_sdk/cluster/cluster.py diff --git a/src/codeflare_sdk/cluster/config.py b/codeflare_sdk/cluster/config.py similarity index 100% rename from src/codeflare_sdk/cluster/config.py rename to codeflare_sdk/cluster/config.py diff --git a/src/codeflare_sdk/cluster/model.py b/codeflare_sdk/cluster/model.py similarity index 100% rename from src/codeflare_sdk/cluster/model.py rename to codeflare_sdk/cluster/model.py diff --git a/src/codeflare_sdk/job/__init__.py b/codeflare_sdk/job/__init__.py similarity index 100% rename from src/codeflare_sdk/job/__init__.py rename to codeflare_sdk/job/__init__.py diff --git a/src/codeflare_sdk/job/jobs.py b/codeflare_sdk/job/jobs.py similarity index 100% rename from src/codeflare_sdk/job/jobs.py rename to codeflare_sdk/job/jobs.py diff --git a/src/codeflare_sdk/job/ray_jobs.py b/codeflare_sdk/job/ray_jobs.py similarity index 100% rename from src/codeflare_sdk/job/ray_jobs.py rename to codeflare_sdk/job/ray_jobs.py diff --git a/src/codeflare_sdk/templates/base-template.yaml b/codeflare_sdk/templates/base-template.yaml similarity index 100% rename from src/codeflare_sdk/templates/base-template.yaml rename to codeflare_sdk/templates/base-template.yaml diff --git a/src/codeflare_sdk/utils/__init__.py b/codeflare_sdk/utils/__init__.py similarity index 100% rename from src/codeflare_sdk/utils/__init__.py rename to codeflare_sdk/utils/__init__.py diff --git a/src/codeflare_sdk/utils/generate_cert.py b/codeflare_sdk/utils/generate_cert.py similarity index 100% rename from src/codeflare_sdk/utils/generate_cert.py rename to codeflare_sdk/utils/generate_cert.py diff --git a/src/codeflare_sdk/utils/generate_yaml.py b/codeflare_sdk/utils/generate_yaml.py similarity index 100% rename from src/codeflare_sdk/utils/generate_yaml.py rename to codeflare_sdk/utils/generate_yaml.py diff --git a/src/codeflare_sdk/utils/kube_api_helpers.py b/codeflare_sdk/utils/kube_api_helpers.py similarity index 100% rename from src/codeflare_sdk/utils/kube_api_helpers.py rename to codeflare_sdk/utils/kube_api_helpers.py diff --git a/src/codeflare_sdk/utils/openshift_oauth.py b/codeflare_sdk/utils/openshift_oauth.py similarity index 100% rename from src/codeflare_sdk/utils/openshift_oauth.py rename to codeflare_sdk/utils/openshift_oauth.py diff --git a/src/codeflare_sdk/utils/pretty_print.py b/codeflare_sdk/utils/pretty_print.py similarity index 100% rename from src/codeflare_sdk/utils/pretty_print.py rename to codeflare_sdk/utils/pretty_print.py diff --git a/poetry.lock b/poetry.lock index a0ed4770e..89e44a236 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "aiohttp" diff --git a/tests/e2e/config b/tests/e2e/config new file mode 100644 index 000000000..a226de89f --- /dev/null +++ b/tests/e2e/config @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Config +clusters: +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJek1USXhNakV3TWpneE4xb1hEVE16TVRJd09URXdNamd4TjFvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTGFPCi9vY1dITX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yRkRWNnhyanlJdFVSWithcFJFREEwL29maTB5andzRjBtV01oMVJSY0tCQ1ZJUzMKWHBJPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== + server: https://127.0.0.1:34211 + name: kind-kind +contexts: +- context: + cluster: kind-kind + user: sdk-user + name: sdk-user +users: +- name: sdk-user + user: + client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN3VENDQWFrQ0ZCT0FEQ1l4OUxDczZDNVdPZzFQRWRuQlc5YkpNQTBHQ1NxR1NJYjNEUUVCQ3dVQU1CVXgKRXpBUkJnTlZCQU1UQ210MVltVnlibVYwWlhNd0hoY05Nak14TWpFeU1UQXlPRFEwV2hjTk1qUXhNakEyTVRBeQpPRFEwV2pBbE1SRXdEd1lEVlFRRERBaHpaR3N0ZFhObGNqRVFNQTRHQTFVRUNnd0hkR1Z1WVc1ME1UQ0NBU0l3CkRRWUpLb1pJaHZjTkFRRUJCUUFEZ2dFUEFEQ0NBUW9DZ2dFQkFPMkw0UnJuMlB2TEQweGZSL2g3MDBhNnB3aG0KSmtrTGttWHFYY3ZISmdiS1VkZG5QcU5rTzVsN2w4STR6MjMydWZiYllCbFZHL1ljbTd3OGNlK2RFbmpoTHAxeQozRWU0RUdsQ1JETHU5U080SUZUSTUwRHk4WUxhUTU5TitteXQ5UDBENW14RmEremREYUQ1Q2E2NTFtd3B1R2g3CkNDbnZhaFNnYmt5MytlQ0FiOU1FdGFwZi82bjlvT045dHNVZTNOQlo1aUZ2cTV4bER6Q0k2dWlUKzJTVytCWWIKM3dXbkhsTkoxTVZuVHVSbUVJc3pPUXltREZkQVcyVDJjNkl2dnJKZndCNzVOd1Q5c2poUGY4SHV0M0tIUGErVQpQazVYRVErdVlYcjFiMlVQZUdrT3VtdkZnN1JQRHZMK1JFL0t0QXpDOGNaYVNycE5sWUk2TVZMVVV5OENBd0VBCkFUQU5CZ2txaGtpRzl3MEJBUXNGQUFPQ0FRRUFNeGJWdGx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CkVVSUwwcVl3Zm4zZ29GbEc0YTNnKzRWbERpTG40UStibHdvT2psRHBnQUJWdFFkcWF3anZxeEVSc1RCTExZWWQKNGwxanJVNzhpeEs5UUUyb0VGL1B0cVBodk5YZTJIdXkvNzBibU5HdExCOHV3eCtPVlBVSklwSE5Bb0dCQUpHSgpaRFhubmFTYitZbDg0V1FkZ0FmeEd5Vkg3TTZKWll5L2VVZ3BSOUg0NXgrWjQ3SzdGU1JieFlnQ0FzOFArL3Q3CnlZTG45NUY4VjlaQnhxVjI5bW45NWZEdThIWEZTZ0Q1UEU4QjFhaFFTUUdYcDZvNGdZeWc1OHRHRC93WVZ3ZlYKdk5jMElwRkdlZEpOY091aWphSnFwWGxsUVptUnVINnVwQjRGMGt5dEFvR0JBTzh5ZVVOVmhQNWhjandQVmNFawpYV0FSS3ErNnhBM3d3R0ZLV25CY1JSd2xOcFNjMUkrWWo0dFZaLzN5R3VxVndCL2JqWm1UemlQOG5HK3FGL3NoCm1zTzFsN0JZVlcrMDFpQ1k5c0M1S3FBR0lyTG5yUkd6LzdSZUhvWDdIVFVTM29PQW9YSmtkSWZPRkJVNVdDVGkKMzg3dHFTTDBjQkN6bHlEU2dGZUJFZWVyCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K diff --git a/tests/e2e/install-codeflare-sdk.sh b/tests/e2e/install-codeflare-sdk.sh old mode 100644 new mode 100755 index e78085824..8defbe43a --- a/tests/e2e/install-codeflare-sdk.sh +++ b/tests/e2e/install-codeflare-sdk.sh @@ -1,17 +1,9 @@ -#!/bin/bash - -cd .. +# !/bin/bash # Install Poetry and configure virtualenvs pip install poetry poetry config virtualenvs.create false -cd codeflare-sdk - # Lock dependencies and install them poetry lock --no-update poetry install --with test,docs - -# Return to the workdir -cd .. -cd workdir diff --git a/tests/e2e/kind.sh b/tests/e2e/kind.sh new file mode 100755 index 000000000..d15678e4f --- /dev/null +++ b/tests/e2e/kind.sh @@ -0,0 +1,133 @@ +#!/bin/bash + +# Copyright 2022 IBM, Red Hat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -euo pipefail +: "${INGRESS_NGINX_VERSION:=controller-v1.6.4}" + +echo "Creating KinD cluster" +cat < ca.crt.base64 +base64 -w 0 < sdk-user.crt > sdk-user.crt.base64 +base64 -w 0 < sdk-user.key > sdk-user.key.base64 +SERVER_ADDRESS=$(kubectl cluster-info | grep -o "https://127.0.0.1:[0-9]*" | head -n 1) + +# Replace the placeholders in the user config file with the actual values +sed -i 's|certificate-authority-data:.*|certificate-authority-data: '$(cat ca.crt.base64)'|g' ./tests/e2e/config +sed -i 's|client-certificate-data:.*|client-certificate-data: '$(cat sdk-user.crt.base64)'|g' ./tests/e2e/config +sed -i 's|client-key-data:.*|client-key-data: '$(cat sdk-user.key.base64)'|g' ./tests/e2e/config +sed -i 's|server:.*|server: '$(echo $SERVER_ADDRESS)'|g' ./tests/e2e/config + +# Apply to the user limited RBAC permissions +cat <