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

Test for Worm Mode Introduced #277

Merged
merged 1 commit into from
Jun 14, 2018
Merged

Test for Worm Mode Introduced #277

merged 1 commit into from
Jun 14, 2018

Conversation

sinhaashish
Copy link

Test cases are added to check the worm mode of the Server

@sinhaashish sinhaashish force-pushed the onetest branch 3 times, most recently from 127f510 to a3c64f4 Compare May 18, 2018 18:50
@sinhaashish sinhaashish force-pushed the onetest branch 3 times, most recently from 3f6ba90 to 88858e4 Compare May 19, 2018 02:21
@nitisht
Copy link
Contributor

nitisht commented May 22, 2018

this needs minio-go release for Travis/Mint build to work

@sinhaashish sinhaashish force-pushed the onetest branch 2 times, most recently from 6717c22 to 294c24c Compare May 23, 2018 02:54
startTime := time.Now()
object := "testObject"
function := "PutAndDelete"
bucket := randString(60, rand.NewSource(time.Now().UnixNano()), "worm-mode-test-")
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

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

code modified

remain--
}
return prefix + string(b[0:30-len(prefix)])
}
Copy link
Member

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()

Copy link
Author

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.

maxRetries = 1
)

type ErrorResponse struct {
Copy link
Member

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?

@@ -0,0 +1,434 @@
/*
*
* Mint, (C) 2017 Minio, Inc.
Copy link
Member

Choose a reason for hiding this comment

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

(C) 2018

Copy link
Author

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
Copy link
Member

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.

Copy link
Author

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
Copy link
Member

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
Copy link
Member

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.

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/...
Copy link
Member

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.

Copy link
Member

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?

Copy link
Author

@sinhaashish sinhaashish Jun 12, 2018

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.

Copy link
Member

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.

Copy link
Author

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.

@kannappanr
Copy link
Collaborator

@sinhaashish Travis build is failing. Can you please take a look?

@nitisht
Copy link
Contributor

nitisht commented May 29, 2018

@kannappanr we need to release minio-go for Travis build fix

@harshavardhana
Copy link
Member

@kannappanr we need to release minio-go for Travis build fix

minio-go released @nitisht @sinhaashish

@nitisht
Copy link
Contributor

nitisht commented May 30, 2018

@sinhaashish build works now, can you please check the review comments

@sinhaashish
Copy link
Author

@balamurugana @nitisht please validate. Modified the mint.sh for creating scenario based runlist.

}

func randBucketName() string {
const length = 55
Copy link
Member

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

Copy link
Author

Choose a reason for hiding this comment

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

modified.

@@ -0,0 +1,410 @@
/*
* Mint, (C) 2017 Minio, Inc.
Copy link
Member

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

Copy link
Author

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"]
Copy link
Member

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
```
Copy link
Member

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

Copy link
Author

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
```
Copy link
Member

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

Copy link
Author

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"
Copy link
Member

Choose a reason for hiding this comment

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

  1. Overall you would need to remove your debug prints/commands.
  2. 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
Copy link
Member

@balamurugana balamurugana Jun 3, 2018

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.

Copy link
Author

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

Copy link
Member

Choose a reason for hiding this comment

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

Yep. "$#" comes without $0

@sinhaashish sinhaashish force-pushed the onetest branch 5 times, most recently from 98bea2e to 8749b78 Compare June 6, 2018 05:10
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"]
Copy link
Contributor

Choose a reason for hiding this comment

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

add new line

Copy link
Author

Choose a reason for hiding this comment

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

done

}
_, 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()
Copy link
Contributor

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.

Copy link
Contributor

@nitisht nitisht left a 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

Copy link
Contributor

@nitisht nitisht left a 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
@nitisht nitisht merged commit a05cf19 into minio:master Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants