Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmeenkaur committed Jul 17, 2023
1 parent 4613b27 commit dde7d81
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 28 deletions.
67 changes: 50 additions & 17 deletions cd_scripts/e2e_starter_script.sh → cd_scripts/e2e_test.sh
@@ -1,62 +1,94 @@
#! /bin/bash
# Copyright 2023 Google Inc. 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.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Print commands and their arguments as they are executed.
set -x
# Exit immediately if a command exits with a non-zero status.
set -e

#details.txt file contains the release version and commit hash of the current release.
gsutil cp gs://gcsfuse-release-packages/version-detail/details.txt .
# Writing VM instance name to details.txt (Format: release-test-<os-name>)
curl http://metadata.google.internal/computeMetadata/v1/instance/name -H "Metadata-Flavor: Google" >> details.txt

# Based on the os type(from vm instance name) in detail.txt, run the following commands to add starterscriptuser
if grep -q ubuntu details.txt || grep -q debian details.txt;
then
sudo adduser --ingroup google-sudoers --disabled-password --home=/home/starterscript --gecos "" starterscript
# For ubuntu and debian os
sudo adduser --ingroup google-sudoers --disabled-password --home=/home/starterscriptuser --gecos "" starterscriptuser
else
sudo adduser -g google-sudoers --home-dir=/home/starterscript starterscript
# For rhel and centos
sudo adduser -g google-sudoers --home-dir=/home/starterscriptuser starterscriptuser
fi
sudo -u starterscript bash -c '

# Run the following as starterscriptuser
sudo -u starterscriptuser bash -c '
# Exit immediately if a command exits with a non-zero status.
set -e
# Print commands and their arguments as they are executed.
set -x
#Copy details.txt to starterscriptuser home directory and create logs.txt
cd ~/
cp /details.txt .
touch logs.txt
gsutil cp gs://gcsfuse-release-packages/version-detail/details.txt .
curl http://metadata.google.internal/computeMetadata/v1/instance/name -H "Metadata-Flavor: Google" >> details.txt
touch ~/logs.txt
echo User: $USER &>> ~/logs.txt
echo Current Working Directory: $(pwd) &>> ~/logs.txt
# Based on the os type in detail.txt, run the following commands for setup
if grep -q ubuntu details.txt || grep -q debian details.txt;
then
# For Debian and Ubuntu os
sudo apt update
#Install fuse
yes | sudo apt install fuse
sudo apt install -y fuse
# download and install gcsfuse deb package
gsutil cp gs://gcsfuse-release-packages/v$(sed -n 1p details.txt)/gcsfuse_$(sed -n 1p details.txt)_amd64.deb .
yes | sudo dpkg -i gcsfuse_$(sed -n 1p details.txt)_amd64.deb |& tee -a ~/logs.txt
sudo dpkg -i gcsfuse_$(sed -n 1p details.txt)_amd64.deb |& tee -a ~/logs.txt
# install wget
yes | sudo apt install wget
sudo apt install -y wget
#install git
yes | sudo apt install git
sudo apt install -y git
#install build-essentials
yes | sudo apt install build-essential
sudo apt install -y build-essential
else
# For rhel and centos
sudo yum makecache
sudo yum check-update
#Install fuse
yes | sudo yum install fuse
sudo yum -y install fuse
#download and install gcsfuse rpm package
gsutil cp gs://gcsfuse-release-packages/v$(sed -n 1p details.txt)/gcsfuse-$(sed -n 1p details.txt)-1.x86_64.rpm .
yes | sudo yum localinstall gcsfuse-$(sed -n 1p details.txt)-1.x86_64.rpm
sudo yum -y localinstall gcsfuse-$(sed -n 1p details.txt)-1.x86_64.rpm
#install wget
yes | sudo yum install wget
sudo yum -y install wget
#install git
yes | sudo yum install git
sudo yum -y install git
#install Development tools
yes | sudo yum install gcc gcc-c++ make
sudo yum -y install gcc gcc-c++ make
fi
# install go
Expand All @@ -77,7 +109,8 @@ git checkout $(sed -n 2p ~/details.txt) |& tee -a ~/logs.txt
#run tests with testbucket flag
GODEBUG=asyncpreemptoff=1 go test ./tools/integration_tests/... -p 1 --integrationTest -v --testbucket=$(sed -n 3p ~/details.txt) --testInstalledPackage --timeout=60m &>> ~/logs.txt
if grep -q FAIL ~/logs.txt; then
if grep -q FAIL ~/logs.txt;
then
echo "Test failures detected" &>> ~/logs.txt
else
touch success.txt
Expand Down
42 changes: 31 additions & 11 deletions cd_scripts/install_starter_script.sh → cd_scripts/install_test.sh
@@ -1,24 +1,44 @@
#! /bin/bash
# Copyright 2023 Google Inc. 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.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Print commands and their arguments as they are executed.
set -x

#details.txt file contains the release version and commit hash of the current release.
gsutil cp gs://gcsfuse-release-packages/version-detail/details.txt .
# Writing VM instance name to details.txt (Format: release-test-<os-name>)
curl http://metadata.google.internal/computeMetadata/v1/instance/name -H "Metadata-Flavor: Google" >> details.txt
touch ~/logs.txt

# Install apt-transport-artifact-registry
# Based on the os type(from vm instance name) in detail.txt, run the following commands to install apt-transport-artifact-registry
if grep -q ubuntu details.txt || grep -q debian details.txt;
then
# For ubuntu and debian os
curl https://us-central1-apt.pkg.dev/doc/repo-signing-key.gpg | sudo apt-key add - && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo 'deb http://packages.cloud.google.com/apt apt-transport-artifact-registry-stable main' | sudo tee -a /etc/apt/sources.list.d/artifact-registry.list
sudo apt update
sudo apt install apt-transport-artifact-registry
echo 'deb ar+https://us-apt.pkg.dev/projects/gcs-fuse-prod gcsfuse-bullseye main' | sudo tee -a /etc/apt/sources.list.d/artifact-registry.list
echo 'deb ar+https://us-apt.pkg.dev/projects/gcs-fuse-prod $(lsb_release -cs) main' | sudo tee -a /etc/apt/sources.list.d/artifact-registry.list
sudo apt update

# Install released gcsfuse version
yes | sudo apt install gcsfuse=$(sed -n 1p details.txt) -t gcsfuse-bullseye |& tee -a ~/logs.txt
sudo apt install -y gcsfuse=$(sed -n 1p details.txt) -t gcsfuse-$(lsb_release -cs) |& tee -a ~/logs.txt
else
# For rhel and centos
sudo yum makecache
yes | sudo yum install yum-plugin-artifact-registry
sudo yum -y install yum-plugin-artifact-registry
sudo tee -a /etc/yum.repos.d/artifact-registry.repo << EOF
[gcsfuse-el7-x86-64]
name=gcsfuse-el7-x86-64
Expand All @@ -30,7 +50,7 @@ gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
sudo yum makecache
yes | sudo yum --enablerepo=gcsfuse-el7-x86-64 install gcsfuse-$(sed -n 1p details.txt)-1 |& tee -a ~/logs.txt
sudo yum -y --enablerepo=gcsfuse-el7-x86-64 install gcsfuse-$(sed -n 1p details.txt)-1 |& tee -a ~/logs.txt
fi

# Verify gcsfuse version (successful installation)
Expand All @@ -45,11 +65,11 @@ fi
# Uninstall gcsfuse latest version and install old version
if grep -q ubuntu details.txt || grep -q debian details.txt;
then
yes | sudo apt remove gcsfuse
yes | sudo apt install gcsfuse=0.42.5 -t gcsfuse-bullseye |& tee -a ~/logs.txt
sudo apt remove -y gcsfuse
sudo apt install -y gcsfuse=0.42.5 -t gcsfuse-$(lsb_release -cs) |& tee -a ~/logs.txt
else
yes | sudo yum remove gcsfuse
yes | sudo yum install gcsfuse-0.42.5-1 |& tee -a ~/logs.txt
sudo yum -y remove gcsfuse
sudo yum -y install gcsfuse-0.42.5-1 |& tee -a ~/logs.txt
fi

# verify old version installation
Expand All @@ -66,7 +86,7 @@ if grep -q ubuntu details.txt || grep -q debian details.txt;
then
sudo apt install --only-upgrade gcsfuse |& tee -a ~/logs.txt
else
yes | sudo yum upgrade gcsfuse |& tee -a ~/logs.txt
sudo yum -y upgrade gcsfuse |& tee -a ~/logs.txt
fi

gcsfuse --version |& tee version.txt
Expand All @@ -84,4 +104,4 @@ else
gsutil cp success.txt gs://gcsfuse-release-packages/v$(sed -n 1p details.txt)/installation-test/$(sed -n 3p details.txt)/ ;
fi

gsutil cp ~/logs.txt gs://gcsfuse-release-packages/v$(sed -n 1p details.txt)/installation-test/$(sed -n 3p details.txt)/
gsutil cp ~/logs.txt gs://gcsfuse-release-packages/v$(sed -n 1p details.txt)/installation-test/$(sed -n 3p details.txt)/

0 comments on commit dde7d81

Please sign in to comment.