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

Merged

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. This is fixed
  • 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
Base automatically changed from gabriel.plassard/WF-9346/improve-private-actions-helm to main September 24, 2024 08:34
@dd-gplassard dd-gplassard force-pushed the gabriel.plassard/WF-9346/improve-private-actions-helm-tests branch from f8e892a to 6acec8d Compare September 24, 2024 08:34
@dd-gplassard dd-gplassard marked this pull request as ready for review September 24, 2024 09:14
@dd-gplassard dd-gplassard requested a review from a team as a code owner September 24, 2024 09:14
@dd-gplassard dd-gplassard force-pushed the gabriel.plassard/WF-9346/improve-private-actions-helm-tests branch from 1c113e3 to a6d171c Compare September 26, 2024 08:18
@dd-gplassard dd-gplassard requested a review from a team September 26, 2024 08:37
@dd-gplassard dd-gplassard merged commit 655672b into main Sep 26, 2024
4 checks passed
@dd-gplassard dd-gplassard deleted the gabriel.plassard/WF-9346/improve-private-actions-helm-tests branch September 26, 2024 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants