Skip to content

Commit

Permalink
Merge pull request #759 from diegolovison/doc5
Browse files Browse the repository at this point in the history
How to debug using GoLand
  • Loading branch information
HumairAK authored Dec 3, 2024
2 parents c86983a + 6a5a1f7 commit d80a181
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
42 changes: 36 additions & 6 deletions .github/scripts/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ To prevent file monitoring issues in development environments (e.g., IDEs or fil
sudo sysctl fs.inotify.max_user_instances=2280
sudo sysctl fs.inotify.max_user_watches=1255360
```
## Prerequisites
* Kind https://kind.sigs.k8s.io/

## Create kind cluster
```bash
cat <<EOF | kind create cluster --name=kubeflow --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.31.0@sha256:53df588e04085fd41ae12de0c3fe4c72f7013bba32a20e7325357a1ac94ba865
image: kindest/node:v1.30.6@sha256:b6d08db72079ba5ae1f4a88a09025c0a904af3b52387643c285442afb05ab994
kubeadmConfigPatches:
- |
kind: ClusterConfiguration
Expand All @@ -32,20 +35,20 @@ Instead of replacing your kubeconfig, we are going to set to a diff file
kind get kubeconfig --name kubeflow > /tmp/kubeflow-config
export KUBECONFIG=/tmp/kubeflow-config
```
# docker
## docker
In order to by pass the docker limit issue while downloading the images. Let's use your credentials
```bash
docker login
docker login -u='...' -p='...' quay.io
```

Upload the secret. The following command will return an error. You need to replace `to` with user `username`
```bash
kubectl create secret generic regcred \
--from-file=.dockerconfigjson=/home/to/.docker/config.json \
--from-file=.dockerconfigjson=$HOME/.docker/config.json \
--type=kubernetes.io/dockerconfigjson
```

# Test environment variables
## Test environment variables
Replace the `/path/to` in order to match the `data-science-pipelines-operator` folder
```bash
export GIT_WORKSPACE=/path/to/data-science-pipelines-operator
Expand All @@ -58,7 +61,34 @@ Replace `username` with your quay user
export REGISTRY_ADDRESS=quay.io/username
```

# Run the test
## Run the test
```bash
sh .github/scripts/tests/tests.sh --kind
```

# Debug a test using GoLand
Let's say you wish to debug the `Should create a Pipeline Run` test.
The first step is right click inside the method content and select the menu
`Run 'TestIntegrationTestSuite'`. It will fail because you need to fill some parameters.
Edit the configuration for `TestIntegrationTestSuite/TestPipelineSuccessfulRun/Should_create_a_Pipeline_Run in github.com/opendatahub-io/data-science-pipelines-operator/tests`
````
-k8sApiServerHost=https://127.0.0.1:39873
-kubeconfig=/tmp/kubeflow-config
-DSPANamespace=test-dspa
-DSPAPath=/path/to/data-science-pipelines-operator/tests/resources/dspa-lite.yaml
````
## How to retrieve the parameters above
* `k8sApiServerHost`: inspect the kubeconfig and retrieve the server URL from there
* `kubeconfig`: the path where you stored the output of `kind get kubeconfig`
* `DSPANamespace`: namespace
* `DSPAPath`: full path for the dspa.yaml

`Should create a Pipeline Run`, `DSPANamespace` and `DSPAPath` depends on the test scenario.

If you wish to keep the resources, add `-skipCleanup=True` in the config above.

## If you wish to rerun the test you need to delete the dspa
```bash
$ kubectl delete datasciencepipelinesapplications test-dspa -n test-dspa
datasciencepipelinesapplication.datasciencepipelinesapplications.opendatahub.io "test-dspa" deleted
```
18 changes: 1 addition & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,23 +504,7 @@ oc delete project ${ODH_NS}

## Run tests

Simply clone the directory and execute `make test`.

To run it without `make` you can run the following:

```bash
tmpFolder=$(mktemp -d)
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
export KUBEBUILDER_ASSETS=$(${GOPATH}/bin/setup-envtest use 1.25.0 --bin-dir ${tmpFolder}/bin -p path)
go test ./... -coverprofile cover.out
# once $KUBEBUILDER_ASSETS you can also run the full test suite successfully by running:
pre-commit run --all-files
```

You can find a more permanent location to install `setup-envtest` into on your local filesystem and export
`KUBEBUILDER_ASSETS` into your `.bashrc` or equivalent. By doing this you can always run `pre-commit run --all-files`
without having to repeat these steps.
See `.github/scripts/tests/README.md`(https://github.com/opendatahub-io/data-science-pipelines-operator/blob/main/.github/scripts/tests/README.md)

## Metrics

Expand Down

0 comments on commit d80a181

Please sign in to comment.