Merge pull request #685 from TomChv/move-tests-to-universe

Move tests to universe
This commit is contained in:
Andrea Luzzardi 2021-06-21 17:41:43 +02:00 committed by GitHub
commit 83019a5414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 400 additions and 251 deletions

28
stdlib/.dagger/env/aws-eks/values.yaml vendored Normal file
View File

@ -0,0 +1,28 @@
plan:
module: .dagger/env/aws-eks/plan
name: aws-eks
inputs:
TestConfig.awsConfig.accessKey:
secret: ENC[AES256_GCM,data:ZiNdgkTZlOyWht2CDpmYKN+ViTE=,iv:wdRiBw65BgSia9z//tUDirkkhw9O29ZoerX6eZnYx9k=,tag:S/0i/fRtQJg4Qp7tmUK4ag==,type:str]
TestConfig.awsConfig.secretKey:
secret: ENC[AES256_GCM,data:ywvQiDE4gmM6KasYWOvX1FY/Lerg5TghgoYTq1AlXDRHNGzZtY3ClQ==,iv:HCXweaSKHLwEA8Mq4up/TUaV7YDtsRpBpwYD19Jh4iw=,tag:l2hmI9BsGiRyulh4yDn/hw==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBVdWE4VlRMWGJ3WDExWkNl
S1dqU21uVXFjaXU5eWdKRmRCUXFCd2ZaTjNrCjlkNXI3WUdnRGVibmZkbXJYaEV4
SXIveGNDNnZ6dDM4SjdrMmZIZVhyVzAKLS0tIGkzK0tMTTdHU2lacmtvakUwbGFE
M3U4UFV5REQzYko3QjlXVE02Z0J4WUkK8uHC67Mutls4drXbCi8AwuFqbRXeb69P
ZnOFZEB4NoayoOojr1mY9ssDTywHF4KwR4E9ZmJ3V3hlEAgMkqfvSA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-17T18:46:34Z"
mac: ENC[AES256_GCM,data:B+WtEMOKXy8AT/YTUaKZ9aA8fQRt2pJp3IaABpj0oYI1vCG953MnDCIxj0j2bTQN5gyaFPF8UQ1o/pRJzCKhm26wbCByUrVdHxHTwoJ7arDqQGwcNKYAuQjLtMG7gsl0BqjCg0oKO5YEa24BqHVf1dEo9AcXd6LBwqvxVjmd98g=,iv:aWxj1Oq6wmUYuWnGOc2zIpzOYJVyXV9qSzBgF+iGsHI=,tag:Bx1A8UxghYq97wEdUxbmdg==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -0,0 +1,2 @@
# dagger state
state/**

View File

@ -6,15 +6,38 @@ import (
"dagger.io/docker"
)
source: dagger.#Artifact
TestSourceBuild: dagger.#Artifact @dagger(input)
TestImageFromDockerfile: {
image: docker.#ImageFromDockerfile & {
dockerfile: """
FROM alpine
COPY test.txt /test.txt
"""
context: source
TestBuild: {
image: docker.#Build & {
source: TestSourceBuild
}
verify: #up: [
op.#Load & {
from: image
},
op.#Exec & {
always: true
args: [
"sh", "-c", """
grep -q "test" /test.txt
""",
]
},
]
}
TestSourceImageFromDockerfile: dagger.#Artifact @dagger(input)
TestImageFromDockerfile: {
image: docker.#ImageFromDockerfile & {
dockerfile: """
FROM alpine
COPY test.txt /test.txt
"""
context: TestSourceImageFromDockerfile
}
verify: #up: [

View File

@ -0,0 +1,30 @@
plan:
module: .dagger/env/docker-build/plan
name: docker-build
inputs:
TestSourceBuild:
dir:
path: ./docker/testdata/build
TestSourceImageFromDockerfile:
dir:
path: ./docker/testdata/dockerfile
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA0TXlFYWNvUldMdlRtWkEz
SlBEYUY1Q0thbFdSZGpaT00xQ2Jkc1J2WkdJClBXUGVTamdmZU1KNUdjam9HN0Zl
RjRQbVRHVjR6S3RCWlJLaElaM2ZWVG8KLS0tIDJJejFkQkxYeDdHcWdPS0p0QmJ0
Mm5vT1dHbFViK2ZIakNnVkZTd2lhUHMK63jJsJVLJMbQE2NkAB8qv8JnPHpvcNes
z17EJgl0lCLqeNHtfrTfSiIP4wq8gNLK4avCKK+WGDOIMsXPzK6RNw==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-17T20:14:11Z"
mac: ENC[AES256_GCM,data:hlc0Bnfeoor/WKMbQRgTalkxngL0YXTwHAys/moXZ4ZMGd2lt+j4l4EkKSjb3QrJfPllCeqroohLKtN+lP4K9fSCMcfYzic2DTEP68rPwufmrgxys1snOHHgIEfqogL8p55fJdXn91x+WHhPNkbWaaH0WcboYsy0zemUIkjb+xc=,iv:8oUeR1dfT4lrVWyJpGPPFa/jlPgWA/ld3UM9Cw2znxk=,tag:59RyiXwzJ5j+c5faxs9U3w==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -1,3 +1,5 @@
plan:
module: .dagger/env/git/plan
name: git
sops:
kms: []
@ -14,8 +16,8 @@ sops:
TmhJNisyamw3d244aGVJSEVFVUVLZGsKvd+nowA0CLXQbdvyI4J0lBjs9vdISWlo
gGvR49uul3Z8raVWXFUzsyQ8xTvYNg0ovynFG2KdagSKr1DlhKMBEQ==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-15T14:34:51Z"
mac: ENC[AES256_GCM,data:phQpRQlHv9c3VRcqZ7OkSfW4a9oPnTD2ucsB8TJatgzLrbP1+erj9x2jrPex0T2MExIFFzNynSAiWwueLYqCzUvuG2DfIokvM9erNfdpbIBTtJeWO9+hVIkzoQ6xeKg1wLb0q3U7Cbbe6GBFA3oabPN2kyzGbgS2LO2Ou77NMLk=,iv:sS0MRNEGBWos6XNAQEYK2UmaK9g0rd+Nx1xBNeh6w+M=,tag:DIcqzBvChde/C7T/yAhn+w==,type:str]
lastmodified: "2021-06-18T16:23:23Z"
mac: ENC[AES256_GCM,data:AdTUEx0RIrJU6aZZNn9iIrl0eM2eParknCVIQL7k1arLRfYH4WyMf9lUa03+Qy83r4miNh4a9kFpNWyodbOR/j7OiLgAxWGXc08XAnIU51F2H7b55cSW9yNJj5kfos2e1pS356MoSaswg4fH8EYVUNgWC6mdBcXzC1m7uiqTS0E=,iv:mK9sjOCd7ePWR4xe5qNwmPuIyNR1nE3Ql65cF15SovI=,tag:DPUTnGTF+Ve+A7ShACNrnQ==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -0,0 +1,2 @@
# dagger state
state/**

View File

@ -8,7 +8,7 @@ import (
// We assume that a kinD cluster is running locally
// To deploy a local KinD cluster, follow this link : https://kind.sigs.k8s.io/docs/user/quick-start/
kubeconfig: string @dagger(input)
TestKubeconfig: string @dagger(input)
TestKubeApply: {
suffix: random.#String & {
@ -31,7 +31,7 @@ TestKubeApply: {
// Apply deployment
apply: kubernetes.#Resources & {
"kubeconfig": kubeconfig
kubeconfig: TestKubeconfig
namespace: "dagger-test"
manifest: yaml.Marshal(kubeSrc)
}

View File

@ -29,7 +29,7 @@ import (
op.#WriteFile & {
dest: "/kubeconfig"
content: kubeconfig
content: TestKubeconfig
mode: 0o600
},

View File

@ -0,0 +1,23 @@
plan:
module: .dagger/env/kubernetes-deployment/plan
name: kubernetes-deployment
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBIQ2hZZ3ZRVzRseXZyVW1h
L01WYkNrTzdHSEN5WTlyQzVDTm9FbzRENzFFCjdrcVhKa1ZwaGNyYmo3ditDR1hC
cStzcmVjUXY3V3FUZElRNUIzQlQzL0UKLS0tIHlmWTlUdFVOczM0TTF5RHFTUXps
SVVkOUtuWTJneE45em5iQ3JvbnIwWlkKgdJC5IzvVDxbWSfU41Xg/UGPxuVBSOGY
eqenr07uWppNaHuLuo9A+znQa2RQ0L2clcB2d+ka+6z5tQyHOfx1nA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-18T15:41:02Z"
mac: ENC[AES256_GCM,data:R3DuHLEyfehKe1nCWHdKB9jyOs5TXI+r2BmQDMiwI8v0xfZdOZWfwGw3NAFGDZHbaLNTajQkzviDsMhaXg5bxvmK7P8PiJOOmnm/LnDRfnJirGRGpWA7bmsHH/QZL1lb75+cwUrwRZflkKoPy2bQyoC5Rze6/oNhPIUTCwQWaMo=,iv:73ZjXAcazCND3JhC94TjUOlcMbwfTz8YDFP1BPo8yUw=,tag:wUVcfyjtf4KzpU0jDrxleQ==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -0,0 +1,2 @@
# dagger state
state/**

View File

@ -1,14 +1,16 @@
package main
import (
"dagger.io/dagger"
"dagger.io/kubernetes/helm"
"dagger.io/random"
"dagger.io/dagger"
)
// We assume that a kinD cluster is running locally
// To deploy a local KinD cluster, follow this link : https://kind.sigs.k8s.io/docs/user/quick-start/
kubeconfig: string @dagger(input)
TestKubeconfig: string @dagger(input)
TestChartSource: dagger.#Artifact @dagger(input)
// Deploy user local chart
TestHelmSimpleChart: {
@ -18,10 +20,10 @@ TestHelmSimpleChart: {
// Deploy chart
deploy: helm.#Chart & {
name: "dagger-test-helm-simple-chart-\(suffix.out)"
name: "dagger-test-inline-chart-\(suffix.out)"
namespace: "dagger-test"
"kubeconfig": kubeconfig
chartSource: dagger.#Artifact
kubeconfig: TestKubeconfig
chartSource: TestChartSource
}
// Verify deployment
@ -37,11 +39,11 @@ TestHelmRepoChart: {
seed: "repo"
}
// Deploy chart
// Deploy remote chart
deploy: helm.#Chart & {
name: "dagger-test-helm-repository-\(suffix.out)"
name: "dagger-test-repository-\(suffix.out)"
namespace: "dagger-test"
"kubeconfig": kubeconfig
kubeconfig: TestKubeconfig
repository: "https://charts.bitnami.com/bitnami"
chart: "redis"
}

View File

@ -28,7 +28,7 @@ import (
op.#WriteFile & {
dest: "/kubeconfig"
content: kubeconfig
content: TestKubeconfig
mode: 0o600
},

View File

@ -0,0 +1,27 @@
plan:
module: .dagger/env/kubernetes-helm/plan
name: kubernetes-helm
inputs:
TestChartSource:
dir:
path: ./kubernetes/helm/testdata/mychart
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBud1hMc0dTZTlIQ3lZVEQ5
WjA2UlAvTm15ZEgycXlKKzhjTmU0Ui9xZHcwCkRxclFUTUE0aXRvaElkc3diV2Ix
N2VZZVIzS2t3cVl3UmtXOC9PY1VObzAKLS0tIG9ydkFzak1SaUo2NGxET3ZiNklZ
VHlGUExaMzcwM0pOM2VDY280UWZXSzQKAm7ZV1agxbla3Yrc7vrwJosSjQtWhdac
ZFyQ6Gi+9H7qHZM89yVjAaIg1lwr68HcjYgDzpvvhJO9YPfzwoLyHw==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-18T15:42:52Z"
mac: ENC[AES256_GCM,data:SzHFZpgiv+h1vRjq0GP+4nzj9az6pAwQwstxYz10yBGPQXnZv/VtJm071oouiK7pgD4i7cTvTKgIOaX9K74PiWSiTjWI5F9sGHvt9ZoGyU08OHM6zwGMDiYygBN2+5dd5jBvT4Xy6efa0IOMxSqhp69+VoJRWesAFsN6IfDcIEY=,iv:Af2WeB2eVk5hnWFWaQij7hz2wjXgNWDJTWDm13iKNvA=,tag:uvR1ruMc69ZhDJRtYCFQBw==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -0,0 +1,2 @@
# dagger state
state/**

View File

@ -0,0 +1,27 @@
plan:
module: .dagger/env/kubernetes-kustomize/plan
name: kubernetes-kustomize
inputs:
TestKustomize.testdata:
dir:
path: ./kubernetes/kustomize/testdata
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBTL2Jyczk3QXZiUVkyd3cw
TlYzQ2NyR2ZGZnhSRmowSGRmbFBodFRPc2dnCnJpYjdCdUpEUE10d3I4clh1eDVV
MmVqbmxiNmRvSUNqZEY3clZnci9pRkkKLS0tIGVLSVFwTy9TSElFUkdjOVlWb3Yy
OFllMEh3cVJZZnFxbW4xS1RtcFQzcFUKo/1WcYp4nPBXba8wQBe3DMt6pYQJGoSu
ja5BiCffN5wOoW9WT0j8Clx21w7BXcl46+T5GYpXDQDcqf6nCv1kYQ==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-17T20:48:00Z"
mac: ENC[AES256_GCM,data:SCWiSiDccPkZApOcc8RsYP7WPZUqUyYVB0UgivLhIsNSY5q3kCdenPLTUp2zLOcwaWzTPGmj++QtZjoNobcIhdVt1aJ9uXLLKRUXaRGIO3Jmhg3wj7kSPNjbDLZEB6uyA9h3edQGVVivNlNGpo91tg35QcFPPSG7UiowFnsD0zM=,iv:44hkujM/ZWjtYHau8BFMdOIeBj5jF/WnW4OOK7oSw1Y=,tag:mtJdUR+sA0tjIyAWDpXQlA==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -0,0 +1,2 @@
# dagger state
state/**

View File

@ -0,0 +1,74 @@
package terraform
import (
"dagger.io/dagger"
"dagger.io/dagger/op"
"dagger.io/alpine"
"dagger.io/terraform"
)
TestData: dagger.#Artifact @dagger(input)
TestConfig: awsConfig: {
accessKey: dagger.#Secret @dagger(input)
secretKey: dagger.#Secret @dagger(input)
region: "us-east-2"
}
#TestGetConfig: {
accessKey: dagger.#Secret
secretKey: dagger.#Secret
visibleAccessKey: string
visibleSecretKey: string
#up: [
op.#Load & {from: alpine.#Image & {
package: {
bash: true
jq: true
}
}},
op.#Exec & {
always: true
args: ["/bin/bash", "-c", #"""
export ACCESS_KEY=$(cat /accessKey)
export SECRET_KEY=$(cat /secretKey)
jq --arg key0 'visibleAccessKey' --arg value0 "$ACCESS_KEY" \
--arg key1 'visibleSecretKey' --arg value1 "$SECRET_KEY" \
'. | .[$key0]=$value0 | .[$key1]=$value1' <<< '{}' > /out
"""#,
]
mount: {
"/accessKey": secret: accessKey
"/secretKey": secret: secretKey
}
},
op.#Export & {
source: "/out"
format: "json"
},
]
}
TestTerraform: {
config: #TestGetConfig & {
accessKey: TestConfig.awsConfig.accessKey
secretKey: TestConfig.awsConfig.secretKey
}
apply: terraform.#Configuration & {
source: TestData
env: {
AWS_ACCESS_KEY_ID: config.visibleAccessKey
AWS_SECRET_ACCESS_KEY: config.visibleSecretKey
AWS_DEFAULT_REGION: TestConfig.awsConfig.region
AWS_REGION: TestConfig.awsConfig.region
}
}
}

View File

@ -0,0 +1,31 @@
plan:
module: .dagger/env/terraform/plan
name: terraform
inputs:
TestConfig.awsConfig.accessKey:
secret: ENC[AES256_GCM,data:V/p84nLbgjrytefnsfItiY71ikQ=,iv:i1x3UYP+sctwY9LrRp/rfeJ8/JPWOfiiJSG0NWUiXW0=,tag:IynKh1fQEhExmmR3qGx/zQ==,type:str]
TestConfig.awsConfig.secretKey:
secret: ENC[AES256_GCM,data:cBYaVhbeV9D6acJWNU7uL8AsEtpnY0wHM8td9ZAJ9ebGB+BY4iBZLQ==,iv:SDkRKQQKBSz/cRQlW65sIjF0PhHhhKkGUEgZe9CV7Ek=,tag:OCUQmgjP2p57YoLts9Dh4w==,type:str]
TestData:
dir:
path: ./terraform/testdata
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBkOTJpQWJWY3dnM2hDdXZG
bVJEN0dNUzQ0VGhneWtHVG1hUHA5ZjdhdHdvClR0ZVpKb1RYRnc3dy9wSjVuSHBn
c2RMbzE0Y2EzN2FVak9CMk9CK0hOTFkKLS0tIG9Fdi9xWWc0TU5WY1ZsVUdZM2lw
cC9LSiswbFRKaTNXUGNIWVZVbGJqV1UK3/wsgPwR5P2fzs80wcz1dM/8sbBWMR+B
dmhP99OQisIgcwGATy0nh726pYKtosDpSLIJkLZDAUq9qRKm9bch1w==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-06-18T16:01:11Z"
mac: ENC[AES256_GCM,data:XznDGqfZkC6vsv696qWVxbBCUgsyU/zPZg0NCULCXAfO08Hsteb0c93Y8DA3CV8flQW3cgn5XLugNnQADJ6luTXHbqIVMVMUSe1q41Kxl7exr/dn0robqaRm5MnloG823s9X3sAOcPzyTSxy1YVZfYaYbG23w9IeNmVTyaUttkU=,iv:kEQs7+bx+7j2v5b6Bx0r+ZVtp7rj/8mgX4oRUP7cruc=,tag:oQEfCPO/0V11rmkc0yaz3Q==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -39,10 +39,33 @@ dagger() {
# copy_to_sandbox myenv
# dagger input secret -w "$DAGGER_SANDBOX" -e myenv "temporary change"
# dagger up -w "$DAGGER_SANDBOX" -e myenv
#
# To use testdata directory in tests, add the package name as second flag
# Usage:
# copy_to_sandbox myenv mypackage
copy_to_sandbox() {
local name="$1"
local source="$DAGGER_WORKSPACE"/.dagger/env/"$name"
local target="$DAGGER_SANDBOX"/.dagger/env/"$name"
cp -a "$source" "$target"
if [ -d "$2" ]; then
local package="$2"
local source_package="$DAGGER_WORKSPACE"/"$package"
local target_package="$DAGGER_SANDBOX"/
cp -a "$source_package" "$target_package"
fi
}
# Check if there is a local kubernetes cluster.
#
# This is need to do kubernetes test in the CI.
skip_unless_local_kube() {
if [ -f ~/.kube/config ] && grep -q "user: kind-kind" ~/.kube/config &> /dev/null && grep -q "127.0.0.1" ~/.kube/config &> /dev/null; then
echo "Kubernetes available"
else
skip "local kubernetes cluster not available"
fi
}

View File

@ -32,10 +32,18 @@ setup() {
dagger -e aws-s3 up
}
@test "aws: eks" {
dagger -e aws-eks up
}
@test "docker run: local" {
dagger -e docker-run-local up
}
@test "docker build" {
dagger -e docker-build up
}
@test "docker command: ssh" {
dagger -e docker-command-ssh up
}
@ -53,6 +61,40 @@ setup() {
dagger -e docker-run-ssh up
}
@test "kubernetes: deployment" {
skip_unless_local_kube
# Copy deployment to sandbox
copy_to_sandbox kubernetes-deployment
# Set kubeconfig
dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input text TestKubeconfig -f "$HOME"/.kube/config
dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment up
# Unset kubeconfig
dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input unset TestKubeconfig
}
@test "kubernetes: kustomize" {
dagger -e kubernetes-kustomize up
}
@test "kubernetes: helm" {
skip_unless_local_kube
# Copy deployment to sandbox
copy_to_sandbox kubernetes-helm kubernetes
# Set kubeconfig
dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input text TestKubeconfig -f "$HOME"/.kube/config
dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm up
# Unset kubeconfig
dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input unset TestKubeconfig
}
@test "google cloud: gcr" {
dagger -e google-gcr up
}
@ -60,3 +102,32 @@ setup() {
@test "google cloud: gke" {
dagger -e google-gke up
}
@test "terraform" {
# it must fail because of a missing var
run dagger -e terraform up
assert_failure
# Copy deployment to sandbox
copy_to_sandbox terraform terraform
# Add the var and try again
run dagger -w "$DAGGER_SANDBOX" -e terraform input text TestTerraform.apply.tfvars.input "42"
run dagger -w "$DAGGER_SANDBOX" -e terraform up
assert_success
# ensure the tfvar was passed correctly
run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.input.value -f text
assert_success
assert_output "42"
# ensure the random value is always the same
# this proves we're effectively using the s3 backend
run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.random.value -f json
assert_success
assert_output "36"
# Unset input
run dagger -w "$DAGGER_SANDBOX" -e terraform input unset TestTerraform.apply.tfvars.input
assert_success
}

View File

@ -6,59 +6,7 @@ setup() {
# FIXME: move to universe/universe.bats
# Assigned to: <ADD YOUR NAME HERE>
@test "stdlib: kubernetes" {
skip_unless_local_kube
"$DAGGER" init
dagger_new_with_plan kubernetes "$TESTDIR"/stdlib/kubernetes/
run "$DAGGER" input -e "kubernetes" text kubeconfig -f ~/.kube/config
assert_success
run "$DAGGER" up -e "kubernetes"
assert_success
}
# FIXME: move to universe/universe.bats
# Assigned to: <ADD YOUR NAME HERE>
@test "stdlib: kustomize" {
"$DAGGER" compute "$TESTDIR"/stdlib/kubernetes/kustomize --input-dir TestKustomize.kustom.source="$TESTDIR"/stdlib/kubernetes/kustomize/testdata
}
# FIXME: move to universe/universe.bats
# Assigned to: <ADD YOUR NAME HERE>
@test "stdlib: helm" {
skip "helm is broken"
skip_unless_local_kube
"$DAGGER" init
dagger_new_with_plan helm "$TESTDIR"/stdlib/kubernetes/helm
run "$DAGGER" input -e "helm" text kubeconfig -f ~/.kube/config
assert_success
cp -R "$TESTDIR"/stdlib/kubernetes/helm/testdata/mychart "$DAGGER_WORKSPACE"/testdata
run "$DAGGER" input -e "helm" dir TestHelmSimpleChart.deploy.chartSource "$DAGGER_WORKSPACE"/testdata
assert_success
run "$DAGGER" up -e "helm"
assert_success
}
# FIXME: move to universe/universe.bats
# Assigned to: <ADD YOUR NAME HERE>
@test "stdlib: docker: build" {
"$DAGGER" compute "$TESTDIR"/stdlib/docker/build/ --input-dir source="$TESTDIR"/stdlib/docker/build
}
# FIXME: move to universe/universe.bats
# Assigned to: <ADD YOUR NAME HERE>
@test "stdlib: docker: dockerfile" {
"$DAGGER" compute "$TESTDIR"/stdlib/docker/dockerfile/ --input-dir source="$TESTDIR"/stdlib/docker/dockerfile/testdata
}
# FIXME: move to universe/universe.bats
# Assigned to: <ADD YOUR NAME HERE>
# Changes in https://github.com/dagger/dagger/pull/628
@test "stdlib: docker: push-and-pull" {
skip_unless_secrets_available "$TESTDIR"/stdlib/docker/push-pull/inputs.yaml
@ -66,38 +14,3 @@ setup() {
run "$DAGGER" compute --input-yaml "$TESTDIR"/stdlib/docker/push-pull/inputs.yaml --input-dir source="$TESTDIR"/stdlib/docker/push-pull/testdata "$TESTDIR"/stdlib/docker/push-pull/
assert_success
}
# FIXME: move to universe/universe.bats
# Assigned to: <ADD YOUR NAME HERE>
@test "stdlib: terraform" {
skip_unless_secrets_available "$TESTDIR"/stdlib/terraform/s3/inputs.yaml
"$DAGGER" init
dagger_new_with_plan terraform "$TESTDIR"/stdlib/terraform/s3
cp -R "$TESTDIR"/stdlib/terraform/s3/testdata "$DAGGER_WORKSPACE"/testdata
"$DAGGER" -e terraform input dir TestData "$DAGGER_WORKSPACE"/testdata
sops -d "$TESTDIR"/stdlib/terraform/s3/inputs.yaml | "$DAGGER" -e "terraform" input yaml "" -f -
# it must fail because of a missing var
run "$DAGGER" up -e terraform
assert_failure
# add the var and try again
"$DAGGER" -e terraform input text TestTerraform.apply.tfvars.input "42"
run "$DAGGER" up -e terraform
assert_success
# ensure the tfvar was passed correctly
run "$DAGGER" query -e terraform \
TestTerraform.apply.output.input.value -f text
assert_success
assert_output "42"
# ensure the random value is always the same
# this proves we're effectively using the s3 backend
run "$DAGGER" query -e terraform \
TestTerraform.apply.output.random.value -f json
assert_success
assert_output "36"
}

View File

@ -1,26 +0,0 @@
name: default
inputs:
TestConfig.awsConfig.accessKey:
secret: ENC[AES256_GCM,data:dzhlip9kKU8mMEycFjq6MobD5BA=,iv:LKeYUbXpnWIZneGs7DCLVKxv1W2aa/3EVGO4jnDlOgc=,tag:+TcxQahxFTweyoPaROTJSQ==,type:str]
TestConfig.awsConfig.secretKey:
secret: ENC[AES256_GCM,data:bu3AI5jODWv4ePvRKw2l/1UOuH07Z0/oB2hiY4QqrhTcfjdSbr6kBg==,iv:BqddzzXqvAv0cAj2SVhoFx/kUOnRsoevqMRujCINVv0=,tag:u0KjVnbN8h54CLFARJmJ0g==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAzV0ZXNW5qaGNJMjF5bnBO
d1Z1RXFhSnNRM1Vwa3lyWFJ6VVFDZTQ3cUhZClh0N1lxZ3dwSFhHTjRyS092OVVj
Tkw4ZlU4S3g0T1VGS1RYYnB1dGlzbVkKLS0tIEc4T1Z3SEU2NUNhd2FkSXlIUERM
UE5Cd2VwYkd1MHlTOXNJVEU3RVpqU2sK86kXU6ZaaVHTg9BuCEcOxnDrrW00+bwu
AHttbzqYVuC3YxXjOTzAZL8aYTStk14wGdI6TirZ9pX0fyaKAfzBUQ==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-05-27T16:01:59Z"
mac: ENC[AES256_GCM,data:T+0rcT9Xi/kJ8+EzCd7ewenDmc1cH/t2MxCpf+QXkILUC/uE8OgROizDMAiUYI2HpeBfZrmUgLMVzlTZirIbC51eWLAf6itbSIGKkVuz0uSNwhRpKGAROg6U1h39Scg6RpAvpzSTZvYOx5SwP78Uc6NQdp5yTDEb+0e9Wqzu+jU=,iv:INAN+EPwBv5dWWHQnaMr4QOBQWx3WCcohORvIPrBZN8=,tag:N4vtDowFKTDSHmMob5HgCw==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -1,53 +0,0 @@
package eks
import (
"dagger.io/aws"
"dagger.io/aws/eks"
"dagger.io/kubernetes"
"dagger.io/dagger/op"
)
TestConfig: awsConfig: aws.#Config & {
region: "us-east-2"
}
TestCluster: eks.#KubeConfig & {
config: TestConfig.awsConfig
clusterName: *"dagger-example-eks-cluster" | string
}
TestEks: {
#GetPods:
"""
kubectl get pods -A
"""
#up: [
op.#Load & {
from: kubernetes.#Kubectl
},
op.#WriteFile & {
dest: "/kubeconfig"
content: TestCluster.kubeconfig
},
op.#WriteFile & {
dest: "/getPods.sh"
content: #GetPods
},
op.#Exec & {
always: true
args: [
"/bin/bash",
"--noprofile",
"--norc",
"-eo",
"pipefail",
"/getPods.sh",
]
env: KUBECONFIG: "/kubeconfig"
},
]
}

View File

@ -1,31 +0,0 @@
package docker
import (
"dagger.io/dagger"
"dagger.io/dagger/op"
"dagger.io/docker"
)
// Build a Docker image from source, using included Dockerfile
source: dagger.#Artifact
TestBuild: {
image: docker.#Build & {
"source": source
}
verify: #up: [
op.#Load & {
from: image
},
op.#Exec & {
always: true
args: [
"sh", "-c", """
grep -q "test" /test.txt
""",
]
},
]
}

View File

@ -1,25 +0,0 @@
package testing
import (
"dagger.io/dagger"
"dagger.io/terraform"
)
TestData: dagger.#Artifact
TestConfig: awsConfig: {
accessKey: string
secretkey: string
region: "us-east-2"
}
TestTerraform: apply: terraform.#Configuration & {
source: TestData
env: {
AWS_ACCESS_KEY_ID: TestConfig.awsConfig.accessKey
AWS_SECRET_ACCESS_KEY: TestConfig.awsConfig.secretKey
AWS_DEFAULT_REGION: TestConfig.awsConfig.region
AWS_REGION: TestConfig.awsConfig.region
}
}