Merge pull request #881 from harshavardhana/pr_out_remove_cp_and_sync_tests_for_now_bring_them_back_with_console_test_additionally_close_datafp_inside_session_close_
Remove cp and sync tests for now, bring them back with console.Test, additionally close DataFP inside session.Close()
This commit is contained in:
-190
@@ -1,190 +0,0 @@
|
||||
/*
|
||||
* Minio Client (C) 2015 Minio, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
/*
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
. "github.com/minio/check"
|
||||
)
|
||||
|
||||
var barCp barSend
|
||||
|
||||
func (s *CmdTestSuite) TestCpTypeA(c *C) {
|
||||
/// filesystem
|
||||
source, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(source)
|
||||
|
||||
cps, err := newSession()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
sourcePath := filepath.Join(source, "object1")
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
err = putTarget(sourcePath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
target, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(target)
|
||||
targetPath := filepath.Join(target, "newObject1")
|
||||
|
||||
cps.URLs = append(cps.URLs, sourcePath)
|
||||
cps.URLs = append(cps.URLs, targetPath)
|
||||
for err := range doCopyCmdSession(barCp, cps) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
cps, err = newSession()
|
||||
c.Assert(err, IsNil)
|
||||
targetURL := server.URL + "/bucket/newObject"
|
||||
|
||||
cps.URLs = append(cps.URLs, sourcePath)
|
||||
cps.URLs = append(cps.URLs, targetURL)
|
||||
for err := range doCopyCmdSession(barCp, cps) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestCpTypeB(c *C) {
|
||||
/// filesystem
|
||||
source, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(source)
|
||||
|
||||
sourcePath := filepath.Join(source, "object1")
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
err = putTarget(sourcePath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
target, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(target)
|
||||
|
||||
cps, err := newSession()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
cps.URLs = append(cps.URLs, sourcePath)
|
||||
cps.URLs = append(cps.URLs, target)
|
||||
for err := range doCopyCmdSession(barCp, cps) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
cps, err = newSession()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
targetURL := server.URL + "/bucket"
|
||||
cps.URLs = append(cps.URLs, sourcePath)
|
||||
cps.URLs = append(cps.URLs, targetURL)
|
||||
for err := range doCopyCmdSession(barCp, cps) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestCpTypeC(c *C) {
|
||||
/// filesystem
|
||||
source, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(source)
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
objectPath := filepath.Join(source, "object"+strconv.Itoa(i))
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
err = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
target, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(target)
|
||||
|
||||
cps, err := newSession()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
cps.URLs = append(cps.URLs, source+"...")
|
||||
cps.URLs = append(cps.URLs, target)
|
||||
for err := range doCopyCmdSession(barCp, cps) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
cps, err = newSession()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
cps.URLs = append(cps.URLs, source+"...")
|
||||
cps.URLs = append(cps.URLs, server.URL+"/bucket")
|
||||
for err := range doCopyCmdSession(barCp, cps) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestCpTypeD(c *C) {
|
||||
/// filesystem
|
||||
source1, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
source2, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(source1)
|
||||
defer os.RemoveAll(source2)
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
objectPath := filepath.Join(source1, "object"+strconv.Itoa(i))
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
err = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
for i := 10; i < 20; i++ {
|
||||
objectPath := filepath.Join(source2, "object"+strconv.Itoa(i))
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
err = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
target, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(target)
|
||||
|
||||
cps, err := newSession()
|
||||
c.Assert(err, IsNil)
|
||||
cps.URLs = append(cps.URLs, source1+"...")
|
||||
cps.URLs = append(cps.URLs, source2+"...")
|
||||
cps.URLs = append(cps.URLs, target)
|
||||
for err := range doCopyCmdSession(barCp, cps) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
cps, err = newSession()
|
||||
c.Assert(err, IsNil)
|
||||
targetURL := server.URL + "/bucket"
|
||||
cps.URLs = append(cps.URLs, source1+"...")
|
||||
cps.URLs = append(cps.URLs, source2+"...")
|
||||
cps.URLs = append(cps.URLs, targetURL)
|
||||
for err := range doCopyCmdSession(barCp, cps) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -35,6 +35,12 @@ func checkConfig() {
|
||||
console.Fatalf("Unable to determine current user. %s\n", err)
|
||||
}
|
||||
|
||||
if !isSessionDirExists() {
|
||||
if err := createSessionDir(); err != nil {
|
||||
console.Fatalf("Unable to create session directory. %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
// If config doesn't exist, do not attempt to read it
|
||||
if !isMcConfigExists() {
|
||||
return
|
||||
@@ -45,6 +51,7 @@ func checkConfig() {
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to read config file. %s\n", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Get os/arch/platform specific information.
|
||||
|
||||
+6
-8
@@ -63,17 +63,10 @@ type sessionV2 struct {
|
||||
|
||||
// provides a new session
|
||||
func newSessionV2() *sessionV2 {
|
||||
// TODO: Blindly create .mc and session dirs at init and remove these checks -ab.
|
||||
if !isMcConfigExists() {
|
||||
console.Fatalf("Please run \"mc config generate\". %s\n", errNotConfigured{})
|
||||
}
|
||||
|
||||
if !isSessionDirExists() {
|
||||
if err := createSessionDir(); err != nil {
|
||||
console.Fatalf("Unable to create session directory. %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
s := &sessionV2{}
|
||||
s.Header = &sessionV2Header{}
|
||||
s.Header.Version = "1.1.0"
|
||||
@@ -146,7 +139,12 @@ func (s *sessionV2) Close() error {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
||||
err := os.Remove(getSessionDataFile(s.SessionID))
|
||||
err := s.DataFP.Close()
|
||||
if err != nil {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
|
||||
err = os.Remove(getSessionDataFile(s.SessionID))
|
||||
if err != nil {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ func (s *CmdTestSuite) TestSession(c *C) {
|
||||
c.Assert(isSessionDirExists(), Equals, true)
|
||||
|
||||
session := newSessionV2()
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(session.Header.CommandArgs, IsNil)
|
||||
c.Assert(len(session.SessionID), Equals, 8)
|
||||
|
||||
|
||||
-153
@@ -1,153 +0,0 @@
|
||||
/*
|
||||
* Minio Client (C) 2015 Minio, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
/*
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
. "github.com/minio/check"
|
||||
)
|
||||
|
||||
var barSync barSend
|
||||
|
||||
func (s *CmdTestSuite) TestSyncTypeA(c *C) {
|
||||
/// filesystem
|
||||
source, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(source)
|
||||
|
||||
sourcePath := filepath.Join(source, "object1")
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
err = putTarget(sourcePath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
target, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(target)
|
||||
targetPath := filepath.Join(target, "newObject1")
|
||||
|
||||
ss, err := newSession()
|
||||
c.Assert(err, IsNil)
|
||||
ss.URLs = append(ss.URLs, sourcePath)
|
||||
ss.URLs = append(ss.URLs, targetPath)
|
||||
for err := range doSyncCmdSession(barSync, ss) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
ss, err = newSession()
|
||||
c.Assert(err, IsNil)
|
||||
targetURL := server.URL + "/bucket/newObject"
|
||||
ss.URLs = append(ss.URLs, sourcePath)
|
||||
ss.URLs = append(ss.URLs, targetURL)
|
||||
for err := range doSyncCmdSession(barSync, ss) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestSyncTypeB(c *C) {
|
||||
/// filesystem
|
||||
source, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(source)
|
||||
|
||||
sourcePath := filepath.Join(source, "object1")
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
err = putTarget(sourcePath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
target, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(target)
|
||||
|
||||
ss, err := newSession()
|
||||
c.Assert(err, IsNil)
|
||||
ss.URLs = append(ss.URLs, sourcePath)
|
||||
ss.URLs = append(ss.URLs, target)
|
||||
for err := range doSyncCmdSession(barSync, ss) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
ss, err = newSession()
|
||||
c.Assert(err, IsNil)
|
||||
targetURL := server.URL + "/bucket"
|
||||
ss.URLs = append(ss.URLs, sourcePath)
|
||||
ss.URLs = append(ss.URLs, targetURL)
|
||||
for err := range doSyncCmdSession(barSync, ss) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CmdTestSuite) TestSyncTypeC(c *C) {
|
||||
/// filesystem
|
||||
source, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(source)
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
objectPath := filepath.Join(source, "object"+strconv.Itoa(i))
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
err = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
target, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(target)
|
||||
|
||||
ss, err := newSession()
|
||||
c.Assert(err, IsNil)
|
||||
ss.URLs = append(ss.URLs, source+"...")
|
||||
ss.URLs = append(ss.URLs, target)
|
||||
for err := range doSyncCmdSession(barSync, ss) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
targetURL := server.URL + "/bucket"
|
||||
ss, err = newSession()
|
||||
c.Assert(err, IsNil)
|
||||
ss.URLs = append(ss.URLs, source+"...")
|
||||
ss.URLs = append(ss.URLs, targetURL)
|
||||
for err := range doSyncCmdSession(barSync, ss) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
target1, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(target1)
|
||||
|
||||
target2, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(target2)
|
||||
|
||||
ss, err = newSession()
|
||||
c.Assert(err, IsNil)
|
||||
ss.URLs = append(ss.URLs, source+"...")
|
||||
ss.URLs = append(ss.URLs, target1)
|
||||
ss.URLs = append(ss.URLs, target2)
|
||||
for err := range doSyncCmdSession(barSync, ss) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user