Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: started to add e2e tests #24

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
{
"name": "Rust",
"name": "caapf-dev",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {},
"ghcr.io/devcontainers-contrib/features/kind:1": {},
"ghcr.io/rio/features/k9s:1": {},
"ghcr.io/guiyomh/features/just:0": {},
"ghcr.io/lentzi90/features/clusterctl:0": {}
}
"ghcr.io/lentzi90/features/clusterctl:0": {},
"ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/devcontainers/features/node:1": {}
},
// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
// "mounts": [
// {
Expand All @@ -20,14 +23,34 @@
// "type": "volume"
// }
// ]
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",
"postCreateCommand": "bash ./.devcontainer/post-install.sh",
// Configure tool-specific properties.
// "customizations": {},
// "customizations": {
// "vscode": {
// // Set *default* container specific settings.json values on container create.
// "settings": {
// "python.defaultInterpreterPath": "/usr/local/bin/python"
// }
// }
// }
"customizations": {
"vscode": {
"settings": {
"editor.formatOnSave": true,
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python.defaultInterpreterPath": ".venv/bin/python",
"python.terminal.activateEnvInCurrentTerminal": true
},
"extensions": [
"ms-python.python",
"ms-python.pylint"
]
}
}
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
10 changes: 10 additions & 0 deletions .devcontainer/post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

just
pip install poetry
poetry config virtualenvs.create false
python -m venv .venv --prompt feria
chown -R vscode:vscode .venv
source .venv/bin/activate
pwd
cd tests; poetry install --no-interaction --no-root --no-cache
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ _out/
.vscode/
.idea/
child.kubeconfig
.venv/
26 changes: 17 additions & 9 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ KUSTOMIZE_VERSION := "v5.4.1"
KUSTOMIZE_BIN := "_out/kustomize"
ARCH := if arch() == "aarch64" { "arm64"} else { "amd64" }
DIST := os()
CARGO_HOME := env_var('CARGO_HOME')

[private]
default:
Expand All @@ -21,10 +22,10 @@ generate:

# generates files for CRDS
generate-crds: _create-out-dir _install-kopium _download-yq
just _generate-kopium-url {{home_directory()}}/.cargo/bin/kopium "https://raw.githubusercontent.com/kubernetes-sigs/cluster-api/main/config/crd/bases/cluster.x-k8s.io_clusters.yaml" "src/api/capi_cluster.rs" ""
just _generate-kopium-url {{home_directory()}}/.cargo/bin/kopium "https://raw.githubusercontent.com/kubernetes-sigs/cluster-api/main/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml" "src/api/capi_clusterclass.rs" ""
just _generate-kopium-url {{home_directory()}}/.cargo/bin/kopium "https://raw.githubusercontent.com/rancher/fleet/main/charts/fleet-crd/templates/crds.yaml" "src/api/fleet_cluster.rs" "select(.spec.names.singular==\"cluster\")" "--no-condition"
just _generate-kopium-url {{home_directory()}}/.cargo/bin/kopium "https://raw.githubusercontent.com/rancher/fleet/main/charts/fleet-crd/templates/crds.yaml" "src/api/fleet_clustergroup.rs" "select(.spec.names.singular==\"clustergroup\")" "--no-condition"
just _generate-kopium-url {{CARGO_HOME}}/bin/kopium "https://raw.githubusercontent.com/kubernetes-sigs/cluster-api/main/config/crd/bases/cluster.x-k8s.io_clusters.yaml" "src/api/capi_cluster.rs" ""
just _generate-kopium-url {{CARGO_HOME}}/bin/kopium "https://raw.githubusercontent.com/kubernetes-sigs/cluster-api/main/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml" "src/api/capi_clusterclass.rs" ""
just _generate-kopium-url {{CARGO_HOME}}/bin/kopium "https://raw.githubusercontent.com/rancher/fleet/main/charts/fleet-crd/templates/crds.yaml" "src/api/fleet_cluster.rs" "select(.spec.names.singular==\"cluster\")" "--no-condition"
just _generate-kopium-url {{CARGO_HOME}}/bin/kopium "https://raw.githubusercontent.com/rancher/fleet/main/charts/fleet-crd/templates/crds.yaml" "src/api/fleet_clustergroup.rs" "select(.spec.names.singular==\"clustergroup\")" "--no-condition"

[private]
_generate-kopium-url kpath="" source="" dest="" yqexp="." condition="":
Expand All @@ -43,11 +44,15 @@ run:

# format with nightly rustfmt
fmt:
cargo +nightly fmt
cargo +nightly fmt --all

# run unit tests
test-unit:
cargo test
# Run e2e tests
test-e2e:
cd tests; poetry run pytest e2e/

# Run tests for styling
test-style:
cd tests; poetry run pytest --fmt-config={{justfile_directory()}}/rustfmt.toml style/

# compile for musl (for docker image)
compile features="": _create-out-dir
Expand Down Expand Up @@ -97,7 +102,10 @@ deploy-crs:

# Deploy child cluster using docker & kubead,
deploy-child-cluster:
kubectl --context kind-dev apply -f testdata/cluster_docker_kcp.yaml
kubectl --context kind-dev apply -f testdata/cluster_quickstart.yaml

deploy-class:
kubectl --context kind-dev apply -f testdata/class_quickstart.yaml

# Add and update helm repos used
update-helm-repos:
Expand Down
8 changes: 8 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
group_imports = "StdExternalCrate"
comment_width = 100
imports_granularity = "Module"
wrap_comments = true
format_code_in_doc_comments = true
format_strings = true
normalize_comments = true
normalize_doc_attributes = true
Loading
Loading