Skip to content

Commit

Permalink
automated commit
Browse files Browse the repository at this point in the history
Signed-off-by: Public copy <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Oct 15, 2024
1 parent 88927e6 commit ee9f39d
Show file tree
Hide file tree
Showing 16 changed files with 385 additions and 127 deletions.
16 changes: 8 additions & 8 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
126 changes: 126 additions & 0 deletions images/datadog-agent/tests/agent-jmx/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
imagetest = { source = "chainguard-dev/imagetest" }
}
}

variable "digest" {
description = "The image digest to run tests over."
}

locals { parsed = provider::oci::parse(var.digest) }

variable "namespace" {
default = "datadog-agent-system"
}

data "imagetest_inventory" "this" {}

resource "imagetest_harness_k3s" "this" {
name = "datadog-agent-jmx"
inventory = data.imagetest_inventory.this

sandbox = {
mounts = [
{
source = path.module
destination = "/tests"
}
]
envs = {
"DATADOG_JMX_IMAGE" = "${local.parsed.registry_repo}:${local.parsed.pseudo_tag}"
}
}
}

module "helm-datadog-operator-thing" {
source = "../../../../tflib/imagetest/helm"

namespace = var.namespace
repo = "https://helm.datadoghq.com"
chart = "datadog-operator"

values = {
watchNamespaces : [""]
datadog = {
apiKey = "dummy"
dd_url = "http://fakeintake.${var.namespace}.svc.cluster.local"
clusterName = "chainguard"
}
}
}

resource "imagetest_feature" "basic-helm-operator" {
name = "Basic"
description = "Basic datadog-agent-operator Helm install test"
harness = imagetest_harness_k3s.this

steps = [
{
name = "Setup fakeintake"
cmd = "kubectl apply --wait -f /tests/fakeintake.yaml"
},
{
name = "Helm install"
cmd = module.helm-datadog-operator-thing.install_cmd
},
{
name = "Check datadog-agent-operator pods"
cmd = "kubectl wait --for=condition=Ready pods --all --namespace ${var.namespace}"
retry = { attempts = 5, delay = "10s" }
},
{
name = "Check datadog-agent pods"
cmd = <<EOFagent
cat <<EOF > /tmp/datadog-agent.yaml
apiVersion: "datadoghq.com/v2alpha1"
kind: "DatadogAgent"
metadata:
name: "datadog"
spec:
global:
site: "http://fakeintake.${var.namespace}.svc.cluster.local"
clusterName: "chainguard"
credentials:
apiKey: "dummy"
override:
nodeAgent:
env:
- name: DD_HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
image:
name: $DATADOG_JMX_IMAGE
jmxEnabled: true
EOF
kubectl apply -f /tmp/datadog-agent.yaml
kubectl get datadogagents
# wait until the agent is ready
kubectl wait --for=condition=Ready datadogagent/datadog --timeout=5m
# let's deploy a JMX application
kubectl apply -f /tests/tomcat.yaml
# wait until tomcat is ready
kubectl wait pod --for=condition=Ready tomcat-test --timeout 5m
# wait until jmx metrics are available
sleep 120
# get the name of the pod which has label agent.datadoghq.com/component=agent
AGENT_POD=$(kubectl get pods -l agent.datadoghq.com/component=agent -o jsonpath='{.items[0].metadata.name}')
echo "Agent pod: $AGENT_POD"
# check if the JMX metrics are available
kubectl exec $AGENT_POD -c agent -- agent status "jmx fetch" | grep "status: OK"
EOFagent
}
]

labels = {
type = "k8s",
}
}
40 changes: 40 additions & 0 deletions images/datadog-agent/tests/agent-jmx/tomcat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: v1
kind: Pod
metadata:
name: tomcat-test
annotations:
ad.datadoghq.com/tomcat.checks: |
{
"tomcat": {
"init_config": {
"is_jmx": true,
"collect_default_metrics": true
},
"instances": [{
"host": "%%host%%",
"port": "9012"
}]
}
}
spec:
containers:
- name: tomcat
image: tomcat:8.0
imagePullPolicy: Always
ports:
- name: jmx-metrics
containerPort: 9012
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: JAVA_OPTS
value: >-
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.port=9012
-Dcom.sun.management.jmxremote.rmi.port=9012
-Djava.rmi.server.hostname=$(POD_IP)
39 changes: 39 additions & 0 deletions images/datadog-agent/tests/agent/fakeintake.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: v1
kind: Namespace
metadata:
name: datadog-agent-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fakeintake
namespace: datadog-agent-system
spec:
replicas: 1
selector:
matchLabels:
app: fakeintake
template:
metadata:
labels:
app: fakeintake
spec:
containers:
- name: fakeintake
image: datadog/fakeintake
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: fakeintake
namespace: datadog-agent-system
spec:
type: ClusterIP
selector:
app: fakeintake
ports:
- protocol: TCP
port: 80
targetPort: 80
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ resource "imagetest_harness_k3s" "this" {
}

module "helm" {
source = "../../../tflib/imagetest/helm"
source = "../../../../tflib/imagetest/helm"

namespace = var.namespace
repo = "https://helm.datadoghq.com"
Expand Down Expand Up @@ -95,7 +95,7 @@ module "helm" {
}
}

resource "imagetest_feature" "basic" {
resource "imagetest_feature" "basic-helm" {
name = "Basic"
description = "Basic datadog-agent Helm install test"
harness = imagetest_harness_k3s.this
Expand Down
1 change: 1 addition & 0 deletions images/docker-selenium/config/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ output "config" {
contents = {
packages = concat([
"docker-selenium-supervisor-config",
"docker-selenium-standalone-chrome",
], var.extra_packages)
}
accounts = module.accts.block
Expand Down
36 changes: 31 additions & 5 deletions images/docker-selenium/tests/main.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
imagetest = { source = "chainguard-dev/imagetest" }
oci = { source = "chainguard-dev/oci" }
}
}

variable "digest" {
description = "The image digest to run tests over."
}

locals { parsed = provider::oci::parse(var.digest) }
data "imagetest_inventory" "inventory" {}

data "oci_exec_test" "smoke" {
digest = var.digest
script = "${path.module}/smoke.sh"
// Run a simple Docker test to verify the image is working.
resource "imagetest_harness_docker" "docker" {
name = "docker"
inventory = data.imagetest_inventory.inventory

envs = {
IMAGE_NAME : var.digest
}
mounts = [
{
source = path.module
destination = "/tests"
}
]
}

resource "imagetest_feature" "test" {
name = "docker-test"
harness = imagetest_harness_docker.docker

steps = [{
name = "basic test"
workdir = "/tests"
cmd = <<EOF
./smoke.sh
EOF
},
]
}
Loading

0 comments on commit ee9f39d

Please sign in to comment.