Skip to content

Commit

Permalink
update install_test.sh to install via the commands mentioned in publi…
Browse files Browse the repository at this point in the history
…c documentation (#1496)
  • Loading branch information
ashmeenkaur committed Jan 10, 2024
1 parent eb49f93 commit 9ddc828
Showing 1 changed file with 39 additions and 76 deletions.
115 changes: 39 additions & 76 deletions tools/cd_scripts/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,37 @@
# Print commands and their arguments as they are executed.
set -x

function write_config_for_rpm_package {
sudo tee -a /etc/yum.repos.d/artifact-registry.repo << EOF
[gcsfuse-el7-x86-64]
name=gcsfuse-el7-x86-64
baseurl=https://asia-yum.pkg.dev/projects/gcs-fuse-prod/gcsfuse-el7-x86-64
enabled=1
repo_gpgcheck=0
gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
}

#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

# uname can be x86_64 or aarch64
uname=$(uname -m)
if [[ $uname == "x86_64" ]]; then
architecture="amd64"
elif [[ $uname == "aarch64" ]]; then
architecture="arm64"
fi

# Based on the os type(from vm instance name) in detail.txt, run the following commands to install apt-transport-artifact-registry
# Based on the os type(from vm instance name) in detail.txt, run the following
# commands to install gcsfuse.
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 -
# Here we used apt-transport-artifact-registry-unstable main as stable one does not supports arm64, will switch back to stable once they support.
echo 'deb http://packages.cloud.google.com/apt apt-transport-artifact-registry-unstable 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-$(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/artifact-registry.list
sudo apt update

# Install released gcsfuse version
sudo apt install -y gcsfuse=$(sed -n 1p details.txt) -t gcsfuse-$(lsb_release -cs) |& tee -a ~/logs.txt
export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`
echo "deb https://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update
# Install latest released gcsfuse version
sudo apt-get install -y gcsfuse
else
# For rhel and centos
# arm64 machines only supports dnf
sudo yum -y install dnf
sudo dnf makecache
if grep -q centos-7 details.txt || grep -q rhel-7 details.txt;
then
sudo yum -y install yum-plugin-artifact-registry
write_config_for_rpm_package
sudo yum makecache
sudo yum -y --enablerepo=gcsfuse-el7-x86-64 install gcsfuse-$(sed -n 1p details.txt)-1 |& tee -a ~/logs.txt
else
sudo yum -y install dnf-plugin-artifact-registry
write_config_for_rpm_package
sudo dnf makecache
sudo dnf -y --enablerepo=gcsfuse-el7-x86-64 install gcsfuse-$(sed -n 1p details.txt)-1 |& tee -a ~/logs.txt
fi
sudo yum install fuse
sudo tee /etc/yum.repos.d/gcsfuse.repo > /dev/null <<EOF
[gcsfuse]
name=gcsfuse (packages.cloud.google.com)
baseurl=https://packages.cloud.google.com/yum/repos/gcsfuse-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=0
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 install -y gcsfuse
fi

# Verify gcsfuse version (successful installation)
Expand All @@ -85,43 +58,32 @@ else
echo "Failure detected in latest gcsfuse version installation." &>> ~/logs.txt
fi

# This will execute only for amd64 machines, as we have not had any previous releases for arm64.
if [[ $architecture == amd64 ]];

# Uninstall gcsfuse latest version and install old version
if grep -q ubuntu details.txt || grep -q debian details.txt;
then
# Uninstall gcsfuse latest version and install old version
if grep -q ubuntu details.txt || grep -q debian details.txt;
then
sudo apt remove -y gcsfuse
sudo apt install -y gcsfuse=0.42.5 -t gcsfuse-$(lsb_release -cs) |& tee -a ~/logs.txt
else
sudo dnf -y remove gcsfuse
if grep -q centos-7 details.txt || grep -q rhel-7 details.txt; then
sudo yum -y install gcsfuse-0.42.5-1 |& tee -a ~/logs.txt
else
sudo dnf -y install gcsfuse-0.42.5-1 |& tee -a ~/logs.txt
fi
fi
sudo apt-get remove -y gcsfuse |& tee -a ~/logs.txt
sudo apt-get install -y gcsfuse=1.2.0 |& tee -a ~/logs.txt
else
sudo yum -y remove gcsfuse |& tee -a ~/logs.txt
sudo yum install -y gcsfuse-1.2.0 |& tee -a ~/logs.txt
fi

# verify old version installation
gcsfuse --version |& tee version.txt
installed_version=$(echo $(sed -n 1p version.txt) | cut -d' ' -f3)
if [ $installed_version == "0.42.5" ]; then
echo "GCSFuse old version (0.42.5) installed successfully" &>> ~/logs.txt
else
echo "Failure detected in GCSFuse old version installation." &>> ~/logs.txt
fi
# verify old version installation
gcsfuse --version |& tee version.txt
installed_version=$(echo $(sed -n 1p version.txt) | cut -d' ' -f3)
if [ $installed_version == "1.2.0" ]; then
echo "GCSFuse old version (1.2.0) installed successfully" &>> ~/logs.txt
else
echo "Failure detected in GCSFuse old version installation." &>> ~/logs.txt
fi

# Upgrade gcsfuse to latest version
if grep -q ubuntu details.txt || grep -q debian details.txt;
then
sudo apt install --only-upgrade gcsfuse |& tee -a ~/logs.txt
sudo apt-get install --only-upgrade gcsfuse |& tee -a ~/logs.txt
else
if grep -q centos-7 details.txt || grep -q rhel-7 details.txt; then
sudo yum -y upgrade gcsfuse |& tee -a ~/logs.txt
else
sudo dnf -y upgrade gcsfuse |& tee -a ~/logs.txt
fi
sudo yum -y upgrade gcsfuse |& tee -a ~/logs.txt
fi

gcsfuse --version |& tee version.txt
Expand All @@ -140,3 +102,4 @@ else
fi

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 9ddc828

Please sign in to comment.