-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Public copy <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
88927e6
commit ee9f39d
Showing
16 changed files
with
385 additions
and
127 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}, | ||
] | ||
} |
Oops, something went wrong.