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

test: add e2e test for odigos cli upgrade from latest to HEAD #1446

Merged
merged 6 commits into from
Aug 16, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- "multi-apps"
- "helm-chart"
- "fe-synthetic"
- "cli-upgrade"
include:
- kube-version: "1.23"
kind-image: "kindest/node:v1.23.17@sha256:14d0a9a892b943866d7e6be119a06871291c517d279aedb816a4b4bc0ec0a5b3"
Expand Down
90 changes: 49 additions & 41 deletions cli/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,52 +42,58 @@ and apply any required migrations and adaptations.`,
os.Exit(1)
}

cm, err := client.CoreV1().ConfigMaps(ns).Get(ctx, resources.OdigosDeploymentConfigMapName, metav1.GetOptions{})
if err != nil {
fmt.Println("Odigos upgrade failed - unable to read the current Odigos version for migration")
os.Exit(1)
}
var operation string

currOdigosVersion := cm.Data["ODIGOS_VERSION"]
if currOdigosVersion == "" {
fmt.Println("Odigos upgrade failed - unable to read the current Odigos version for migration")
os.Exit(1)
}
if !cmd.Flag("skip-version-check").Changed {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the change here is adding this new flag since the current upgrade behavior requires a valid formatted version v1.2.3 while the tests use the tag e2e-test. this flag allows the test to bypass the checks


sourceVersion, err := version.NewVersion(currOdigosVersion)
if err != nil {
fmt.Println("Odigos upgrade failed - unable to parse the current Odigos version for migration")
os.Exit(1)
}
if sourceVersion.LessThan(version.Must(version.NewVersion("1.0.0"))) {
fmt.Printf("Unable to upgrade from Odigos version older than 'v1.0.0' current version is %s.\n", currOdigosVersion)
fmt.Printf("To upgrade, please use 'odigos uninstall' and 'odigos install'.\n")
os.Exit(1)
}
targetVersion, err := version.NewVersion(versionFlag)
if err != nil {
fmt.Println("Odigos upgrade failed - unable to parse the target Odigos version for migration")
os.Exit(1)
}
cm, err := client.CoreV1().ConfigMaps(ns).Get(ctx, resources.OdigosDeploymentConfigMapName, metav1.GetOptions{})
if err != nil {
fmt.Println("Odigos upgrade failed - unable to read the current Odigos version for migration")
os.Exit(1)
}

var operation string
if sourceVersion.Equal(targetVersion) {
fmt.Printf("Odigos version is already '%s', synching installation\n", versionFlag)
operation = "Synching"
} else if sourceVersion.GreaterThan(targetVersion) {
fmt.Printf("About to DOWNGRADE Odigos version from '%s' (current) to '%s' (target)\n", currOdigosVersion, versionFlag)
operation = "Downgrading"
} else {
fmt.Printf("About to upgrade Odigos version from '%s' (current) to '%s' (target)\n", currOdigosVersion, versionFlag)
operation = "Upgrading"
}
currOdigosVersion := cm.Data["ODIGOS_VERSION"]
if currOdigosVersion == "" {
fmt.Println("Odigos upgrade failed - unable to read the current Odigos version for migration")
os.Exit(1)
}

if !cmd.Flag("yes").Changed {
confirmed, err := confirm.Ask("Are you sure?")
if err != nil || !confirmed {
fmt.Println("Aborting upgrade")
return
sourceVersion, err := version.NewVersion(currOdigosVersion)
if err != nil {
fmt.Println("Odigos upgrade failed - unable to parse the current Odigos version for migration")
os.Exit(1)
}
if sourceVersion.LessThan(version.Must(version.NewVersion("1.0.0"))) {
fmt.Printf("Unable to upgrade from Odigos version older than 'v1.0.0' current version is %s.\n", currOdigosVersion)
fmt.Printf("To upgrade, please use 'odigos uninstall' and 'odigos install'.\n")
os.Exit(1)
}
targetVersion, err := version.NewVersion(versionFlag)
if err != nil {
fmt.Println("Odigos upgrade failed - unable to parse the target Odigos version for migration")
os.Exit(1)
}

if sourceVersion.Equal(targetVersion) {
fmt.Printf("Odigos version is already '%s', synching installation\n", versionFlag)
operation = "Synching"
} else if sourceVersion.GreaterThan(targetVersion) {
fmt.Printf("About to DOWNGRADE Odigos version from '%s' (current) to '%s' (target)\n", currOdigosVersion, versionFlag)
operation = "Downgrading"
} else {
fmt.Printf("About to upgrade Odigos version from '%s' (current) to '%s' (target)\n", currOdigosVersion, versionFlag)
operation = "Upgrading"
}

if !cmd.Flag("yes").Changed {
confirmed, err := confirm.Ask("Are you sure?")
if err != nil || !confirmed {
fmt.Println("Aborting upgrade")
return
}
}
} else {
operation = "Focefully upgrading"
}

config, err := resources.GetCurrentConfig(ctx, client, ns)
Expand Down Expand Up @@ -133,5 +139,7 @@ func init() {
versionFlag = OdigosVersion
} else {
upgradeCmd.Flags().StringVar(&versionFlag, "version", OdigosVersion, "for development purposes only")
upgradeCmd.Flags().Bool("skip-version-check", false, "skip the version check and install any version tag provided. used for tests")
updateCmd.Flags().MarkHidden("skip-version-check")
}
}
29 changes: 28 additions & 1 deletion tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,31 @@ expected:
Once you have the file, you can run the test via:
```bash
tests/e2e/common/traceql_runner.sh <path-to-yaml-file>
```
```

## Debugging

When tests fail, and it's related to some traceql query not succeeding, it can be useful to setup a grafana ui to commit queries and see the traces that are stored in tempo.

- Install grafana with helm:

```bash
helm install -n traces grafana grafana/grafana --set adminPassword='odigos'
```

- Port forward to the grafana service:

```bash
kubectl port-forward svc/grafana 3080:80 -n traces
```

- Browse to `http://localhost:3080` and login with `admin` and `odigos`.

- Add tempo as a datasource, by going to `Connections -> Data Sources -> Add data source` and selecting `Tempo` as the type. Set the URL to `http://e2e-tests-tempo:3100` and save.

- In grafana left side menu, go to `Explore` and select the tempo datasource. You can now write queries, run them, and see the traces that are stored in tempo to troubleshoot your test issues. example query:

```
{resource.service.name = "coupon"}
```

3 changes: 3 additions & 0 deletions tests/e2e/cli-upgrade/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# the odigos cli executable downloaded from github for the test to run
odigos
odigos-latest.tar.gz
203 changes: 203 additions & 0 deletions tests/e2e/cli-upgrade/02-install-simple-demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: coupon
namespace: default
labels:
app: coupon
spec:
selector:
matchLabels:
app: coupon
template:
metadata:
labels:
app: coupon
spec:
containers:
- name: coupon
image: keyval/odigos-demo-coupon:v0.1
imagePullPolicy: IfNotPresent
env:
- name: MEMBERSHIP_SERVICE_HOST
value: "membership:8080"
ports:
- containerPort: 8080
---
kind: Service
apiVersion: v1
metadata:
name: coupon
namespace: default
spec:
selector:
app: coupon
ports:
- protocol: TCP
port: 8080
targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
namespace: default
labels:
app: frontend
spec:
selector:
matchLabels:
app: frontend
template:
metadata:
labels:
app: frontend
spec:
containers:
- name: frontend
image: keyval/odigos-demo-frontend:v0.2
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: 1000
env:
- name: INVENTORY_SERVICE_HOST
value: inventory:8080
- name: PRICING_SERVICE_HOST
value: pricing:8080
- name: COUPON_SERVICE_HOST
value: coupon:8080
ports:
- containerPort: 8080
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
---
kind: Service
apiVersion: v1
metadata:
name: frontend
namespace: default
spec:
selector:
app: frontend
ports:
- protocol: TCP
port: 8080
targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: inventory
namespace: default
labels:
app: inventory
spec:
selector:
matchLabels:
app: inventory
template:
metadata:
labels:
app: inventory
spec:
containers:
- name: inventory
image: keyval/odigos-demo-inventory:v0.1
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
---
kind: Service
apiVersion: v1
metadata:
name: inventory
namespace: default
spec:
selector:
app: inventory
ports:
- protocol: TCP
port: 8080
targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: membership
namespace: default
labels:
app: membership
spec:
selector:
matchLabels:
app: membership
template:
metadata:
labels:
app: membership
spec:
containers:
- name: membership
image: keyval/odigos-demo-membership:v0.1
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
---
kind: Service
apiVersion: v1
metadata:
name: membership
namespace: default
spec:
selector:
app: membership
ports:
- protocol: TCP
port: 8080
targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: pricing
namespace: default
labels:
app: pricing
spec:
selector:
matchLabels:
app: pricing
template:
metadata:
labels:
app: pricing
spec:
containers:
- name: pricing
image: keyval/odigos-demo-pricing:v0.1
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
---
kind: Service
apiVersion: v1
metadata:
name: pricing
namespace: default
spec:
selector:
app: pricing
ports:
- protocol: TCP
port: 8080
targetPort: 8080
6 changes: 6 additions & 0 deletions tests/e2e/cli-upgrade/03-instrument-ns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: default
labels:
odigos-instrumentation: enabled
12 changes: 12 additions & 0 deletions tests/e2e/cli-upgrade/04-add-destination.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: odigos.io/v1alpha1
kind: Destination
metadata:
name: odigos.io.dest.tempo-123123
namespace: odigos-test-cli-upgrade
spec:
data:
TEMPO_URL: e2e-tests-tempo.traces:4317
destinationName: e2e-tests
signals:
- TRACES
type: tempo
Loading
Loading