github.com/pachyderm/pachyderm@v1.13.4/etc/testing/deploy-manifests/validate.sh (about) 1 #!/bin/bash 2 3 set -e 4 5 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 6 # shellcheck source=./../../govars.sh 7 source "${SCRIPT_DIR}/../../govars.sh" 8 9 here="$(dirname "${0}")" 10 dest_dir="test" 11 rm -rf "${here:?}/${dest_dir:?}" || true 12 mkdir -p "${here}/${dest_dir}" 13 14 is_regenerate="" 15 if [[ "${#@}" -eq 1 ]]; then 16 if [[ "${1}" == "--regenerate" ]]; then 17 is_regenerate="true" 18 dest_dir="golden" 19 else 20 echo "Unrecognized flag ${1}" >/dev/stderr 21 echo "Must be --regenerate" >/dev/stderr 22 exit 1 23 fi 24 fi 25 26 # Generate a deployment manifest for many different targets using the local 27 # build of 'pachctl' 28 # shellcheck disable=SC2034 29 custom_args=( 30 --cluster-deployment-id test 31 --secure 32 --dynamic-etcd-nodes 3 33 --etcd-storage-class storage-class 34 --namespace pachyderm 35 --no-expose-docker-socket 36 "--object-store=s3" 37 pach-volume # <volumes> 38 50 # <size of volumes (in GB)> 39 pach-bucket # <bucket> 40 storage-id # <id> 41 storage-secret # <secret> 42 storage.endpoint # <endpoint> 43 ) 44 # shellcheck disable=SC2034 45 google_args=( 46 --cluster-deployment-id test 47 --dynamic-etcd-nodes 3 48 pach-bucket # <bucket-name> 49 50 # <disk-size> 50 ) 51 # shellcheck disable=SC2034 52 amazon_args=( 53 --cluster-deployment-id test 54 --dynamic-etcd-nodes 3 55 --credentials "AWSIDAWSIDAWSIDAWSID,awssecret+awssecret+awssecret+awssecret+" 56 pach-bucket # <bucket-name> 57 us-west-1 # <region> 58 50 # <disk-size> 59 ) 60 # shellcheck disable=SC2034 61 microsoft_args=( 62 --cluster-deployment-id test 63 --dynamic-etcd-nodes 3 64 pach-container # <container> 65 pach-account # <account-name> 66 "cGFjaC1hY2NvdW50LWtleQ==" # <account-key> (base64-encoded "pach-account-key") 67 50 # <disk-size> 68 ) 69 70 pach_config="${here}/${dest_dir}/pachconfig" 71 # Use a test-specific pach config to avoid local settings from changing the 72 # output 73 export PACH_CONFIG="${pach_config}" 74 for platform in custom google amazon microsoft; do 75 for fmt in json yaml; do 76 output="${here}/${dest_dir}/${platform}-deploy-manifest.${fmt}" 77 eval "args=( \"\${${platform}_args[@]}\" )" 78 # Generate kubernetes manifest: 79 # - strip additional version info so that pachctl builds from the same 80 # version all work 81 # - Use an empty pach config so that e.g. metrics don't change the output 82 # shellcheck disable=SC2154 83 "${PACHCTL}" deploy "${platform}" "${args[@]}" -o "${fmt}" --dry-run \ 84 | sed 's/\([0-9]\{1,4\}\.[0-9]\{1,4\}\.[0-9]\{1,4\}\)-[0-9a-f]\{40\}/\1/g' >"${output}" 85 rm -f "${pach_config}" # remove cfg from next run (or diff dir, or golden/) 86 if [[ ! "${is_regenerate}" ]]; then 87 # Check manifests with kubeval 88 kubeval "${output}" 89 fi 90 done 91 done 92 93 # XXX: for now, skip diffing because 'ci_build' ends up in the version. Not 94 # sure how to workaround that. 95 # https://app.circleci.com/pipelines/github/pachyderm/pachyderm/80/workflows/088e1426-b4ce-4baa-85e2-f9a20cc75151/jobs/2934 96 if [ -z "$RUN_BAD_TESTS" ]; then 97 echo "Skipping because RUN_BAD_TESTS is empty" 98 exit 0 99 fi 100 101 if [[ "${is_regenerate}" ]]; then 102 exit 0 103 fi 104 105 # Compare manifests to golden files (in addition to kubeval, to see changes 106 # in storage secrets and such) 107 # 108 # TODO(msteffen): if we ever consider removing this because it generates too 109 # many spurious test failures, then I highly recomment we keep the 'kubeval' 110 # validation above, as it should accept any valid kubernetes manifest, and 111 # would've caught at least one serialization bug that completely broke 'pachctl 112 # deploy' in v1.9.8 113 echo "" 114 echo "Diffing 'pachctl deploy' output with known-good golden deploy manifests." 115 DIFF_CMD="${DIFF_CMD:-diff --unified=6}" 116 if ! ${DIFF_CMD} "${here}/${dest_dir}" "${here}/golden"; then 117 echo "" 118 echo "Error: deployment manifest has changed." 119 echo "If this test is failing because you have deliberately changed"\ 120 "'pachctl deploy', you'll need to fix it by replacing the golden"\ 121 "deployment manifests." 122 echo "You can update the golden manifests by running:" 123 echo " make regenerate-test-deploy-manifests" 124 exit 1 125 else 126 echo "" 127 echo "No differences found" 128 fi