-
Notifications
You must be signed in to change notification settings - Fork 50
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
Test for Worm Mode Introduced #277
Conversation
127f510
to
a3c64f4
Compare
3f6ba90
to
88858e4
Compare
this needs |
6717c22
to
294c24c
Compare
run/core/worm/quick-worm-tests.go
Outdated
startTime := time.Now() | ||
object := "testObject" | ||
function := "PutAndDelete" | ||
bucket := randString(60, rand.NewSource(time.Now().UnixNano()), "worm-mode-test-") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could have only one random source than creating every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code modified
run/core/worm/quick-worm-tests.go
Outdated
remain-- | ||
} | ||
return prefix + string(b[0:30-len(prefix)]) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below code is much simpler than this
const charset = "abcdefghijklmnopqrstuvwxyz0123456789"
var randSource *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano()))
func randBucketName() string {
const length = 55
b := make([]byte, length)
for i := range b {
b[i] = charset[randSource.Intn(len(charset))]
}
return "bucket-" + string(b)
}
and it can be used as
bucketName := randBucketName()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used the above given code.
run/core/worm/quick-worm-tests.go
Outdated
maxRetries = 1 | ||
) | ||
|
||
type ErrorResponse struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this type used anywhere?
run/core/worm/quick-worm-tests.go
Outdated
@@ -0,0 +1,434 @@ | |||
/* | |||
* | |||
* Mint, (C) 2017 Minio, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(C) 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the blank space.
mint.sh
Outdated
exit 1 | ||
fi | ||
|
||
if [ "$MINT_MODE" = "worm" ];then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its not required to print mode specific here because user runs with worm mode, not by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed worm specific output
mint.sh
Outdated
@@ -136,14 +162,25 @@ function main() | |||
break | |||
fi | |||
done | |||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could need to format this script properly
mint.sh
Outdated
fi | ||
else | ||
# Remove worm test case | ||
for i in "${!run_list[@]}"; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could keep run_list
populated for worm mode and non-worm mode properly. There is no need to run specifically with if
block.
build/worm/install.sh
Outdated
go get -u github.com/aws/aws-sdk-go/aws/... | ||
go get -u github.com/aws/aws-sdk-go/aws/credentials/... | ||
go get -u github.com/aws/aws-sdk-go/aws/session/... | ||
go get -u github.com/aws/aws-sdk-go/service/s3/... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What package is required here? go get -u
downloads dependencies automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Point here is to have fewer (mostly one) go get -u ...
. Could you figure out and fix accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@balamurugana I will try go get -u github.com/aws/aws-sdk-go/... and confirm if it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure whether the test requires everything from github.com/aws/aws-sdk-go
. I hope you checked that. I think https://talks.golang.org/2014/organizeio.slide#1 may be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that all the dependencies are already present in install.sh of awscli thus i have removed it from worm. Please suggest if any modifications is needed for this.
@sinhaashish Travis build is failing. Can you please take a look? |
@kannappanr we need to release |
minio-go released @nitisht @sinhaashish |
@sinhaashish build works now, can you please check the review comments |
@balamurugana @nitisht please validate. Modified the mint.sh for creating scenario based runlist. |
run/core/worm/quick-worm-tests.go
Outdated
} | ||
|
||
func randBucketName() string { | ||
const length = 55 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this const is not required because its used in only one place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified.
run/core/worm/quick-worm-tests.go
Outdated
@@ -0,0 +1,410 @@ | |||
/* | |||
* Mint, (C) 2017 Minio, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is new file, you would need to set copyright to 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edited
Dockerfile.dev
Outdated
COPY remove-packages.list /mint | ||
COPY postinstall.sh /mint | ||
RUN /mint/postinstall.sh | ||
|
||
COPY mint.sh /mint/mint.sh | ||
COPY entrypoint.sh /mint/entrypoint.sh | ||
ENTRYPOINT ["/mint/entrypoint.sh"] | ||
ENTRYPOINT ["/mint/entrypoint.sh"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add newline
README.md
Outdated
```sh | ||
$ docker run -e SERVER_ENDPOINT=play.minio.io:9000 -e ACCESS_KEY=Q3AM3UQ867SPQQA43P2F \ | ||
-e SECRET_KEY=zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG -e ENABLE_HTTPS=1 -e MINT_MODE=worm minio/mint | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As below table updated with mint mode specific info, this is not required for specific about WORM mode run IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this.
README.md
Outdated
$ docker run -e SERVER_ENDPOINT=`Server End Point` -e ACCESS_KEY=`Your Access Key` \ | ||
-e SECRET_KEY=`Your Secret Key`\ | ||
-e ENABLE_HTTPS=1 -e MINT_MODE=worm minio/mint:latest | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this section of change is also not required. Developer knows how to run with various modes by looking into the above table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
mint.sh
Outdated
@@ -60,9 +61,10 @@ function run_test() | |||
start=$(date +%s) | |||
|
|||
mkdir -p "$BASE_LOG_DIR/$sdk_name" | |||
|
|||
echo "BASE_LOG_DIR :$BASE_LOG_DIR" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Overall you would need to remove your debug prints/commands.
- format the code to the standard and remove unnecessary newlines (double newlines)
mint.sh
Outdated
@@ -111,21 +114,39 @@ function main() | |||
echo "To get logs, run 'docker cp ${CONTAINER_ID}:/mint/log /tmp/mint-logs'" | |||
|
|||
declare -a run_list | |||
declare -a run_list_excluding_worm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would need to replace code block between lines 114 and 122 with below code and there is no other change required in this file.
if [ "$MINT_MODE" == "worm" ]; then
if [ "$#" -gt 1 ]; then
echo "No argument is accepted for worm mode"
exit 1
fi
run_list=( "$TEST_DIR/worm" )
else
sdks=( "$@" )
## populate all sdks except worm when no argument is given.
if [ "$#" -eq 1 ]; then
sdks=( $(ls -I worm "$TESTS_DIR") )
fi
for sdk in "${sdks[@]}"; do
if [ "$sdk" == "worm" ]; then
echo "worm test cannot be run without worm mode"
exit 1
fi
run_list=( "${run_list[@]}" "$TESTS_DIR/$sdk" )
done
fi
This is untested code.
Sorry for pasting the code. I am unable to explain the logic without the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for guiding. Please correct if i am wrong.
if condition should compare with 0 in the below code
## populate all sdks except worm when no argument is given.
if [ "$#" -eq 1 ]; then
sdks=( $(ls -I worm "$TESTS_DIR") )
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. "$#"
comes without $0
98bea2e
to
8749b78
Compare
Dockerfile.dev
Outdated
COPY remove-packages.list /mint | ||
COPY postinstall.sh /mint | ||
RUN /mint/postinstall.sh | ||
|
||
COPY mint.sh /mint/mint.sh | ||
COPY entrypoint.sh /mint/entrypoint.sh | ||
ENTRYPOINT ["/mint/entrypoint.sh"] | ||
|
||
ENTRYPOINT ["/mint/entrypoint.sh"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
run/core/worm/quick-worm-tests.go
Outdated
} | ||
_, err = s3Client.PutObject(putInput2) | ||
if err == nil { | ||
failureLog(function, args, startTime, "", fmt.Sprintf("WORM_MODE ON Put is expected to fail, but it Success %v", nil), nil).Fatal() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message can be WORM_MODE ON - Put is expected to fail, but it passed %v
in here and all the other occurrences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, works fine, one small comment pending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM & Tested
Introducing new test cases for testing server in worm mode
Test cases are added to check the worm mode of the Server