Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
40c39373
Commit
40c39373
authored
May 29, 2018
by
Yecheng Fu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up fake mounters.
parent
2aced6d9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
343 deletions
+29
-343
container_manager_linux_test.go
pkg/kubelet/cm/container_manager_linux_test.go
+8
-102
exec_mount_test.go
pkg/util/mount/exec_mount_test.go
+4
-69
fake.go
pkg/util/mount/fake.go
+8
-1
removeall_test.go
pkg/util/removeall/removeall_test.go
+4
-83
host_path_test.go
pkg/volume/host_path/host_path_test.go
+5
-88
No files found.
pkg/kubelet/cm/container_manager_linux_test.go
View file @
40c39373
...
@@ -19,8 +19,6 @@ limitations under the License.
...
@@ -19,8 +19,6 @@ limitations under the License.
package
cm
package
cm
import
(
import
(
"errors"
"fmt"
"io/ioutil"
"io/ioutil"
"os"
"os"
"path"
"path"
...
@@ -32,101 +30,9 @@ import (
...
@@ -32,101 +30,9 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/mount"
)
)
type
fakeMountInterface
struct
{
mountPoints
[]
mount
.
MountPoint
}
func
(
mi
*
fakeMountInterface
)
Mount
(
source
string
,
target
string
,
fstype
string
,
options
[]
string
)
error
{
return
fmt
.
Errorf
(
"unsupported"
)
}
func
(
mi
*
fakeMountInterface
)
Unmount
(
target
string
)
error
{
return
fmt
.
Errorf
(
"unsupported"
)
}
func
(
mi
*
fakeMountInterface
)
List
()
([]
mount
.
MountPoint
,
error
)
{
return
mi
.
mountPoints
,
nil
}
func
(
mi
*
fakeMountInterface
)
IsMountPointMatch
(
mp
mount
.
MountPoint
,
dir
string
)
bool
{
return
(
mp
.
Path
==
dir
)
}
func
(
mi
*
fakeMountInterface
)
IsNotMountPoint
(
dir
string
)
(
bool
,
error
)
{
return
false
,
fmt
.
Errorf
(
"unsupported"
)
}
func
(
mi
*
fakeMountInterface
)
IsLikelyNotMountPoint
(
file
string
)
(
bool
,
error
)
{
return
false
,
fmt
.
Errorf
(
"unsupported"
)
}
func
(
mi
*
fakeMountInterface
)
GetDeviceNameFromMount
(
mountPath
,
pluginDir
string
)
(
string
,
error
)
{
return
""
,
nil
}
func
(
mi
*
fakeMountInterface
)
DeviceOpened
(
pathname
string
)
(
bool
,
error
)
{
for
_
,
mp
:=
range
mi
.
mountPoints
{
if
mp
.
Device
==
pathname
{
return
true
,
nil
}
}
return
false
,
nil
}
func
(
mi
*
fakeMountInterface
)
PathIsDevice
(
pathname
string
)
(
bool
,
error
)
{
return
true
,
nil
}
func
(
mi
*
fakeMountInterface
)
MakeRShared
(
path
string
)
error
{
return
nil
}
func
(
mi
*
fakeMountInterface
)
GetFileType
(
pathname
string
)
(
mount
.
FileType
,
error
)
{
return
mount
.
FileType
(
"fake"
),
nil
}
func
(
mi
*
fakeMountInterface
)
MakeDir
(
pathname
string
)
error
{
return
nil
}
func
(
mi
*
fakeMountInterface
)
MakeFile
(
pathname
string
)
error
{
return
nil
}
func
(
mi
*
fakeMountInterface
)
ExistsPath
(
pathname
string
)
(
bool
,
error
)
{
return
true
,
errors
.
New
(
"not implemented"
)
}
func
(
mi
*
fakeMountInterface
)
PrepareSafeSubpath
(
subPath
mount
.
Subpath
)
(
newHostPath
string
,
cleanupAction
func
(),
err
error
)
{
return
""
,
nil
,
nil
}
func
(
mi
*
fakeMountInterface
)
CleanSubPaths
(
_
,
_
string
)
error
{
return
nil
}
func
(
mi
*
fakeMountInterface
)
SafeMakeDir
(
_
,
_
string
,
_
os
.
FileMode
)
error
{
return
nil
}
func
(
mi
*
fakeMountInterface
)
GetMountRefs
(
pathname
string
)
([]
string
,
error
)
{
return
nil
,
errors
.
New
(
"not implemented"
)
}
func
(
mi
*
fakeMountInterface
)
GetFSGroup
(
pathname
string
)
(
int64
,
error
)
{
return
-
1
,
errors
.
New
(
"not implemented"
)
}
func
(
mi
*
fakeMountInterface
)
GetSELinuxSupport
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
mi
*
fakeMountInterface
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
0
,
errors
.
New
(
"not implemented"
)
}
func
fakeContainerMgrMountInt
()
mount
.
Interface
{
func
fakeContainerMgrMountInt
()
mount
.
Interface
{
return
&
fakeMountInterface
{
return
&
mount
.
FakeMounter
{
[]
mount
.
MountPoint
{
MountPoints
:
[]
mount
.
MountPoint
{
{
{
Device
:
"cgroup"
,
Device
:
"cgroup"
,
Type
:
"cgroup"
,
Type
:
"cgroup"
,
...
@@ -158,8 +64,8 @@ func TestCgroupMountValidationSuccess(t *testing.T) {
...
@@ -158,8 +64,8 @@ func TestCgroupMountValidationSuccess(t *testing.T) {
}
}
func
TestCgroupMountValidationMemoryMissing
(
t
*
testing
.
T
)
{
func
TestCgroupMountValidationMemoryMissing
(
t
*
testing
.
T
)
{
mountInt
:=
&
fakeMountInterface
{
mountInt
:=
&
mount
.
FakeMounter
{
[]
mount
.
MountPoint
{
MountPoints
:
[]
mount
.
MountPoint
{
{
{
Device
:
"cgroup"
,
Device
:
"cgroup"
,
Type
:
"cgroup"
,
Type
:
"cgroup"
,
...
@@ -182,8 +88,8 @@ func TestCgroupMountValidationMemoryMissing(t *testing.T) {
...
@@ -182,8 +88,8 @@ func TestCgroupMountValidationMemoryMissing(t *testing.T) {
}
}
func
TestCgroupMountValidationMultipleSubsystem
(
t
*
testing
.
T
)
{
func
TestCgroupMountValidationMultipleSubsystem
(
t
*
testing
.
T
)
{
mountInt
:=
&
fakeMountInterface
{
mountInt
:=
&
mount
.
FakeMounter
{
[]
mount
.
MountPoint
{
MountPoints
:
[]
mount
.
MountPoint
{
{
{
Device
:
"cgroup"
,
Device
:
"cgroup"
,
Type
:
"cgroup"
,
Type
:
"cgroup"
,
...
@@ -212,8 +118,8 @@ func TestSoftRequirementsValidationSuccess(t *testing.T) {
...
@@ -212,8 +118,8 @@ func TestSoftRequirementsValidationSuccess(t *testing.T) {
defer
os
.
RemoveAll
(
tempDir
)
defer
os
.
RemoveAll
(
tempDir
)
req
.
NoError
(
ioutil
.
WriteFile
(
path
.
Join
(
tempDir
,
"cpu.cfs_period_us"
),
[]
byte
(
"0"
),
os
.
ModePerm
))
req
.
NoError
(
ioutil
.
WriteFile
(
path
.
Join
(
tempDir
,
"cpu.cfs_period_us"
),
[]
byte
(
"0"
),
os
.
ModePerm
))
req
.
NoError
(
ioutil
.
WriteFile
(
path
.
Join
(
tempDir
,
"cpu.cfs_quota_us"
),
[]
byte
(
"0"
),
os
.
ModePerm
))
req
.
NoError
(
ioutil
.
WriteFile
(
path
.
Join
(
tempDir
,
"cpu.cfs_quota_us"
),
[]
byte
(
"0"
),
os
.
ModePerm
))
mountInt
:=
&
fakeMountInterface
{
mountInt
:=
&
mount
.
FakeMounter
{
[]
mount
.
MountPoint
{
MountPoints
:
[]
mount
.
MountPoint
{
{
{
Device
:
"cgroup"
,
Device
:
"cgroup"
,
Type
:
"cgroup"
,
Type
:
"cgroup"
,
...
...
pkg/util/mount/exec_mount_test.go
View file @
40c39373
...
@@ -19,9 +19,7 @@ limitations under the License.
...
@@ -19,9 +19,7 @@ limitations under the License.
package
mount
package
mount
import
(
import
(
"errors"
"fmt"
"fmt"
"os"
"reflect"
"reflect"
"strings"
"strings"
"testing"
"testing"
...
@@ -47,7 +45,7 @@ func TestMount(t *testing.T) {
...
@@ -47,7 +45,7 @@ func TestMount(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
})
})
wrappedMounter
:=
&
fakeMounter
{
t
}
wrappedMounter
:=
&
fakeMounter
{
FakeMounter
:
&
FakeMounter
{},
t
:
t
}
mounter
:=
NewExecMounter
(
exec
,
wrappedMounter
)
mounter
:=
NewExecMounter
(
exec
,
wrappedMounter
)
mounter
.
Mount
(
sourcePath
,
destinationPath
,
fsType
,
mountOptions
)
mounter
.
Mount
(
sourcePath
,
destinationPath
,
fsType
,
mountOptions
)
...
@@ -75,7 +73,7 @@ func TestBindMount(t *testing.T) {
...
@@ -75,7 +73,7 @@ func TestBindMount(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
})
})
wrappedMounter
:=
&
fakeMounter
{
t
}
wrappedMounter
:=
&
fakeMounter
{
FakeMounter
:
&
FakeMounter
{},
t
:
t
}
mounter
:=
NewExecMounter
(
exec
,
wrappedMounter
)
mounter
:=
NewExecMounter
(
exec
,
wrappedMounter
)
bindOptions
:=
append
(
mountOptions
,
"bind"
)
bindOptions
:=
append
(
mountOptions
,
"bind"
)
mounter
.
Mount
(
sourcePath
,
destinationPath
,
fsType
,
bindOptions
)
mounter
.
Mount
(
sourcePath
,
destinationPath
,
fsType
,
bindOptions
)
...
@@ -94,7 +92,7 @@ func TestUnmount(t *testing.T) {
...
@@ -94,7 +92,7 @@ func TestUnmount(t *testing.T) {
return
nil
,
nil
return
nil
,
nil
})
})
wrappedMounter
:=
&
fakeMounter
{
t
}
wrappedMounter
:=
&
fakeMounter
{
&
FakeMounter
{},
t
}
mounter
:=
NewExecMounter
(
exec
,
wrappedMounter
)
mounter
:=
NewExecMounter
(
exec
,
wrappedMounter
)
mounter
.
Unmount
(
destinationPath
)
mounter
.
Unmount
(
destinationPath
)
...
@@ -102,6 +100,7 @@ func TestUnmount(t *testing.T) {
...
@@ -102,6 +100,7 @@ func TestUnmount(t *testing.T) {
/* Fake wrapped mounter */
/* Fake wrapped mounter */
type
fakeMounter
struct
{
type
fakeMounter
struct
{
*
FakeMounter
t
*
testing
.
T
t
*
testing
.
T
}
}
...
@@ -116,67 +115,3 @@ func (fm *fakeMounter) Unmount(target string) error {
...
@@ -116,67 +115,3 @@ func (fm *fakeMounter) Unmount(target string) error {
fm
.
t
.
Errorf
(
"Unexpected wrapped mount call"
)
fm
.
t
.
Errorf
(
"Unexpected wrapped mount call"
)
return
fmt
.
Errorf
(
"Unexpected wrapped mount call"
)
return
fmt
.
Errorf
(
"Unexpected wrapped mount call"
)
}
}
func
(
fm
*
fakeMounter
)
List
()
([]
MountPoint
,
error
)
{
return
nil
,
nil
}
func
(
fm
*
fakeMounter
)
IsMountPointMatch
(
mp
MountPoint
,
dir
string
)
bool
{
return
false
}
func
(
fm
*
fakeMounter
)
IsNotMountPoint
(
file
string
)
(
bool
,
error
)
{
return
false
,
nil
}
func
(
fm
*
fakeMounter
)
IsLikelyNotMountPoint
(
file
string
)
(
bool
,
error
)
{
return
false
,
nil
}
func
(
fm
*
fakeMounter
)
DeviceOpened
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
nil
}
func
(
fm
*
fakeMounter
)
PathIsDevice
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
nil
}
func
(
fm
*
fakeMounter
)
GetDeviceNameFromMount
(
mountPath
,
pluginDir
string
)
(
string
,
error
)
{
return
""
,
nil
}
func
(
fm
*
fakeMounter
)
MakeRShared
(
path
string
)
error
{
return
nil
}
func
(
fm
*
fakeMounter
)
MakeFile
(
pathname
string
)
error
{
return
nil
}
func
(
fm
*
fakeMounter
)
MakeDir
(
pathname
string
)
error
{
return
nil
}
func
(
fm
*
fakeMounter
)
ExistsPath
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
fm
*
fakeMounter
)
GetFileType
(
pathname
string
)
(
FileType
,
error
)
{
return
FileTypeFile
,
nil
}
func
(
fm
*
fakeMounter
)
PrepareSafeSubpath
(
subPath
Subpath
)
(
newHostPath
string
,
cleanupAction
func
(),
err
error
)
{
return
subPath
.
Path
,
nil
,
nil
}
func
(
fm
*
fakeMounter
)
CleanSubPaths
(
podDir
string
,
volumeName
string
)
error
{
return
nil
}
func
(
fm
*
fakeMounter
)
SafeMakeDir
(
pathname
string
,
base
string
,
perm
os
.
FileMode
)
error
{
return
nil
}
func
(
fm
*
fakeMounter
)
GetMountRefs
(
pathname
string
)
([]
string
,
error
)
{
return
nil
,
errors
.
New
(
"not implemented"
)
}
func
(
fm
*
fakeMounter
)
GetFSGroup
(
pathname
string
)
(
int64
,
error
)
{
return
-
1
,
errors
.
New
(
"not implemented"
)
}
func
(
fm
*
fakeMounter
)
GetSELinuxSupport
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
fm
*
fakeMounter
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
0
,
errors
.
New
(
"not implemented"
)
}
pkg/util/mount/fake.go
View file @
40c39373
...
@@ -29,6 +29,7 @@ import (
...
@@ -29,6 +29,7 @@ import (
type
FakeMounter
struct
{
type
FakeMounter
struct
{
MountPoints
[]
MountPoint
MountPoints
[]
MountPoint
Log
[]
FakeAction
Log
[]
FakeAction
Filesystem
map
[
string
]
FileType
// Some tests run things in parallel, make sure the mounter does not produce
// Some tests run things in parallel, make sure the mounter does not produce
// any golang's DATA RACE warnings.
// any golang's DATA RACE warnings.
mutex
sync
.
Mutex
mutex
sync
.
Mutex
...
@@ -190,6 +191,9 @@ func (f *FakeMounter) MakeRShared(path string) error {
...
@@ -190,6 +191,9 @@ func (f *FakeMounter) MakeRShared(path string) error {
}
}
func
(
f
*
FakeMounter
)
GetFileType
(
pathname
string
)
(
FileType
,
error
)
{
func
(
f
*
FakeMounter
)
GetFileType
(
pathname
string
)
(
FileType
,
error
)
{
if
t
,
ok
:=
f
.
Filesystem
[
pathname
];
ok
{
return
t
,
nil
}
return
FileType
(
"fake"
),
nil
return
FileType
(
"fake"
),
nil
}
}
...
@@ -202,7 +206,10 @@ func (f *FakeMounter) MakeFile(pathname string) error {
...
@@ -202,7 +206,10 @@ func (f *FakeMounter) MakeFile(pathname string) error {
}
}
func
(
f
*
FakeMounter
)
ExistsPath
(
pathname
string
)
(
bool
,
error
)
{
func
(
f
*
FakeMounter
)
ExistsPath
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"not implemented"
)
if
_
,
ok
:=
f
.
Filesystem
[
pathname
];
ok
{
return
true
,
nil
}
return
false
,
nil
}
}
func
(
f
*
FakeMounter
)
PrepareSafeSubpath
(
subPath
Subpath
)
(
newHostPath
string
,
cleanupAction
func
(),
err
error
)
{
func
(
f
*
FakeMounter
)
PrepareSafeSubpath
(
subPath
Subpath
)
(
newHostPath
string
,
cleanupAction
func
(),
err
error
)
{
...
...
pkg/util/removeall/removeall_test.go
View file @
40c39373
...
@@ -27,87 +27,12 @@ import (
...
@@ -27,87 +27,12 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/mount"
)
)
type
fakeMounter
struct
{}
type
fakeMounter
struct
{
mount
.
FakeMounter
var
_
mount
.
Interface
=
&
fakeMounter
{}
func
(
mounter
*
fakeMounter
)
Mount
(
source
string
,
target
string
,
fstype
string
,
options
[]
string
)
error
{
return
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
Unmount
(
target
string
)
error
{
return
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
List
()
([]
mount
.
MountPoint
,
error
)
{
return
nil
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
fakeMounter
)
DeviceOpened
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
PathIsDevice
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
GetDeviceNameFromMount
(
mountPath
,
pluginDir
string
)
(
string
,
error
)
{
return
""
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
IsMountPointMatch
(
mp
mount
.
MountPoint
,
dir
string
)
bool
{
return
mp
.
Path
==
dir
}
func
(
mounter
*
fakeMounter
)
IsNotMountPoint
(
dir
string
)
(
bool
,
error
)
{
return
mount
.
IsNotMountPoint
(
mounter
,
dir
)
}
func
(
mounter
*
fakeMounter
)
GetFileType
(
pathname
string
)
(
mount
.
FileType
,
error
)
{
return
mount
.
FileType
(
"fake"
),
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
MakeDir
(
pathname
string
)
error
{
return
nil
}
}
func
(
mounter
*
fakeMounter
)
MakeFile
(
pathname
string
)
error
{
// IsLikelyNotMountPoint overrides mount.FakeMounter.IsLikelyNotMountPoint for our use.
return
nil
func
(
f
*
fakeMounter
)
IsLikelyNotMountPoint
(
file
string
)
(
bool
,
error
)
{
}
func
(
mounter
*
fakeMounter
)
ExistsPath
(
pathname
string
)
(
bool
,
error
)
{
return
true
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
PrepareSafeSubpath
(
subPath
mount
.
Subpath
)
(
newHostPath
string
,
cleanupAction
func
(),
err
error
)
{
return
""
,
nil
,
nil
}
func
(
mounter
*
fakeMounter
)
CleanSubPaths
(
_
,
_
string
)
error
{
return
nil
}
func
(
mounter
*
fakeMounter
)
SafeMakeDir
(
_
,
_
string
,
_
os
.
FileMode
)
error
{
return
nil
}
func
(
mounter
*
fakeMounter
)
GetMountRefs
(
pathname
string
)
([]
string
,
error
)
{
return
nil
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
GetFSGroup
(
pathname
string
)
(
int64
,
error
)
{
return
-
1
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
GetSELinuxSupport
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
0
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
IsLikelyNotMountPoint
(
file
string
)
(
bool
,
error
)
{
name
:=
path
.
Base
(
file
)
name
:=
path
.
Base
(
file
)
if
strings
.
HasPrefix
(
name
,
"mount"
)
{
if
strings
.
HasPrefix
(
name
,
"mount"
)
{
return
false
,
nil
return
false
,
nil
...
@@ -118,10 +43,6 @@ func (mounter *fakeMounter) IsLikelyNotMountPoint(file string) (bool, error) {
...
@@ -118,10 +43,6 @@ func (mounter *fakeMounter) IsLikelyNotMountPoint(file string) (bool, error) {
return
true
,
nil
return
true
,
nil
}
}
func
(
mounter
*
fakeMounter
)
MakeRShared
(
path
string
)
error
{
return
nil
}
func
TestRemoveAllOneFilesystem
(
t
*
testing
.
T
)
{
func
TestRemoveAllOneFilesystem
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
name
string
name
string
...
...
pkg/volume/host_path/host_path_test.go
View file @
40c39373
...
@@ -17,7 +17,6 @@ limitations under the License.
...
@@ -17,7 +17,6 @@ limitations under the License.
package
host_path
package
host_path
import
(
import
(
"errors"
"fmt"
"fmt"
"os"
"os"
"testing"
"testing"
...
@@ -319,92 +318,6 @@ func TestPersistentClaimReadOnlyFlag(t *testing.T) {
...
@@ -319,92 +318,6 @@ func TestPersistentClaimReadOnlyFlag(t *testing.T) {
}
}
}
}
type
fakeFileTypeChecker
struct
{
desiredType
string
}
func
(
fftc
*
fakeFileTypeChecker
)
Mount
(
source
string
,
target
string
,
fstype
string
,
options
[]
string
)
error
{
return
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
Unmount
(
target
string
)
error
{
return
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
List
()
([]
utilmount
.
MountPoint
,
error
)
{
return
nil
,
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
IsMountPointMatch
(
mp
utilmount
.
MountPoint
,
dir
string
)
bool
{
return
false
}
func
(
fftc
*
fakeFileTypeChecker
)
IsNotMountPoint
(
file
string
)
(
bool
,
error
)
{
return
false
,
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
IsLikelyNotMountPoint
(
file
string
)
(
bool
,
error
)
{
return
false
,
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
DeviceOpened
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
PathIsDevice
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
GetDeviceNameFromMount
(
mountPath
,
pluginDir
string
)
(
string
,
error
)
{
return
"fake"
,
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
MakeRShared
(
path
string
)
error
{
return
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
MakeFile
(
pathname
string
)
error
{
return
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
MakeDir
(
pathname
string
)
error
{
return
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
ExistsPath
(
pathname
string
)
(
bool
,
error
)
{
return
true
,
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
GetFileType
(
_
string
)
(
utilmount
.
FileType
,
error
)
{
return
utilmount
.
FileType
(
fftc
.
desiredType
),
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
PrepareSafeSubpath
(
subPath
utilmount
.
Subpath
)
(
newHostPath
string
,
cleanupAction
func
(),
err
error
)
{
return
""
,
nil
,
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
CleanSubPaths
(
_
,
_
string
)
error
{
return
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
SafeMakeDir
(
_
,
_
string
,
_
os
.
FileMode
)
error
{
return
nil
}
func
(
fftc
*
fakeFileTypeChecker
)
GetMountRefs
(
pathname
string
)
([]
string
,
error
)
{
return
nil
,
errors
.
New
(
"not implemented"
)
}
func
(
fftc
*
fakeFileTypeChecker
)
GetFSGroup
(
pathname
string
)
(
int64
,
error
)
{
return
-
1
,
errors
.
New
(
"not implemented"
)
}
func
(
fftc
*
fakeFileTypeChecker
)
GetSELinuxSupport
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
fftc
*
fakeFileTypeChecker
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
0
,
errors
.
New
(
"not implemented"
)
}
func
setUp
()
error
{
func
setUp
()
error
{
err
:=
os
.
MkdirAll
(
"/tmp/ExistingFolder"
,
os
.
FileMode
(
0755
))
err
:=
os
.
MkdirAll
(
"/tmp/ExistingFolder"
,
os
.
FileMode
(
0755
))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -473,7 +386,11 @@ func TestOSFileTypeChecker(t *testing.T) {
...
@@ -473,7 +386,11 @@ func TestOSFileTypeChecker(t *testing.T) {
}
}
for
i
,
tc
:=
range
testCases
{
for
i
,
tc
:=
range
testCases
{
fakeFTC
:=
&
fakeFileTypeChecker
{
desiredType
:
tc
.
desiredType
}
fakeFTC
:=
&
utilmount
.
FakeMounter
{
Filesystem
:
map
[
string
]
utilmount
.
FileType
{
tc
.
path
:
utilmount
.
FileType
(
tc
.
desiredType
),
},
}
oftc
:=
newFileTypeChecker
(
tc
.
path
,
fakeFTC
)
oftc
:=
newFileTypeChecker
(
tc
.
path
,
fakeFTC
)
path
:=
oftc
.
GetPath
()
path
:=
oftc
.
GetPath
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment