Skip to content
Merged
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
64 changes: 64 additions & 0 deletions docs/developer/testing/AttatchingIDEDebuggers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

# Attatching IDE Debuggers to project.

## VSCode
Create `.vscode/launch.json` file with following content

```json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug E2E Test",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceRoot}/tests/e2e/e2e_suite_test.go",
"env": {
// "KUBECONFIG": "/path/to/.kube/config",
"KUBERNETES_MASTER": "http://localhost:8080",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localhost:8080 4reelz?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the default. Not defining it is also fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your kubeconfig takes care of what cluster it talks to.

// modifying values from test-e2e flags
"E2E_USE_ENV_FLAGS": "true",
"VELERO_NAMESPACE": "openshift-adp",
"SETTINGS": "${workspaceRoot}/.vscode/default_settings.json",
"CLOUD_CREDENTIALS": "",
"VELERO_INSTANCE_NAME": "",
"CREDS_SECRET_REF": "",
"PROVIDER": "",
"CI_CRED_FILE": "",
"ARTIFACT_DIR": "",
"OC_CLI": "",
}
},
{
"name": "Launch main.go",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceRoot}/main.go",
"env": {
"WATCH_NAMESPACE": "openshift-adp",
// "KUBECONFIG": "",
"KUBERNETES_MASTER": "http://localhost:8080"
}
},
]
}

```

copy `default_settings.json` file from `test/e2e/templates/` directory to `.vscode/` directory and modify it as per your needs.

You can now use Run and Debug menu to launch
- Debug E2E Test
- This runs the test suite in debug mode. You can add breakpoints to step through the end to end test.
- Prerequisites:
- You have installed OADP Operator. To install current commit run `make deploy-olm`
- Launch main.go
- This runs the operator on your machine in debug mode. You can add breakpoints and step through the code.
- You will not see OADP in Installed Operators but it will be watching for DPA resources in the namespace as if it was installed.
- Prerequisites:
- Run `make install apply-velerosa-role` to install CRDs and create service accounts, a task normally handled by OLM but not in this case.
34 changes: 34 additions & 0 deletions tests/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"flag"
"log"
"os"
"testing"
"time"

Expand All @@ -28,6 +29,39 @@ func init() {
flag.StringVar(&artifact_dir, "artifact_dir", "/tmp", "Directory for storing must gather")
flag.StringVar(&oc_cli, "oc_cli", "oc", "OC CLI Client")

// helps with launching debug sessions from IDE
if os.Getenv("E2E_USE_ENV_FLAGS") == "true" {
if os.Getenv("CLOUD_CREDENTIALS") != "" {
credFile = os.Getenv("CLOUD_CREDENTIALS")
}
if os.Getenv("VELERO_NAMESPACE") != "" {
namespace = os.Getenv("VELERO_NAMESPACE")
}
if os.Getenv("SETTINGS") != "" {
settings = os.Getenv("SETTINGS")
}
if os.Getenv("VELERO_INSTANCE_NAME") != "" {
instanceName = os.Getenv("VELERO_INSTANCE_NAME")
}
if os.Getenv("CREDS_SECRET_REF") != "" {
credSecretRef = os.Getenv("CREDS_SECRET_REF")
}
if os.Getenv("PROVIDER") != "" {
provider = os.Getenv("PROVIDER")
}
if os.Getenv("CI_CRED_FILE") != "" {
ci_cred_file = os.Getenv("CI_CRED_FILE")
} else {
ci_cred_file = credFile
}
if os.Getenv("ARTIFACT_DIR") != "" {
artifact_dir = os.Getenv("ARTIFACT_DIR")
}
if os.Getenv("OC_CLI") != "" {
oc_cli = os.Getenv("OC_CLI")
}
}

timeoutMultiplierInput := flag.Int64("timeout_multiplier", 1, "Customize timeout multiplier from default (1)")
timeoutMultiplier = 1
if timeoutMultiplierInput != nil && *timeoutMultiplierInput >= 1 {
Expand Down