Skip to content

Commit ebace8c

Browse files
authored
fix: grep seaweedfs bucket name instead of using awk (#4076)
* fix: grep seaweedfs bucket name instead of using awk Closes #4075 * fix: inverted logic gate * chore: file permission
1 parent d53bad5 commit ebace8c

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
source _unit-test/_test_setup.sh
4+
source install/dc-detect-version.sh
5+
source install/create-docker-volumes.sh
6+
7+
start_service_and_wait_ready seaweedfs
8+
9+
$dcx seaweedfs apk add --no-cache s3cmd
10+
s3cmd="$dc exec seaweedfs s3cmd"
11+
12+
# Create multiple buckets for testing
13+
buckets=(bucket1 bucket2 bucket3)
14+
for bucket in "${buckets[@]}"; do
15+
$s3cmd --access_key=sentry --secret_key=sentry --no-ssl --region=us-east-1 --host=localhost:8333 --host-bucket='localhost:8333/%(bucket)' mb s3://$bucket
16+
done
17+
18+
# Verify that all buckets were created successfully
19+
bucket_list=$($s3cmd --access_key=sentry --secret_key=sentry --no-ssl --region=us-east-1 --host=localhost:8333 --host-bucket='localhost:8333/%(bucket)' ls)
20+
for bucket in "${buckets[@]}"; do
21+
if ! echo "$bucket_list" | grep -q "s3://$bucket"; then
22+
echo "Error: Bucket s3://$bucket was not created successfully."
23+
exit 1
24+
fi
25+
done
26+
27+
# Can find "bucket2"
28+
if ! echo "$bucket_list" | grep -q "s3://bucket2"; then
29+
echo "Error: Bucket s3://bucket2 was not found."
30+
exit 1
31+
fi
32+
33+
# Can't find "bucket5", should not exist
34+
if echo "$bucket_list" | grep -q "s3://bucket5"; then
35+
echo "Error: Bucket s3://bucket5 should not exist."
36+
exit 1
37+
fi
38+
39+
report_success

install/bootstrap-s3-nodestore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ s3cmd="$dc exec seaweedfs s3cmd"
77

88
bucket_list=$($s3cmd --access_key=sentry --secret_key=sentry --no-ssl --region=us-east-1 --host=localhost:8333 --host-bucket='localhost:8333/%(bucket)' ls)
99

10-
if [[ $(echo "$bucket_list" | tail -1 | awk '{print $3}') != 's3://nodestore' ]]; then
10+
if ! echo "$bucket_list" | grep -q "s3://nodestore"; then
1111
apply_config_changes_nodestore=0
1212
# Only touch if no existing nodestore config is found
1313
if ! grep -q "SENTRY_NODESTORE" $SENTRY_CONFIG_PY; then

install/bootstrap-s3-profiles.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if [[ "$COMPOSE_PROFILES" == "feature-complete" ]]; then
1919

2020
bucket_list=$($s3cmd --access_key=sentry --secret_key=sentry --no-ssl --region=us-east-1 --host=localhost:8333 --host-bucket='localhost:8333/%(bucket)' ls)
2121

22-
if [[ $(echo "$bucket_list" | tail -1 | awk '{print $3}') != 's3://profiles' ]]; then
22+
if ! echo "$bucket_list" | grep -q "s3://profiles"; then
2323
apply_config_changes_profiles=0
2424
# Only touch if no existing profiles config is found
2525
if ! grep -q "filestore.profiles-backend" $SENTRY_CONFIG_YML; then

0 commit comments

Comments
 (0)