Testing¶
This document describes how to run tests for Otterdog. You should setup your development environment as described in the Development Setup guide before running tests.
Development Resources¶
[Optional] Creating an Organization for development¶
On your profile, create one orgnaization
- Organization name:
otterdog-<github username>(Ex: otterdog-foobar) - Contact email: your@email
- This organization belongs to: My personal account
Accept the Terms of Service (if you agree)
Configure your otterdog (source code) to work with your development organization¶
https://otterdog.readthedocs.io/en/latest/setup/#otterdog-configuration
{
"defaults": {
"jsonnet": {
"base_template": "https://github.com/<Github Username>/otterdog#examples/template/otterdog-defaults.libsonnet@main",
"config_dir": "orgs"
}
},
"organizations": [
{
"name": "otterdog-<Github Username>",
"github_id": "otterdog-<Github Username>",
"credentials": {
"provider": "bitwarden",
"item_id" : "<item ide>"
}
}
]
}
[Optional] Setup common Otterdog configuration repository¶
This will store and maintain the otterdog.json in the repository.
Go to your organization https://github.com/otterdog-<github username> > Repositories > New repository
- Repository name *: .otterdog
Click on Create repository
Edit your current and include:
[Optional] Otterdog WebApp development environment¶
To run the otterdog webapp (without integration with GitHub)
Make sure you have the eclipse-csi helm chart repository
If you want use the integration with GitHub, you can use the tailscale
Setup a tailscale to enable GitHub Webhooks to your development environment¶
-
Sign up/Login to tail tailscale
-
Go to tailscale admin console https://login.tailscale.com/admin/machines
We use tailscale on Kubernetes (minikube), configuring it:
-
Go to tailscale admin console -> ACL (https://login.tailscale.com/admin/acls/file)
Include or update the
tagOwnersAdd
tag:k8sto thenodeAttrs: -
Create an OAuth in Settings > OAuth clients (https://login.tailscale.com/admin/settings/oauth)
Create an OAuth client in the OAuth clients page of the admin console. Create the client with Devices Core and Auth Keys write scopes, and the tag
tag:k8s-operator.This is well described in the official doc
Your new OAuth client's Client ID and Client Secret will be displayed—copy these values now as you'll need them in the next step.
-
Save your tailscale DNS (https://login.tailscale.com/admin/dns)
It might look like
tail<some hash>.ts.net -
Export them on you terminal
export TS_CLIENT_ID=<client id> export TS_CLIENT_SECRET=<client secret> export TS_DNS=tail<some hash>.ts.netNOTE: If you close terminal, you will need re-export
Create a GitHub App¶
NOTES:
- Replace
<OTTERDOG-WEBAPP>by yourtail<some hash>.ts.net - You can always double check the URL at https://login.tailscale.com/admin/machines as multiple instances
of your development environment can generate
otterdog-1,otterdog-2...
It is required if you are the integration with GitHub (Create a GitHub app)
- Go to your organization
https://github.com/organizations/<ORG> - Click Settings.
- In the left sidebar, select <> Developer settings
- Click GitHub Apps
- New GitHub App
Basic Information
- Add GitHub App name:
<choose a name> - Homepage URL:
<OTTERDOG-WEBAPP>
Webhook
- [X] Active
- Webhook url:
<OTTERDOG-WEBAPP> - Secret: Choose the secret
Add the following permissions and events:
Repository Permissions
| Permission | Access Level |
|---|---|
| Actions | Read & Write |
| Administration | Read & Write |
| Commit statuses | Read & Write |
| Contents | Read & Write |
| Environments | Read & Write |
| Issues | Read only |
| Metadata | Read only |
| Pages | Read & Write |
| Pull requests | Read & Write |
| Secrets | Read & Write |
| Variables | Read & Write |
| Webhooks | Read & Write |
| Workflows | Read & Write |
Organization Permissions
| Permission | Access Level |
|---|---|
| Administration | Read & Write |
| Custom Organization Roles | Read & Write |
| Members | Read only |
| Plan | Read only |
| Secrets | Read & Write |
| Variables | Read & Write |
| Webhooks | Read & Write |
Events
| Event |
|---|
| Issue comment |
| Pull request |
| Pull request review |
| Push |
| Workflow job |
| Workflow run |
Configure the values.yaml to setup your otterdog webapp¶
config:
configOwner: "otterdog-<github username>" # GitHub organization hosting the otterdog.json
configToken: "" # A base64 valid GitHub token, no need for any permissions, just for rate limit purposes
dependencyTrackToken: "" # A base64 depednecy track generated
github:
webhookSecret: "" # The Base64 webhook secret as configured for the GitHub App
appId: "" # The APP id created in GitHub
appPrivateKey: "" # The base64 App Private Key
NOTE:
In the dev configuration the otterdog webapp uses the following repositories:
You can overwrite it on values.yaml
It is recommeded to create the repository otterdog-configs and add the otterdog.json
Example of otterdog.json
{
"defaults": {
"jsonnet": {
"base_template": "https://github.com/<GitHub Username>/otterdog#examples/template/otterdog-defaults.libsonnet@main",
"config_dir": "orgs"
}
},
"github": {
"config_repo": ".otterdog"
},
"organizations": [
{
"name": "otterdog-<GitHub Username>",
"github_id": "otterdog-<GitHub Username>"
}
]
}
Run otterdog with tailscale¶
Make sure you have the eclipse-csi, tailscale and dependency-track helm chart repositories added
helm repo add dependency-track https://dependencytrack.github.io/helm-charts
helm repo add eclipse-csi https://eclipse-csi.github.io/helm-charts
helm repo add tailscale https://pkgs.tailscale.com/helmcharts
Initiate otterdog webapp with tailscale
You can see at https://login.tailscale.com/admin/machines the otterdog machine.
Otterdog WebApp is reacheable at https://otterdog.tail
Init the otterdog and watch the logs
Dependency Track is reacheable at https://sbom.tail[Optional] Configure dependency track¶
-
Access the https://sbom.tail
.ts.net (default DependencyTrack credentials) (First time will ask to change password and re-login) -
To generate the
dependencyTrackTokengo toAdministration>Access Management>Teams -
Create a Team or choose one (i.e.
Automation) create and API Key. -
Use this API Key in
depdencyTrackTokenonvalues.yaml
It will reloadd automatically.