Skip to content

Commit 156da5f

Browse files
nitishtpoornas
authored andcommitted
Added mc and init directories. (#1)
1 parent 4dc6652 commit 156da5f

File tree

10 files changed

+295
-5
lines changed

10 files changed

+295
-5
lines changed

Apps/init/initCheck.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package main
2+
3+
/*
4+
* Minio Cloud Storage, (C) 2017 Minio, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import (
20+
"log"
21+
"os"
22+
23+
"github.com/minio/minio/pkg/madmin"
24+
)
25+
26+
func main() {
27+
endpoint := os.Getenv("S3_ADDRESS")
28+
accessKeyID := os.Getenv("ACCESS_KEY")
29+
secretAccessKey := os.Getenv("SECRET_KEY")
30+
useSSL := false
31+
// check if ENABLE_HTTPS env flag is set.
32+
if os.Getenv("ENABLE_HTTPS") != "" {
33+
useSSL = true
34+
}
35+
36+
madmClnt, err := madmin.New(endpoint, accessKeyID, secretAccessKey, useSSL)
37+
if err != nil {
38+
addErrorLog(err.Error())
39+
os.Exit(1)
40+
}
41+
42+
// check the status of the Minio server.
43+
_, err = madmClnt.ServiceStatus()
44+
if err != nil {
45+
addErrorLog(err.Error())
46+
os.Exit(1)
47+
}
48+
49+
// log the success message.
50+
addRunLog("Target server: " + endpoint + " is reachable. Starting the tests...")
51+
}
52+
53+
func addErrorLog(message string) {
54+
errorLogFile := os.Getenv("INIT_ERROR_LOG_FILE")
55+
file, err := os.OpenFile(errorLogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) // For read access.
56+
if err != nil {
57+
log.Fatal(err)
58+
}
59+
defer file.Close()
60+
61+
// write the log to file
62+
log.SetOutput(file)
63+
log.Println(message)
64+
}
65+
66+
func addRunLog(message string) {
67+
logFile := os.Getenv("INIT_LOG_FILE")
68+
file, err := os.OpenFile(logFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) // For read access.
69+
if err != nil {
70+
log.Fatal(err)
71+
}
72+
defer file.Close()
73+
74+
// write the log to file
75+
log.SetOutput(file)
76+
log.Println(message)
77+
}

Apps/init/run.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/sh
2+
#
3+
# Minio Cloud Storage, (C) 2017 Minio, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# Add Run instructions for SDK tests here.
19+
# The Build instructions should be added to build.sh
20+
21+
setLogEnv() {
22+
export INIT_LOG_DIRECTORY=$(echo $LOG_DIRECTORY/${PWD##*/})
23+
export INIT_ERROR_LOG_FILE=$(echo $INIT_LOG_DIRECTORY/"error.log")
24+
export INIT_LOG_FILE=$(echo $INIT_LOG_DIRECTORY/"run.log")
25+
}
26+
27+
prepareLogDir() {
28+
# clear old logs
29+
rm -r echo $INIT_LOG_DIRECTORY 2> /dev/null
30+
31+
# create log directory
32+
mkdir $INIT_LOG_DIRECTORY 2> /dev/null
33+
34+
# create log files
35+
touch $INIT_ERROR_LOG_FILE
36+
touch $INIT_LOG_FILE
37+
}
38+
39+
initCheck() {
40+
# Get minio admin package
41+
go get -u github.com/minio/minio/pkg/madmin
42+
43+
# Build the endpoint checker program.
44+
go build initCheck.go
45+
46+
# This is to avoid https://github.com/docker/docker/issues/9547
47+
sync
48+
49+
# Run the check
50+
./initCheck
51+
}
52+
53+
# Set log folders
54+
setLogEnv
55+
56+
# Create log folders
57+
prepareLogDir
58+
59+
# Run the init tests
60+
initCheck

Apps/mc/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## `mc` tests.
2+
This directory serves as the location for Mint tests using `mc`. To add new test case to Mint `mc` app, just add new method in the `test.sh` file.
3+
4+
- `mc` is already configured to point to alias `target` that points to the endpoint this Mint instance is testing.
5+
- `run.sh` script runs all the test cases.
6+
- A normal response should be redirected to `$MC_LOG_FILE`, and error response should be redirected to `$MC_ERROR_LOG_FILE`.
7+
- Do not proceed to next testcase in case of an error.

Apps/mc/run.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/sh
2+
#
3+
# Minio Cloud Storage, (C) 2017 Minio, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
setLogEnv() {
19+
export MC_LOG_DIRECTORY=$(echo $LOG_DIRECTORY/${PWD##*/})
20+
export MC_ERROR_LOG_FILE=$(echo $MC_LOG_DIRECTORY/"error.log")
21+
export MC_LOG_FILE=$(echo $MC_LOG_DIRECTORY/"run.log")
22+
23+
if [ $ENABLE_HTTPS -eq "1" ]; then
24+
export TARGET_ADDRESS_WITH_PROTOCOL="https://"$S3_ADDRESS
25+
else
26+
export TARGET_ADDRESS_WITH_PROTOCOL="http://"$S3_ADDRESS
27+
fi
28+
}
29+
30+
prepareLogDir() {
31+
# clear old logs
32+
rm -r echo $MC_LOG_DIRECTORY 2> /dev/null
33+
34+
# create log directory
35+
mkdir $MC_LOG_DIRECTORY 2> /dev/null
36+
37+
# create log files
38+
touch $MC_ERROR_LOG_FILE
39+
touch $MC_LOG_FILE
40+
}
41+
42+
cleanUP(){
43+
# remove mc
44+
rm mc
45+
}
46+
47+
downloadMC() {
48+
# Download latest MC release
49+
curl -s -o mc https://dl.minio.io/client/mc/release/linux-amd64/mc
50+
res=$?
51+
if test "$res" != "0"; then
52+
echo "curl command to download mc failed with: $res" >> $MC_ERROR_LOG_FILE
53+
exit 1
54+
else
55+
chmod +x ./mc
56+
echo "Downloaded mc $(./mc version | grep Version)" >> $MC_LOG_FILE
57+
echo "Adding mc host alias target $TARGET_ADDRESS_WITH_PROTOCOL" >> $MC_LOG_FILE
58+
./mc config host add target $TARGET_ADDRESS_WITH_PROTOCOL $ACCESS_KEY $SECRET_KEY >> $MC_LOG_FILE
59+
fi
60+
}
61+
62+
# Execute test.sh
63+
runMCTests() {
64+
./test.sh
65+
}
66+
67+
# Setup log directories
68+
setLogEnv
69+
70+
# Create the log dir and files
71+
prepareLogDir
72+
73+
# Download and add alias target pointing to the server under test
74+
downloadMC
75+
76+
# run the tests
77+
runMCTests
78+
79+
# Remove mc binary
80+
cleanUP
81+

Apps/mc/test.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
#
3+
# Minio Cloud Storage, (C) 2017 Minio, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
createBuckets_01(){
19+
echo "Running createBuckets_01" >> $MC_LOG_FILE
20+
./mc mb target/testbucket1 | grep "<ERROR>" >> $MC_ERROR_LOG_FILE
21+
}

Apps/minio-java/FunctionalTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
/*
3-
* Minio Java SDK for Amazon S3 Compatible Cloud Storage,
4-
* (C) 2015, 2016, 2017 Minio, Inc.
3+
* Minio Cloud Storage, (C) 2017 Minio, Inc.
54
*
65
* Licensed under the Apache License, Version 2.0 (the "License");
76
* you may not use this file except in compliance with the License.

Apps/minio-java/run.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
#!/usr/bin/env bash
2-
#!/usr/bin/expect -f
1+
#!/bin/sh
2+
#
3+
# Minio Cloud Storage, (C) 2017 Minio, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
317

418
# settings / change this to your config
519
ROOT_DIR=$1

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1+
FROM golang:1.7-alpine
12

3+
COPY . /home
4+
5+
WORKDIR /home
6+
7+
# Install commonly used dependencies here.
8+
# Any unique dependencies can be installed in respective build.sh files
9+
10+
RUN \
11+
apk add --no-cache bash git openssh mailcap curl && \
12+
go get -u github.com/minio/minio-go && \
13+
chmod +x run.sh
14+
15+
CMD ./run.sh
216

config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Apps:
2+
- init
3+
- mc
24
- minio-py
35
- minio-go
46
- minio-java

run.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
#!/usr/bin/env bash
1+
#!/bin/sh
2+
#
3+
# Minio Cloud Storage, (C) 2017 Minio, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
217

318
ROOT_DIR="$PWD"
419
TEST_DIR="Apps"

0 commit comments

Comments
 (0)