@@ -1744,7 +1744,7 @@ func TestCopyVolume(t *testing.T) {
1744
1744
ctx := context .Background ()
1745
1745
1746
1746
expectedErr := status .Errorf (codes .InvalidArgument , "copy volume from volumeSnapshot is not supported" )
1747
- err := d .copyVolume (ctx , req , "" , []string {}, "" , "" , secret , nil , nil , "core.windows.net" )
1747
+ err := d .copyVolume (ctx , req , "" , "" , []string {}, "" , "" , secret , nil , nil , "core.windows.net" )
1748
1748
if ! reflect .DeepEqual (err , expectedErr ) {
1749
1749
t .Errorf ("Unexpected error: %v" , err )
1750
1750
}
@@ -1779,7 +1779,7 @@ func TestCopyVolume(t *testing.T) {
1779
1779
ctx := context .Background ()
1780
1780
1781
1781
expectedErr := fmt .Errorf ("protocol nfs is not supported for volume cloning" )
1782
- err := d .copyVolume (ctx , req , "" , []string {}, "" , "" , secret , & fileclient.ShareOptions {Protocol : storage .EnabledProtocolsNFS }, nil , "core.windows.net" )
1782
+ err := d .copyVolume (ctx , req , "" , "" , []string {}, "" , "" , secret , & fileclient.ShareOptions {Protocol : storage .EnabledProtocolsNFS }, nil , "core.windows.net" )
1783
1783
if ! reflect .DeepEqual (err , expectedErr ) {
1784
1784
t .Errorf ("Unexpected error: %v" , err )
1785
1785
}
@@ -1814,7 +1814,7 @@ func TestCopyVolume(t *testing.T) {
1814
1814
ctx := context .Background ()
1815
1815
1816
1816
expectedErr := status .Errorf (codes .NotFound , "error parsing volume id: \" unit-test\" , should at least contain two #" )
1817
- err := d .copyVolume (ctx , req , "" , []string {}, "" , "" , secret , & fileclient.ShareOptions {Name : "dstFileshare" }, nil , "core.windows.net" )
1817
+ err := d .copyVolume (ctx , req , "" , "" , []string {}, "" , "" , secret , & fileclient.ShareOptions {Name : "dstFileshare" }, nil , "core.windows.net" )
1818
1818
if ! reflect .DeepEqual (err , expectedErr ) {
1819
1819
t .Errorf ("Unexpected error: %v" , err )
1820
1820
}
@@ -1848,8 +1848,8 @@ func TestCopyVolume(t *testing.T) {
1848
1848
d := NewFakeDriver ()
1849
1849
ctx := context .Background ()
1850
1850
1851
- expectedErr := fmt .Errorf ("srcFileShareName() or dstFileShareName(dstFileshare) is empty" )
1852
- err := d .copyVolume (ctx , req , "" , []string {}, "" , "" , secret , & fileclient.ShareOptions {Name : "dstFileshare" }, nil , "core.windows.net" )
1851
+ expectedErr := fmt .Errorf ("one or more of srcAccountName(unit-test), srcFileShareName(), dstFileShareName(dstFileshare) are empty" )
1852
+ err := d .copyVolume (ctx , req , "" , "" , []string {}, "" , "" , secret , & fileclient.ShareOptions {Name : "dstFileshare" }, nil , "core.windows.net" )
1853
1853
if ! reflect .DeepEqual (err , expectedErr ) {
1854
1854
t .Errorf ("Unexpected error: %v" , err )
1855
1855
}
@@ -1883,8 +1883,8 @@ func TestCopyVolume(t *testing.T) {
1883
1883
d := NewFakeDriver ()
1884
1884
ctx := context .Background ()
1885
1885
1886
- expectedErr := fmt .Errorf ("srcFileShareName(fileshare) or dstFileShareName() is empty" )
1887
- err := d .copyVolume (ctx , req , "" , []string {}, "" , "" , secret , & fileclient.ShareOptions {}, nil , "core.windows.net" )
1886
+ expectedErr := fmt .Errorf ("one or more of srcAccountName(f5713de20cde511e8ba4900), srcFileShareName(fileshare), dstFileShareName() are empty" )
1887
+ err := d .copyVolume (ctx , req , "" , "" , []string {}, "" , "" , secret , & fileclient.ShareOptions {}, nil , "core.windows.net" )
1888
1888
if ! reflect .DeepEqual (err , expectedErr ) {
1889
1889
t .Errorf ("Unexpected error: %v" , err )
1890
1890
}
@@ -1916,27 +1916,15 @@ func TestCopyVolume(t *testing.T) {
1916
1916
secret := map [string ]string {}
1917
1917
ctx := context .Background ()
1918
1918
1919
- ctrl := gomock .NewController (t )
1920
- defer ctrl .Finish ()
1921
-
1922
- m := util .NewMockEXEC (ctrl )
1923
- listStr := "JobId: ed1c3833-eaff-fe42-71d7-513fb065a9d9\n Start Time: Monday, 07-Aug-23 03:29:54 UTC\n Status: Completed\n Command: copy https://{accountName}.file.core.windows.net/{srcFileshare}{SAStoken} https://{accountName}.file.core.windows.net/{dstFileshare}{SAStoken} --recursive --check-length=false"
1924
- m .EXPECT ().RunCommand (gomock .Eq ("azcopy jobs list | grep dstFileshare -B 3" ), gomock .Any ()).Return (listStr , nil )
1925
- // if test.enableShow {
1926
- // m.EXPECT().RunCommand(gomock.Not("azcopy jobs list | grep dstContainer -B 3")).Return(test.showStr, test.showErr)
1927
- // }
1928
-
1929
- d .azcopy .ExecCmd = m
1930
-
1931
- var expectedErr error
1932
- err := d .copyVolume (ctx , req , "sastoken" , []string {}, "" , "" , secret , & fileclient.ShareOptions {Name : "dstFileshare" }, nil , "core.windows.net" )
1919
+ expectedErr := fmt .Errorf ("one or more of srcAccountName(f5713de20cde511e8ba4900), srcFileShareName(fileshare), dstFileShareName() are empty" )
1920
+ err := d .copyVolume (ctx , req , "" , "" , []string {}, "" , "" , secret , & fileclient.ShareOptions {}, nil , "core.windows.net" )
1933
1921
if ! reflect .DeepEqual (err , expectedErr ) {
1934
1922
t .Errorf ("Unexpected error: %v" , err )
1935
1923
}
1936
1924
},
1937
1925
},
1938
1926
{
1939
- name : "azcopy job is first in progress and then be completed " ,
1927
+ name : "azcopy job is in progress" ,
1940
1928
testFunc : func (t * testing.T ) {
1941
1929
d := NewFakeDriver ()
1942
1930
mp := map [string ]string {}
@@ -1965,16 +1953,13 @@ func TestCopyVolume(t *testing.T) {
1965
1953
1966
1954
m := util .NewMockEXEC (ctrl )
1967
1955
listStr1 := "JobId: ed1c3833-eaff-fe42-71d7-513fb065a9d9\n Start Time: Monday, 07-Aug-23 03:29:54 UTC\n Status: InProgress\n Command: copy https://{accountName}.file.core.windows.net/{srcFileshare}{SAStoken} https://{accountName}.file.core.windows.net/{dstFileshare}{SAStoken} --recursive --check-length=false"
1968
- listStr2 := "JobId: ed1c3833-eaff-fe42-71d7-513fb065a9d9\n Start Time: Monday, 07-Aug-23 03:29:54 UTC\n Status: Completed\n Command: copy https://{accountName}.file.core.windows.net/{srcFileshare}{SAStoken} https://{accountName}.file.core.windows.net/{dstFileshare}{SAStoken} --recursive --check-length=false"
1969
- o1 := m .EXPECT ().RunCommand (gomock .Eq ("azcopy jobs list | grep dstFileshare -B 3" ), gomock .Any ()).Return (listStr1 , nil ).Times (1 )
1956
+ m .EXPECT ().RunCommand (gomock .Eq ("azcopy jobs list | grep dstFileshare -B 3" ), gomock .Any ()).Return (listStr1 , nil ).Times (1 )
1970
1957
m .EXPECT ().RunCommand (gomock .Not ("azcopy jobs list | grep dstFileshare -B 3" ), gomock .Any ()).Return ("Percent Complete (approx): 50.0" , nil )
1971
- o2 := m .EXPECT ().RunCommand (gomock .Eq ("azcopy jobs list | grep dstFileshare -B 3" ), gomock .Any ()).Return (listStr2 , nil )
1972
- gomock .InOrder (o1 , o2 )
1973
1958
1974
1959
d .azcopy .ExecCmd = m
1975
1960
1976
- var expectedErr error
1977
- err := d .copyVolume (ctx , req , "sastoken" , []string {}, "" , "" , secret , & fileclient.ShareOptions {Name : "dstFileshare" }, nil , "core.windows.net" )
1961
+ expectedErr := fmt . Errorf ( "wait for the existing AzCopy job to complete, current copy percentage is 50.0%%" )
1962
+ err := d .copyVolume (ctx , req , "" , " sastoken" , []string {}, "" , "" , secret , & fileclient.ShareOptions {Name : "dstFileshare" }, nil , "core.windows.net" )
1978
1963
if ! reflect .DeepEqual (err , expectedErr ) {
1979
1964
t .Errorf ("Unexpected error: %v" , err )
1980
1965
}
0 commit comments