Skip to content

Commit

Permalink
Add baseline tests for Agent chart
Browse files Browse the repository at this point in the history
  • Loading branch information
levan-m committed Oct 18, 2023
1 parent 2268144 commit 968d2eb
Show file tree
Hide file tree
Showing 11 changed files with 2,696 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
- [ ] Documentation has been updated with helm-docs (run: `.github/helm-docs.sh`)
- [ ] `CHANGELOG.md` has been updated
- [ ] Variables are documented in the `README.md`
- [ ] For Datadog Operator chart or value changes update the test baselines (run: `make update-test-baselines`)
- [ ] For `datadog-operator` or `datadog` chart or value changes update the test baselines (run: `make update-test-baselines`)
38 changes: 38 additions & 0 deletions .github/workflows/go-test-agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Go Test
on:
push:
paths:
- 'test/datadog/**'
- 'charts/datadog/**'
pull_request:
paths:
- 'test/datadog/**'
- 'charts/datadog/**'
env:
GO111MODULE: "on"
PROJECTNAME: "helm-charts"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.20
id: go
- name: Set up Helm
uses: azure/setup-helm@v3.5
with:
version: v3.10.1
- name: Add Datadog Helm repo
run: |
helm repo add Promotheus https://prometheus-community.github.io/helm-charts
helm repo add datadog https://helm.datadoghq.com
helm repo update
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: run Go tests
run: |
helm dependency build ./charts/datadog
make unit-test
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Go Test
on:
push:
paths:
- 'test/**'
- 'test/datadog-operator/**'
- 'charts/datadog-operator/**'
pull_request:
paths:
- 'test/**'
- 'test/datadog-operator/**'
- 'charts/datadog-operator/**'
env:
GO111MODULE: "on"
Expand Down
8 changes: 7 additions & 1 deletion test/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func RenderChart(t *testing.T, cmd HelmCommand) (string, error) {
ValuesFiles: cmd.Values,
}

output, err := helm.RenderTemplateE(t, options, chartPath, cmd.ReleaseName, cmd.ShowOnly)
output, err := helm.RenderTemplateE(t, options, chartPath, cmd.ReleaseName, cmd.ShowOnly, "--debug")

return output, err
}
Expand Down Expand Up @@ -80,6 +80,12 @@ func CreateSecretFromEnv(t *testing.T, kubectlOptions *k8s.KubectlOptions, apiKe
}
}

func ReadFile(t *testing.T, filepath string) string {
fileContent, err := os.ReadFile(filepath)
require.NoError(t, err, "can't load manifest from file", "path", filepath)
return string(fileContent)
}

func LoadFromFile[T any](t *testing.T, filepath string, destObj *T) string {
fileContent, err := os.ReadFile(filepath)
require.NoError(t, err, "can't load manifest from file", "path", filepath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
namespace: datadog-agent
labels:
app.kubernetes.io/name: datadog-operator
helm.sh/chart: datadog-operator-1.2.0
helm.sh/chart: datadog-operator-1.2.1
app.kubernetes.io/instance: datadog-operator
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/managed-by: Helm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
namespace: datadog-agent
labels:
app.kubernetes.io/name: datadog-operator
helm.sh/chart: datadog-operator-1.2.0
helm.sh/chart: datadog-operator-1.2.1
app.kubernetes.io/instance: datadog-operator
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/managed-by: Helm
Expand Down
180 changes: 180 additions & 0 deletions test/datadog/baseline/agent-clusterchecks-deployment_default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
---
# Source: datadog/templates/agent-clusterchecks-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: datadog-clusterchecks
namespace: datadog-agent
labels:
helm.sh/chart: 'datadog-3.40.0'
app.kubernetes.io/name: "datadog"
app.kubernetes.io/instance: "datadog"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: "7"
app.kubernetes.io/component: clusterchecks-agent

spec:
replicas: 2
revisionHistoryLimit: 10
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
selector:
matchLabels:
app: datadog-clusterchecks
template:
metadata:
labels:
app.kubernetes.io/name: "datadog"
app.kubernetes.io/instance: "datadog"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: clusterchecks-agent
app: datadog-clusterchecks

name: datadog-clusterchecks
annotations:
checksum/clusteragent_token: bf153e7c2829cb9288258a823fbe4ee03a9674774143653ba1e00d3236bab247
checksum/install_info: 4c6adc06986cb86f043bbf55310f5478d1ec9f0815ffeec050977d9f4546a28a
spec:
serviceAccountName: datadog-cluster-checks
automountServiceAccountToken: true
imagePullSecrets:
[]
initContainers:
- name: init-volume
image: "gcr.io/datadoghq/agent:7.48.0"
imagePullPolicy: IfNotPresent
command: ["bash", "-c"]
args:
- cp -r /etc/datadog-agent /opt
volumeMounts:
- name: config
mountPath: /opt/datadog-agent
readOnly: false # Need RW for writing agent config files
resources:
{}
- name: init-config
image: "gcr.io/datadoghq/agent:7.48.0"
imagePullPolicy: IfNotPresent
command: ["bash", "-c"]
args:
- for script in $(find /etc/cont-init.d/ -type f -name '*.sh' | sort) ; do bash $script ; done
volumeMounts:
- name: config
mountPath: /etc/datadog-agent
readOnly: false # Need RW for writing datadog.yaml config file
resources:
{}
containers:
- name: agent
image: "gcr.io/datadoghq/agent:7.48.0"
command: ["bash", "-c"]
args:
- rm -rf /etc/datadog-agent/conf.d && touch /etc/datadog-agent/datadog.yaml && exec agent run
imagePullPolicy: IfNotPresent
env:
- name: DD_API_KEY
valueFrom:
secretKeyRef:
name: "datadog-secret"
key: api-key
- name: KUBERNETES
value: "yes"
- name: DD_LOG_LEVEL
value: "INFO"
- name: DD_EXTRA_CONFIG_PROVIDERS
value: "clusterchecks"
- name: DD_HEALTH_PORT
value: "5557"
# Cluster checks (cluster-agent communication)
- name: DD_CLUSTER_AGENT_ENABLED
value: "true"
- name: DD_CLUSTER_AGENT_KUBERNETES_SERVICE_NAME
value: datadog-cluster-agent
- name: DD_CLUSTER_AGENT_AUTH_TOKEN
valueFrom:
secretKeyRef:
name: datadog-cluster-agent
key: token
# Safely run alongside the daemonset
- name: DD_ENABLE_METADATA_COLLECTION
value: "false"
# Expose CLC stats
- name: DD_CLC_RUNNER_ENABLED
value: "true"
- name: DD_CLC_RUNNER_HOST
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: DD_CLC_RUNNER_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
# Remove unused features
- name: DD_USE_DOGSTATSD
value: "false"
- name: DD_PROCESS_AGENT_ENABLED
value: "false"
- name: DD_LOGS_ENABLED
value: "false"
- name: DD_APM_ENABLED
value: "false"
- name: DD_REMOTE_CONFIGURATION_ENABLED
value: "false"
- name: DD_HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName


resources:
{}
volumeMounts:
- name: installinfo
subPath: install_info
mountPath: /etc/datadog-agent/install_info
readOnly: true
- name: config
mountPath: /etc/datadog-agent
readOnly: false # Need RW for config path
livenessProbe:
failureThreshold: 6
httpGet:
path: /live
port: 5557
scheme: HTTP
initialDelaySeconds: 15
periodSeconds: 15
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
failureThreshold: 6
httpGet:
path: /ready
port: 5557
scheme: HTTP
initialDelaySeconds: 15
periodSeconds: 15
successThreshold: 1
timeoutSeconds: 5
volumes:
- name: installinfo
configMap:
name: datadog-installinfo
- name: config
emptyDir: {}
affinity:
# Prefer scheduling the runners on different nodes if possible
# for better checks stability in case of node failure.
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 50
podAffinityTerm:
labelSelector:
matchLabels:
app: datadog-clusterchecks
topologyKey: kubernetes.io/hostname
nodeSelector:
kubernetes.io/os: linux
Loading

0 comments on commit 968d2eb

Please sign in to comment.