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

Fix export test esti job #7635

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .github/workflows/esti.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ jobs:
run: docker compose logs --tail=2500 lakefs

export:
if: false # TODO (niro): We need to enable this again!!!
name: Test lakeFS rclone export functionality
needs: [deploy-image, deploy-rclone-export-image, login-to-amazon-ecr]
runs-on: ubuntu-22.04
Expand Down
4 changes: 0 additions & 4 deletions test/rclone_export/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.9'
services:
postgres:
image: "postgres:11"
Expand Down Expand Up @@ -34,9 +33,6 @@ services:

lakefs-export:
image: "${REPO:-treeverse}/lakefs-rclone-export:${EXPORT_TAG:-latest}"
depends_on:
- "lakefs"
- "postgres"
profiles: ["client"]
Comment on lines -37 to -39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking on this, sharing my thoughts though:
This solves the problem, and because we run it in later steps it works to overcome the dependencies, but we regarding the docker-compose file it's wrong to remove these dependencies.
Did we try using project names?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the concern, however:

  1. I feel like we should not invest more time on this since this provides a good enough solution
  2. Lets address this when this actually becomes painful

environment:
- LAKEFS_ENDPOINT=http://lakefs:8000
Expand Down
56 changes: 27 additions & 29 deletions test/rclone_export/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,31 @@

REPOSITORY=${REPOSITORY:-example}


run_cmd_and_validate() {
echo $1
echo "Running: $2"
newVariable=$(eval $2)
if [[ $? != "0" ]]
then
echo "FAILED!" && exit 1
fi
echo "Output:"
echo $newVariable
}
Comment on lines +6 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like 😎


# Run Export without previous commit
echo "Current working directory: ${WORKING_DIRECTORY}"
echo "upload file_one"
docker compose exec -T lakefs lakectl fs upload lakefs://${REPOSITORY}/main/a/file_one.txt --source /local/file_one.txt
echo "res $?"
run_cmd_and_validate "upload file_one" "docker compose exec -T lakefs lakectl fs upload lakefs://${REPOSITORY}/main/a/file_one.txt --source /local/file_one.txt"

echo "export no previous commit"
docker compose --project-directory ${WORKING_DIRECTORY} run --rm lakefs-export ${REPOSITORY} ${EXPORT_LOCATION} --branch="main"
echo "res $?"
run_cmd_and_validate "export no previous commit" "docker compose --project-directory ${WORKING_DIRECTORY} run --rm lakefs-export ${REPOSITORY} ${EXPORT_LOCATION} --branch=main"

# Validate export
lakectl_out=$(mktemp)
s3_out=$(mktemp)
trap 'rm -f -- $s3_out $lakectl_out' INT TERM EXIT

echo "ls"
docker compose exec -T lakefs lakectl fs ls --recursive --no-color lakefs://${REPOSITORY}/main/ | awk '{print $8}' | sort > ${lakectl_out}
echo "res $?"

n=$(grep -o "/" <<< ${EXPORT_LOCATION} | wc -l)

Expand All @@ -30,37 +37,28 @@ else
n=$((n-1))
fi

echo "aws ls"
aws s3 ls --recursive ${EXPORT_LOCATION} | awk '{print $4}'| cut -d/ -f ${n}- | grep -v EXPORT_ | sort > ${s3_out}
echo "res $?"

echo $(cat $lakectl_out)
echo $(cat $s3_out)

if ! diff ${lakectl_out} ${s3_out}; then
echo "export location and lakefs should contain same objects"
exit 1
fi

# Run Export with previous commit - add file and also delete an existing file
echo "export previous commit"
docker compose exec -T lakefs lakectl fs upload lakefs://${REPOSITORY}/main/a/file_two.txt --source /local/file_two.txt
echo "res $?"
docker compose exec -T lakefs lakectl fs rm lakefs://${REPOSITORY}/main/a/file_one.txt
echo "res $?"
docker compose exec -T lakefs lakectl commit lakefs://${REPOSITORY}/main --message="removed file_one and added file_two"
echo "res $?"

docker compose --project-directory ${WORKING_DIRECTORY} run --rm lakefs-export ${REPOSITORY} ${EXPORT_LOCATION} --branch="main" --prev_commit_id="some_commit"
echo "res $?"
run_cmd_and_validate "upload file_two" "docker compose exec -T lakefs lakectl fs upload lakefs://${REPOSITORY}/main/a/file_two.txt --source /local/file_two.txt"
run_cmd_and_validate "delete file_one" "docker compose exec -T lakefs lakectl fs rm lakefs://${REPOSITORY}/main/a/file_one.txt"
run_cmd_and_validate "commit changes" "docker compose exec -T lakefs lakectl commit lakefs://${REPOSITORY}/main --message='removed file_one and added file_two'"
run_cmd_and_validate "export previous commit" "docker compose --project-directory ${WORKING_DIRECTORY} run --rm lakefs-export ${REPOSITORY} ${EXPORT_LOCATION} --branch=main --prev_commit_id='some_commit'"

# Validate sync
lakectl_out=$(mktemp)
s3_out=$(mktemp)
trap 'rm -f -- $s3_out $lakectl_out' INT TERM EXIT

echo "ls"
docker compose exec -T lakefs lakectl fs ls --recursive --no-color lakefs://${REPOSITORY}/main/ | awk '{print $8}' | sort > ${lakectl_out}
echo "res $?"

echo "aws ls"
aws s3 ls --recursive ${EXPORT_LOCATION} | awk '{print $4}'| cut -d/ -f ${n}- | grep -v EXPORT_ | sort > ${s3_out}

if ! diff ${lakectl_out} ${s3_out}; then
Expand All @@ -69,13 +67,13 @@ if ! diff ${lakectl_out} ${s3_out}; then
fi

# Run Export with commit_id reference
echo "export with commit_id"
docker compose exec -T lakefs lakectl fs upload lakefs://${REPOSITORY}/main/a/file_three.txt --source /local/file_three.txt
echo "res $?"
run_cmd_and_validate "upload file_three" "docker compose exec -T lakefs lakectl fs upload lakefs://${REPOSITORY}/main/a/file_three.txt --source /local/file_three.txt"

commit_id=$(docker compose exec -T lakefs lakectl commit lakefs://${REPOSITORY}/main --message="added file_three" | sed -n 4p | awk '{print $2}')

docker compose --project-directory ${WORKING_DIRECTORY} run --rm lakefs-export ${REPOSITORY} ${EXPORT_LOCATION} --commit_id="$commit_id"
echo "res $?"
# We should not validate the exit code - since it is erroneous
echo "run export"
docker compose --project-directory ${WORKING_DIRECTORY} run --rm lakefs-export ${REPOSITORY} ${EXPORT_LOCATION} --commit_id=$commit_id

echo "commit_id $commit_id"

Expand Down
Loading