Skip to content

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:

    "github": {
      "config_repo": ".otterdog"
    },

[Optional] Otterdog WebApp development environment

To run the otterdog webapp (without integration with GitHub)

Make sure you have the eclipse-csi helm chart repository

helm repo add eclipse-csi https://eclipse-csi.github.io/helm-charts
make dev-webapp

If you want use the integration with GitHub, you can use the tailscale

Setup a tailscale to enable GitHub Webhooks to your development environment

  1. Sign up/Login to tail tailscale

  2. Go to tailscale admin console https://login.tailscale.com/admin/machines

We use tailscale on Kubernetes (minikube), configuring it:

  1. Go to tailscale admin console -> ACL (https://login.tailscale.com/admin/acls/file)

    Include or update the tagOwners

        "tagOwners": {
            "tag:k8s-operator": [],
            "tag:k8s":          ["tag:k8s-operator"],
        },
    

    Add tag:k8s to the nodeAttrs:

    "nodeAttrs": [
        {
    
            "target": ["autogroup:member", "tag:k8s"],
            "attr":   ["funnel"],
        },
        {
            "target": ["tag:k8s"], // tag that Tailscale Operator uses to tag proxies; defaults to 'tag:k8s'
            "attr":   ["funnel"],
        },
    ],
    
  2. 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.

  3. Save your tailscale DNS (https://login.tailscale.com/admin/dns)

    It might look like tail<some hash>.ts.net

  4. Export them on you terminal

    export TS_CLIENT_ID=<client id>
    export TS_CLIENT_SECRET=<client secret>
    export TS_DNS=tail<some hash>.ts.net
    

    NOTE: If you close terminal, you will need re-export

Create a GitHub App

NOTES:

  • Replace <OTTERDOG-WEBAPP> by your tail<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)

  1. Go to your organization https://github.com/organizations/<ORG>
  2. Click Settings.
  3. In the left sidebar, select <> Developer settings
  4. Click GitHub Apps
  5. 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:

config:
  configRepo: "otterdog-configs"
  configPath: "otterdog.json"

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

make dev-webapp-tunnel

You can see at https://login.tailscale.com/admin/machines the otterdog machine.

Otterdog WebApp is reacheable at https://otterdog.tail.ts.net

Init the otterdog and watch the logs

curl  https://otterdog.tail<hash>.ts.net/internal/init
Dependency Track is reacheable at https://sbom.tail.ts.net (it still need to be re-configured, see it below)

[Optional] Configure dependency track

  1. Access the https://sbom.tail.ts.net (default DependencyTrack credentials) (First time will ask to change password and re-login)

  2. To generate the dependencyTrackToken go to Administration > Access Management> Teams

  3. Create a Team or choose one (i.e. Automation) create and API Key.

  4. Use this API Key in depdencyTrackToken on values.yaml

It will reloadd automatically.