diff --git a/Dockerfile b/Dockerfile index 159cef7..e8993df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2018 Google LLC. All rights reserved. +# Copyright 2024 Google LLC. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -11,16 +11,16 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and -FROM marketplace.gcr.io/google/debian11 +FROM marketplace.gcr.io/google/debian12 -ENV PACKER_VERSION 1.8.3 -ENV PACKER_SHA256 0587f7815ed79589cd9c2b754c82115731c8d0b8fd3b746fe40055d969facba5 -ENV PACKER_BINARY /bin/packer +ENV PACKER_VERSION=1.11.2 +ENV PACKER_SHA256=ced13efc257d0255932d14b8ae8f38863265133739a007c430cae106afcfc45a +ENV PACKER_BINARY=/bin/packer -ENV CHEF_DIR /chef -ENV PACKER_DIR /packer/templates -ENV TESTS_DIR /tests -ENV KEY_FILE_PATH /service-account.json +ENV CHEF_DIR=/chef +ENV PACKER_DIR=/packer/templates +ENV TESTS_DIR=/tests +ENV KEY_FILE_PATH=/service-account.json # Installs packages RUN set -eux \ diff --git a/cloudbuild.yaml b/cloudbuild.yaml index dee4112..7b851e5 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,4 +1,4 @@ -timeout: 600s +timeout: 800s options: workerPool: projects/${PROJECT_ID}/locations/us-central1/workerPools/gcb-workers-pool-e2 steps: diff --git a/scripts/build-vm-image.sh b/scripts/build-vm-image.sh index f41b0e2..8413aeb 100755 --- a/scripts/build-vm-image.sh +++ b/scripts/build-vm-image.sh @@ -95,6 +95,10 @@ python3 "${SCRIPT_DIR}/packergen.py" "${INPUT_TEMPLATE}" > /tmp/template.json echo "Packer: $("${PACKER_BINARY}" -v)" +# Install googlecompute and chef plugins +"${PACKER_BINARY}" plugins install github.com/hashicorp/googlecompute +"${PACKER_BINARY}" plugins install github.com/hashicorp/chef + # Build the packer command PACKER_COMMAND=("${PACKER_BINARY}" build -color=false) PACKER_COMMAND+=(-var "chefdir=${CHEF_DIR}") diff --git a/scripts/packergen.py b/scripts/packergen.py index a78854a..d21f53c 100644 --- a/scripts/packergen.py +++ b/scripts/packergen.py @@ -20,8 +20,8 @@ # Install chef-solo via deb package. INSTALL_CHEF_SOLO = r""" -declare -r VERSION=18.2.7 -declare -r SHA256=a4461840de71f08f11f3c65a6d2f40f41d394e98f84979f7a8388ed0b578c666 +declare -r VERSION=18.5.0 +declare -r SHA256=1918e72eebeea0dd2f7680b08f1362d699b37570431ebca3c1b4fbe40cfc2abb curl "https://packages.chef.io/files/stable/chef/${VERSION}/debian/11/chef_${VERSION}-1_amd64.deb" -o chef-solo.deb \ && echo "${SHA256} chef-solo.deb" | sha256sum -c \ diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh index fefbc95..697449b 100755 --- a/scripts/run-tests.sh +++ b/scripts/run-tests.sh @@ -94,6 +94,12 @@ while (( ${index} <= ${max_connection_attempts} )); do done # Create $IMAGEBUILDER_TEST_DIR directory and upload tests there +echo "Copying tests to the tester instance..." +ssh -i "${PRIVATE_SSH_KEY}" \ + -o UserKnownHostsFile="${TEMPDIR}/known_hosts" \ + -o StrictHostKeyChecking=no \ + "${USER}@${IP}" \ + "/bin/bash -e -c 'mkdir -p "${IMAGEBUILDER_TEST_DIR}"'" scp -r \ -i "${PRIVATE_SSH_KEY}" \ -o UserKnownHostsFile="${TEMPDIR}/known_hosts" \ @@ -101,11 +107,12 @@ scp -r \ "${TESTS_DIR}" "${USER}@${IP}:${IMAGEBUILDER_TEST_DIR}/" # Run tests +echo "Running tests in tester instance..." ssh -i "${PRIVATE_SSH_KEY}" \ -o UserKnownHostsFile="${TEMPDIR}/known_hosts" \ -o StrictHostKeyChecking=no \ "${USER}@${IP}" \ - "/bin/bash -eu -c 'chmod +x ${IMAGEBUILDER_TEST_DIR}/run-tests-on-instance.sh && PACKER_SSH_USERNAME=${PACKER_SSH_USERNAME} SOLUTION_NAME=${SOLUTION_NAME} ${IMAGEBUILDER_TEST_DIR}/run-tests-on-instance.sh'" \ + "/bin/bash -eu -c 'chmod +x ${IMAGEBUILDER_TEST_DIR}/tests/run-tests-on-instance.sh && PACKER_SSH_USERNAME=${PACKER_SSH_USERNAME} SOLUTION_NAME=${SOLUTION_NAME} ${IMAGEBUILDER_TEST_DIR}/tests/run-tests-on-instance.sh'" \ && lcstatus=$? || lcstatus=$? echo "--> Deleting the temporary instance (${INSTANCE}) ..."