Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding changes to run integration and perf tests with label #1283

Merged
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7375bbb
adding changes to separate integration tests and perf tests
Tulsishah Aug 16, 2023
963dc3b
fix braces error
Tulsishah Aug 16, 2023
34adce8
fix random string error
Tulsishah Aug 16, 2023
3251acb
testing
Tulsishah Aug 16, 2023
339fdff
remove changes
Tulsishah Aug 16, 2023
e28d48d
merge
Tulsishah Aug 17, 2023
9e148e2
merge
Tulsishah Aug 17, 2023
ec3c727
merge
Tulsishah Aug 17, 2023
7ae81ca
fixing comments
Tulsishah Aug 17, 2023
fae77c9
fixing comments
Tulsishah Aug 17, 2023
c4fe28f
fixing comments
Tulsishah Aug 17, 2023
4784a2e
fixing comments
Tulsishah Aug 17, 2023
8b50951
testing
Tulsishah Aug 17, 2023
e7c24e3
testing
Tulsishah Aug 17, 2023
d8f8adb
echo bucket name
Tulsishah Aug 17, 2023
259d4c9
testing by adding git stash
Tulsishah Aug 17, 2023
574b602
removing testing commanda
Tulsishah Aug 17, 2023
32ebde6
testing by adding git stash
Tulsishah Aug 17, 2023
4aa5607
testing by adding git stash
Tulsishah Aug 17, 2023
1512f0f
testing by adding git stash
Tulsishah Aug 17, 2023
bfcce12
testing by adding git stash
Tulsishah Aug 17, 2023
2f66445
testing kokoro
Tulsishah Aug 17, 2023
0367164
testing kokoro
Tulsishah Aug 17, 2023
0ca3240
testing kokoro
Tulsishah Aug 17, 2023
38d0508
testing kokoro
Tulsishah Aug 17, 2023
b29a5e6
undo testing changes
Tulsishah Aug 17, 2023
1ffb4e9
fixing comment
Tulsishah Aug 17, 2023
8434972
testing with both the labels
Tulsishah Aug 17, 2023
3a8818c
removing testing changes
Tulsishah Aug 17, 2023
b209a53
removing comment
Tulsishah Aug 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 81 additions & 46 deletions perfmetrics/scripts/presubmit_test/pr_perf_test/build.sh
Original file line number Diff line number Diff line change
@@ -1,69 +1,104 @@
#!/bin/bash
# Running test only for when PR contains execute-perf-test label
# Running test only for when PR contains execute-perf-test or execute-integration-tests label
readonly EXECUTE_PERF_TEST_LABEL="execute-perf-test"
readonly EXECUTE_INTEGRATION_TEST_LABEL="execute-integration-tests"
readonly INTEGRATION_TEST_EXECUTION_TIME=24m

curl https://api.github.com/repos/GoogleCloudPlatform/gcsfuse/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER >> pr.json
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved
perfTest=$(cat pr.json | grep "execute-perf-test")
perfTest=$(cat pr.json | grep $EXECUTE_PERF_TEST_LABEL)
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved
integrationTests=$(cat pr.json | grep $EXECUTE_INTEGRATION_TEST_LABEL)
rm pr.json
perfTestStr="$perfTest"
if [[ "$perfTestStr" != *"execute-perf-test"* ]]
integrationTestsStr="$integrationTests"
if [[ "$perfTestStr" != *$EXECUTE_PERF_TEST_LABEL* && "$integrationTestsStr" != *$EXECUTE_INTEGRATION_TEST_LABEL* ]]
gargnitingoogle marked this conversation as resolved.
Show resolved Hide resolved
then
echo "No need to execute tests"
exit 0
fi

# It will take approx 80 minutes to run the script.
set -e
# It will take approx 80 minutes to run the script.
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved
sudo apt-get update
echo Installing git
sudo apt-get install git
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved
echo Installing python3-pip
sudo apt-get -y install python3-pip
echo Installing libraries to run python script
pip install google-cloud
pip install google-cloud-vision
pip install google-api-python-client
pip install prettytable
echo Installing go-lang 1.20.5
wget -O go_tar.tar.gz https://go.dev/dl/go1.20.5.linux-amd64.tar.gz
wget -O go_tar.tar.gz https://go.dev/dl/go1.20.5.linux-amd64.tar.gz -q
sudo rm -rf /usr/local/go && tar -xzf go_tar.tar.gz && sudo mv go /usr/local
export PATH=$PATH:/usr/local/go/bin
echo Installing fio
sudo apt-get install fio -y

# Run on master branch
export CGO_ENABLED=0
cd "${KOKORO_ARTIFACTS_DIR}/github/gcsfuse"
git checkout master
echo Mounting gcs bucket for master branch
mkdir -p gcs
GCSFUSE_FLAGS="--implicit-dirs --max-conns-per-host 100"
BUCKET_NAME=presubmit-perf-tests
MOUNT_POINT=gcs
# The VM will itself exit if the gcsfuse mount fails.
CGO_ENABLED=0 go run . $GCSFUSE_FLAGS $BUCKET_NAME $MOUNT_POINT
touch result.txt
# Running FIO test
chmod +x perfmetrics/scripts/presubmit/run_load_test_on_presubmit.sh
./perfmetrics/scripts/presubmit/run_load_test_on_presubmit.sh
sudo umount gcs

# Fetch PR branch
echo '[remote "origin"]
fetch = +refs/pull/*/head:refs/remotes/origin/pr/*' >> .git/config
git fetch origin
echo checkout PR branch
git checkout pr/$KOKORO_GITHUB_PULL_REQUEST_NUMBER
git fetch origin -q

function execute_perf_test() {
mkdir -p gcs
GCSFUSE_FLAGS="--implicit-dirs --max-conns-per-host 100"
BUCKET_NAME=presubmit-perf-tests
MOUNT_POINT=gcs
# The VM will itself exit if the gcsfuse mount fails.
go run . $GCSFUSE_FLAGS $BUCKET_NAME $MOUNT_POINT
# Running FIO test
chmod +x perfmetrics/scripts/presubmit/run_load_test_on_presubmit.sh
./perfmetrics/scripts/presubmit/run_load_test_on_presubmit.sh
sudo umount gcs
}

# execute perf tests.
if [[ "$perfTestStr" == *$EXECUTE_PERF_TEST_LABEL* ]];
then
# Installing requirements
echo Installing python3-pip
sudo apt-get -y install python3-pip
echo Installing libraries to run python script
pip install google-cloud
pip install google-cloud-vision
pip install google-api-python-client
pip install prettytable
echo Installing fio
sudo apt-get install fio -y

# Executing integration tests
GODEBUG=asyncpreemptoff=1 CGO_ENABLED=0 go test ./tools/integration_tests/... -p 1 --integrationTest -v --testbucket=gcsfuse-integration-test -timeout 24m
# Executing perf tests for master branch
git checkout master
# Store results
touch result.txt
echo Mounting gcs bucket for master branch and execute tests
execute_perf_test

# Executing perf tests
echo Mounting gcs bucket from pr branch
mkdir -p gcs
# The VM will itself exit if the gcsfuse mount fails.
CGO_ENABLED=0 go run . $GCSFUSE_FLAGS $BUCKET_NAME $MOUNT_POINT
# Running FIO test
chmod +x perfmetrics/scripts/presubmit/run_load_test_on_presubmit.sh
./perfmetrics/scripts/presubmit/run_load_test_on_presubmit.sh
sudo umount gcs

echo showing results...
python3 ./perfmetrics/scripts/presubmit/print_results.py
# Executing perf tests for PR branch
echo checkout PR branch
git checkout pr/$KOKORO_GITHUB_PULL_REQUEST_NUMBER
echo Mounting gcs bucket from pr branch and execute tests
execute_perf_test

# Show results
echo showing results...
python3 ./perfmetrics/scripts/presubmit/print_results.py
fi

# Execute integration tests.
if [[ "$integrationTestsStr" == *$EXECUTE_INTEGRATION_TEST_LABEL* ]];
then
echo checkout PR branch
git checkout pr/$KOKORO_GITHUB_PULL_REQUEST_NUMBER
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved

# Create bucket for integration tests.
# The prefix for the random string
bucketPrefix="gcsfuse-integration-test-"
# The length of the random string
length=5
raj-prince marked this conversation as resolved.
Show resolved Hide resolved
# Generate the random string
random_string=$(tr -dc 'a-z0-9' < /dev/urandom | head -c $length)
BUCKET_NAME=$bucketPrefix$random_string
echo bucket name
gargnitingoogle marked this conversation as resolved.
Show resolved Hide resolved
echo $BUCKET_NAME
gcloud alpha storage buckets create gs://$BUCKET_NAME --project=gcs-fuse-test-ml --location=us-west1 --uniform-bucket-level-access
Tulsishah marked this conversation as resolved.
Show resolved Hide resolved

# Executing integration tests
GODEBUG=asyncpreemptoff=1 go test ./tools/integration_tests/... -p 1 --integrationTest -v --testbucket=$BUCKET_NAME -timeout $INTEGRATION_TEST_EXECUTION_TIME

# Delete bucket after testing.
gcloud alpha storage rm --recursive gs://$BUCKET_NAME/
fi