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

Tests for private action runner helm chart #1532

Draft
wants to merge 6 commits into
base: gabriel.plassard/WF-9346/improve-private-actions-helm
Choose a base branch
from

Conversation

dd-gplassard
Copy link
Contributor

@dd-gplassard dd-gplassard commented Sep 23, 2024

What this PR does / why we need it:

I initially wanted to do it in #1529 but I found out that my implementation

  • was only making assertions on the service-account, all other resources were not checked. I believe this is due to the fact that common.Unmarshal(t, manifest, &actual) and common.LoadFromFile(t, baselineManifestPath, &baseline) actually only read the first entry from the yaml and ignores the following ones (not 100% sure about this but it matches my observation)

    func verifyPrivateActionRunner(t *testing.T, baselineManifestPath, manifest string) {
    verifyBaseline(t, baselineManifestPath, manifest, appsv1.Deployment{}, appsv1.Deployment{})
    verifyBaseline(t, baselineManifestPath, manifest, rbacv1.ClusterRole{}, rbacv1.ClusterRole{})
    verifyBaseline(t, baselineManifestPath, manifest, rbacv1.RoleBinding{}, rbacv1.RoleBinding{})
    verifyBaseline(t, baselineManifestPath, manifest, corev1.Secret{}, corev1.Secret{})
    verifyBaseline(t, baselineManifestPath, manifest, corev1.Service{}, corev1.Service{})
    verifyBaseline(t, baselineManifestPath, manifest, corev1.ServiceAccount{}, corev1.ServiceAccount{})
    }
    func verifyBaseline[T any](t *testing.T, baselineManifestPath, manifest string, baseline, actual T) {
    common.Unmarshal(t, manifest, &actual)
    common.LoadFromFile(t, baselineManifestPath, &baseline)
    assert.True(t, cmp.Equal(baseline, actual, cmp.Options{}), cmp.Diff(baseline, actual))
    }

    ---
    # Source: private-action-runner/templates/serviceaccount.yaml
    apiVersion: v1
    kind: ServiceAccount
    metadata:
    name: "private-action-runner-default-serviceaccount"
    namespace: datadog-agent
    ---
    # Source: private-action-runner/templates/secrets.yaml
    apiVersion: v1
    kind: Secret
    metadata:
    name: "private-action-runner-default-secrets"
    namespace: datadog-agent
    stringData:
    config.yaml: |
    ddBaseURL: https://app.datadoghq.com
    urn: CHANGE_ME_URN_FROM_CONFIG
    privateKey: CHANGE_ME_PRIVATE_KEY_FROM_CONFIG
    modes:
    - workflowAutomation
    - appBuilder
    port: 9016
    actionsAllowlist:
    - com.datadoghq.kubernetes.core.getPod
    - com.datadoghq.kubernetes.core.listPod
    ---

  • the tests were not running on the pull request because the only github workflow running unit test is restricted to test/datadog-operator/** and charts/datadog-operator/** paths

Special notes for your reviewer:

I'm not 100% sure of the best path forward about this.

  • I went for using helm.DiffAgainstSnapshot which made bump a few dependencies.
  • It also seems like tests from other packages are also not working so not sure what we should do about them.
  • I more or less copy pasted the github workflow definition for datadog-operator, maybe there is a better solution ?

@dd-gplassard dd-gplassard changed the title Gabriel.plassard/wf 9346/improve private actions helm tests Tests for private action runner helm chart Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant