Add basic test for kubernetes kind documentation
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
committed by
Guillaume de Rouville
parent
6a442fae6c
commit
a8e218d808
@@ -2,162 +2,182 @@
|
||||
## Indentation is important, please append at the end
|
||||
|
||||
setup() {
|
||||
load 'helpers'
|
||||
load 'helpers'
|
||||
|
||||
common_setup
|
||||
common_setup
|
||||
}
|
||||
|
||||
# Test 1003-get-started
|
||||
@test "doc-1003-get-started" {
|
||||
setup_example_sandbox "doc"
|
||||
setup_example_sandbox "doc"
|
||||
|
||||
# Set examples private key
|
||||
./import-tutorial-key.sh
|
||||
# Set examples private key
|
||||
./import-tutorial-key.sh
|
||||
|
||||
# Collect url
|
||||
dagger up
|
||||
url=$(dagger query -f text url)
|
||||
# Collect url
|
||||
dagger up
|
||||
url=$(dagger query -f text url)
|
||||
|
||||
# More commands
|
||||
dagger list
|
||||
ls -l ./s3
|
||||
dagger input list
|
||||
# More commands
|
||||
dagger list
|
||||
ls -l ./s3
|
||||
dagger input list
|
||||
|
||||
# Check output
|
||||
run curl $url
|
||||
assert_output --partial "My Todo app"
|
||||
# Check output
|
||||
run curl $url
|
||||
assert_output --partial "My Todo app"
|
||||
}
|
||||
|
||||
@test "doc-1004-first-env" {
|
||||
setup_example_sandbox "doc"
|
||||
setup_example_sandbox "doc"
|
||||
|
||||
# Follow tutorial
|
||||
mkdir multibucket
|
||||
cp $CODEBLOC_SRC/multibucket/source.cue multibucket
|
||||
cp $CODEBLOC_SRC/multibucket/yarn.cue multibucket
|
||||
cp $CODEBLOC_SRC/multibucket/netlify.cue multibucket
|
||||
# Follow tutorial
|
||||
mkdir multibucket
|
||||
cp $CODEBLOC_SRC/multibucket/source.cue multibucket
|
||||
cp $CODEBLOC_SRC/multibucket/yarn.cue multibucket
|
||||
cp $CODEBLOC_SRC/multibucket/netlify.cue multibucket
|
||||
|
||||
dagger doc alpha.dagger.io/netlify
|
||||
dagger doc alpha.dagger.io/js/yarn
|
||||
dagger doc alpha.dagger.io/netlify
|
||||
dagger doc alpha.dagger.io/js/yarn
|
||||
|
||||
# Initialize new env
|
||||
dagger new 'multibucket' -p ./multibucket
|
||||
# Initialize new env
|
||||
dagger new 'multibucket' -p ./multibucket
|
||||
|
||||
# Copy corresponding env
|
||||
cp -r $CODEBLOC_SRC/.dagger/env/multibucket .dagger/env/
|
||||
# Add missing src input
|
||||
dagger -e multibucket input dir src .
|
||||
# Copy corresponding env
|
||||
cp -r $CODEBLOC_SRC/.dagger/env/multibucket .dagger/env/
|
||||
# Add missing src input
|
||||
dagger -e multibucket input dir src .
|
||||
|
||||
# Run test
|
||||
dagger -e multibucket up
|
||||
url=$(dagger -e multibucket query -f text site.netlify.deployUrl)
|
||||
# Run test
|
||||
dagger -e multibucket up
|
||||
url=$(dagger -e multibucket query -f text site.netlify.deployUrl)
|
||||
|
||||
# Check output :
|
||||
run curl $url
|
||||
assert_output --partial "./static/css/main.9149988f.chunk.css"
|
||||
# Check output :
|
||||
run curl $url
|
||||
assert_output --partial "./static/css/main.9149988f.chunk.css"
|
||||
}
|
||||
|
||||
@test "doc-1006-google-cloud-run" {
|
||||
setup_example_sandbox "doc"
|
||||
setup_example_sandbox "doc"
|
||||
|
||||
mkdir gcpcloudrun
|
||||
cp $CODEBLOC_SRC/gcpcloudrun/source.cue gcpcloudrun
|
||||
mkdir gcpcloudrun
|
||||
cp $CODEBLOC_SRC/gcpcloudrun/source.cue gcpcloudrun
|
||||
|
||||
# Initialize new env
|
||||
dagger new 'gcpcloudrun' -p gcpcloudrun
|
||||
# Initialize new env
|
||||
dagger new 'gcpcloudrun' -p gcpcloudrun
|
||||
|
||||
# Copy corresponding env
|
||||
cp -r $CODEBLOC_SRC/.dagger/env/gcpcloudrun .dagger/env/
|
||||
# Add missing src input
|
||||
dagger -e gcpcloudrun input dir src .
|
||||
# Copy corresponding env
|
||||
cp -r $CODEBLOC_SRC/.dagger/env/gcpcloudrun .dagger/env/
|
||||
# Add missing src input
|
||||
dagger -e gcpcloudrun input dir src .
|
||||
|
||||
# Run test
|
||||
run dagger -e gcpcloudrun up
|
||||
assert_success
|
||||
# Run test
|
||||
run dagger -e gcpcloudrun up
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "doc-1007-kube-kind" {
|
||||
skip_unless_local_kube
|
||||
|
||||
#################### BASIC ####################
|
||||
# Copy deployment to sendbox
|
||||
copy_to_sandbox kube-kind-basic kube-kind
|
||||
|
||||
# Add kubeconfig
|
||||
dagger -w "$DAGGER_SANDBOX" -e kube-kind-basic input text kubeconfig -f "$HOME"/.kube/config
|
||||
|
||||
# Up deployment
|
||||
dagger -w "$DAGGER_SANDBOX" -e kube-kind-basic up
|
||||
|
||||
# Check deployment
|
||||
kubectl get deployment
|
||||
|
||||
# Clean
|
||||
kubectl delete deployments --all
|
||||
}
|
||||
|
||||
@test "doc-1008-aws-cloudformation" {
|
||||
setup_example_sandbox "doc"
|
||||
setup_example_sandbox "doc"
|
||||
|
||||
### Create a basic plan
|
||||
## Construct
|
||||
mkdir cloudformation
|
||||
cp $CODEBLOC_SRC/cloudformation/template.cue cloudformation
|
||||
### Create a basic plan
|
||||
## Construct
|
||||
mkdir cloudformation
|
||||
cp $CODEBLOC_SRC/cloudformation/template.cue cloudformation
|
||||
|
||||
# Cloudformation relay
|
||||
dagger doc alpha.dagger.io/aws/cloudformation
|
||||
cp $CODEBLOC_SRC/cloudformation/source-begin.cue cloudformation/source.cue
|
||||
# Cloudformation relay
|
||||
dagger doc alpha.dagger.io/aws/cloudformation
|
||||
cp $CODEBLOC_SRC/cloudformation/source-begin.cue cloudformation/source.cue
|
||||
|
||||
# Initialize new env
|
||||
dagger new 'cloudformation' -p cloudformation
|
||||
# Initialize new env
|
||||
dagger new 'cloudformation' -p cloudformation
|
||||
|
||||
# Finish template setup
|
||||
cp $CODEBLOC_SRC/cloudformation/source-end.cue cloudformation/source.cue
|
||||
# Copy corresponding env
|
||||
cp -r $CODEBLOC_SRC/.dagger/env/cloudformation .dagger/env/
|
||||
# Finish template setup
|
||||
cp $CODEBLOC_SRC/cloudformation/source-end.cue cloudformation/source.cue
|
||||
# Copy corresponding env
|
||||
cp -r $CODEBLOC_SRC/.dagger/env/cloudformation .dagger/env/
|
||||
|
||||
# Run test
|
||||
dagger -e cloudformation up
|
||||
stackName=$(dagger -e cloudformation query cfnStackName -f text)
|
||||
# Run test
|
||||
dagger -e cloudformation up
|
||||
stackName=$(dagger -e cloudformation query cfnStackName -f text)
|
||||
|
||||
## Cleanup
|
||||
# Place back empty source
|
||||
cp $CODEBLOC_SRC/cloudformation/source-begin.cue cloudformation/source.cue
|
||||
cp $CODEBLOC_SRC/cloudformation/deletion.cue cloudformation/deletion.cue
|
||||
# Prepare and run cloudformation cleanup
|
||||
dagger -e cloudformation input text stackRemoval.stackName $stackName
|
||||
dagger -e cloudformation up
|
||||
## Cleanup
|
||||
# Place back empty source
|
||||
cp $CODEBLOC_SRC/cloudformation/source-begin.cue cloudformation/source.cue
|
||||
cp $CODEBLOC_SRC/cloudformation/deletion.cue cloudformation/deletion.cue
|
||||
# Prepare and run cloudformation cleanup
|
||||
dagger -e cloudformation input text stackRemoval.stackName $stackName
|
||||
dagger -e cloudformation up
|
||||
|
||||
### Template part
|
||||
## Create convert.cue
|
||||
cp $CODEBLOC_SRC/cloudformation/template/convert.cue cloudformation/convert.cue
|
||||
rm cloudformation/source.cue cloudformation/deletion.cue
|
||||
### Template part
|
||||
## Create convert.cue
|
||||
cp $CODEBLOC_SRC/cloudformation/template/convert.cue cloudformation/convert.cue
|
||||
rm cloudformation/source.cue cloudformation/deletion.cue
|
||||
|
||||
## Retrieve Unmarshalled JSON
|
||||
dagger query -e cloudformation s3Template
|
||||
## Retrieve Unmarshalled JSON
|
||||
dagger query -e cloudformation s3Template
|
||||
|
||||
## Remove convert.cue
|
||||
rm cloudformation/convert.cue
|
||||
## Store the output
|
||||
cp $CODEBLOC_SRC/cloudformation/template/template-begin.cue cloudformation/template.cue
|
||||
# Inspect conf
|
||||
dagger query -e cloudformation template -f text
|
||||
## Remove convert.cue
|
||||
rm cloudformation/convert.cue
|
||||
## Store the output
|
||||
cp $CODEBLOC_SRC/cloudformation/template/template-begin.cue cloudformation/template.cue
|
||||
# Inspect conf
|
||||
dagger query -e cloudformation template -f text
|
||||
|
||||
cp $CODEBLOC_SRC/cloudformation/template/deployment.cue cloudformation/deployment.cue
|
||||
cp $CODEBLOC_SRC/cloudformation/template/template-end.cue cloudformation/template.cue
|
||||
cp $CODEBLOC_SRC/cloudformation/source-end.cue cloudformation/source.cue
|
||||
cp $CODEBLOC_SRC/cloudformation/template/deployment.cue cloudformation/deployment.cue
|
||||
cp $CODEBLOC_SRC/cloudformation/template/template-end.cue cloudformation/template.cue
|
||||
cp $CODEBLOC_SRC/cloudformation/source-end.cue cloudformation/source.cue
|
||||
|
||||
# Deploy again
|
||||
dagger -e cloudformation query template -f text
|
||||
dagger -e cloudformation up
|
||||
dagger -e cloudformation output list
|
||||
# Deploy again
|
||||
dagger -e cloudformation query template -f text
|
||||
dagger -e cloudformation up
|
||||
dagger -e cloudformation output list
|
||||
|
||||
## Cleanup again
|
||||
stackName=$(dagger -e cloudformation query cfnStackName -f text)
|
||||
rm -rf cloudformation/*
|
||||
# Place back empty source
|
||||
cp $CODEBLOC_SRC/cloudformation/source-begin.cue cloudformation/source.cue
|
||||
cp $CODEBLOC_SRC/cloudformation/deletion.cue cloudformation/deletion.cue
|
||||
# Prepare and run cloudformation cleanup
|
||||
dagger -e cloudformation input text stackRemoval.stackName $stackName
|
||||
dagger -e cloudformation up
|
||||
## Cleanup again
|
||||
stackName=$(dagger -e cloudformation query cfnStackName -f text)
|
||||
rm -rf cloudformation/*
|
||||
# Place back empty source
|
||||
cp $CODEBLOC_SRC/cloudformation/source-begin.cue cloudformation/source.cue
|
||||
cp $CODEBLOC_SRC/cloudformation/deletion.cue cloudformation/deletion.cue
|
||||
# Prepare and run cloudformation cleanup
|
||||
dagger -e cloudformation input text stackRemoval.stackName $stackName
|
||||
dagger -e cloudformation up
|
||||
}
|
||||
|
||||
@test "doc-1010-dev-cue-package" {
|
||||
setup_example_sandbox ""
|
||||
setup_example_sandbox ""
|
||||
|
||||
# Initializing workspace
|
||||
mkdir workspace
|
||||
cd workspace
|
||||
# Initializing workspace
|
||||
mkdir workspace
|
||||
cd workspace
|
||||
|
||||
# Writing the package
|
||||
dagger init
|
||||
mkdir -p cue.mod/pkg/github.com/tjovicic/gcpcloudrun
|
||||
cp $CODEBLOC_SRC/dev-cue-package/source.cue cue.mod/pkg/github.com/tjovicic/gcpcloudrun/source.cue
|
||||
cp $CODEBLOC_SRC/dev-cue-package/script.sh .
|
||||
# Writing the package
|
||||
dagger init
|
||||
mkdir -p cue.mod/pkg/github.com/tjovicic/gcpcloudrun
|
||||
cp $CODEBLOC_SRC/dev-cue-package/source.cue cue.mod/pkg/github.com/tjovicic/gcpcloudrun/source.cue
|
||||
cp $CODEBLOC_SRC/dev-cue-package/script.sh .
|
||||
|
||||
chmod +x script.sh
|
||||
./script.sh
|
||||
run dagger up -e staging
|
||||
assert_output --partial "environment=staging input=run.gcpConfig.serviceKey"
|
||||
chmod +x script.sh
|
||||
./script.sh
|
||||
run dagger up -e staging
|
||||
assert_output --partial "environment=staging input=run.gcpConfig.serviceKey"
|
||||
}
|
||||
|
Reference in New Issue
Block a user