Skip to content

Commit ee00079

Browse files
committed
IDE launch template. e2e flags from environment.
1 parent 961e54d commit ee00079

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
# Attatching IDE Debuggers to project.
3+
4+
## VSCode
5+
Create `.vscode/launch.json` file with following content
6+
7+
```json
8+
{
9+
// Use IntelliSense to learn about possible attributes.
10+
// Hover to view descriptions of existing attributes.
11+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
12+
"version": "0.2.0",
13+
"configurations": [
14+
{
15+
"name": "Debug E2E Test",
16+
"type": "go",
17+
"request": "launch",
18+
"mode": "test",
19+
"program": "${workspaceRoot}/tests/e2e/e2e_suite_test.go",
20+
"env": {
21+
// "KUBECONFIG": "/path/to/.kube/config",
22+
"KUBERNETES_MASTER": "http://localhost:8080",
23+
// modifying values from test-e2e flags
24+
"E2E_USE_ENV_FLAGS": "true",
25+
"VELERO_NAMESPACE": "openshift-adp",
26+
"SETTINGS": "${workspaceRoot}/.vscode/default_settings.json",
27+
"CLOUD_CREDENTIALS": "",
28+
"VELERO_INSTANCE_NAME": "",
29+
"CLUSTER_PROFILE": "",
30+
"CREDS_SECRET_REF": "",
31+
"PROVIDER": "",
32+
"AZURE_RESOURCE_FILE": "",
33+
"CI_CRED_FILE": "",
34+
"ARTIFACT_DIR": "",
35+
"OC_CLI": "",
36+
}
37+
},
38+
{
39+
"name": "Launch main.go",
40+
"type": "go",
41+
"request": "launch",
42+
"mode": "debug",
43+
"program": "${workspaceRoot}/main.go",
44+
"env": {
45+
"WATCH_NAMESPACE": "openshift-adp",
46+
// "KUBECONFIG": "",
47+
"KUBERNETES_MASTER": "http://localhost:8080"
48+
}
49+
},
50+
]
51+
}
52+
53+
```
54+
55+
copy `default_settings.json` file from `test/e2e/templates/` directory to `.vscode/` directory and modify it as per your needs.
56+
57+
You can now use Run and Debug menu to launch
58+
- Debug E2E Test
59+
- This runs the test suite in debug mode. You can add breakpoints to step through the end to end test.
60+
- Prerequisites:
61+
- You have installed OADP Operator. To install current commit run `make deploy-olm`
62+
- Launch main.go
63+
- This runs the operator on your machine in debug mode. You can add breakpoints and step through the code.

tests/e2e/e2e_suite_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"flag"
66
"fmt"
77
"log"
8+
"os"
89
"strconv"
910
"testing"
1011
"time"
@@ -33,6 +34,45 @@ func init() {
3334
flag.StringVar(&artifact_dir, "artifact_dir", "/tmp", "Directory for storing must gather")
3435
flag.StringVar(&oc_cli, "oc_cli", "oc", "OC CLI Client")
3536

37+
// helps with launching debug sessions from IDE
38+
if os.Getenv("E2E_USE_ENV_FLAGS") == "true" {
39+
if os.Getenv("CLOUD_CREDENTIALS") != "" {
40+
credFile = os.Getenv("CLOUD_CREDENTIALS")
41+
}
42+
if os.Getenv("VELERO_NAMESPACE") != "" {
43+
namespace = os.Getenv("VELERO_NAMESPACE")
44+
}
45+
if os.Getenv("VELERO_INSTANCE_NAME") != "" {
46+
instanceName = os.Getenv("VELERO_INSTANCE_NAME")
47+
}
48+
if os.Getenv("CLUSTER_PROFILE") != "" {
49+
bsl_profile = os.Getenv("CLUSTER_PROFILE")
50+
}
51+
if os.Getenv("CREDS_SECRET_REF") != "" {
52+
credSecretRef = os.Getenv("CREDS_SECRET_REF")
53+
}
54+
if os.Getenv("PROVIDER") != "" {
55+
provider = os.Getenv("PROVIDER")
56+
}
57+
if os.Getenv("AZURE_RESOURCE_FILE") != "" {
58+
azure_resource_file = os.Getenv("AZURE_RESOURCE_FILE")
59+
}
60+
if os.Getenv("CI_CRED_FILE") != "" {
61+
ci_cred_file = os.Getenv("CI_CRED_FILE")
62+
} else {
63+
ci_cred_file = credFile
64+
}
65+
if os.Getenv("SETTINGS") != "" {
66+
settings = os.Getenv("SETTINGS")
67+
}
68+
if os.Getenv("ARTIFACT_DIR") != "" {
69+
artifact_dir = os.Getenv("ARTIFACT_DIR")
70+
}
71+
if os.Getenv("OC_CLI") != "" {
72+
oc_cli = os.Getenv("OC_CLI")
73+
}
74+
}
75+
3676
timeoutMultiplierInput := flag.Int64("timeout_multiplier", 1, "Customize timeout multiplier from default (1)")
3777
timeoutMultiplier = 1
3878
if timeoutMultiplierInput != nil && *timeoutMultiplierInput >= 1 {

0 commit comments

Comments
 (0)