-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add tests for custom rbd export-diff command #102
base: main
Are you sure you want to change the base?
Conversation
f0bfef2
to
93f1358
Compare
e7470c2
to
b256928
Compare
9c3b1d3
to
1a230e8
Compare
cf7706a
to
9366cd3
Compare
45ce7b8
to
fb019a9
Compare
Signed-off-by: Yuji Ito <[email protected]>
fb019a9
to
2a1a5b1
Compare
ceph/test/suite_test.go
Outdated
|
||
func TestMTest(t *testing.T) { | ||
if os.Getenv("CEPH_CMD_TEST") == "" { | ||
t.Skip("Run under ceph/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make the test fail here? I'd like to avoid using t.Skip
because I remember topolvm/topolvm#1005.
|
||
description: "(181) not specify snapshot name", | ||
exportArgs: []string{ | ||
"--read-offset", "0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value should be >0 according to the test spec?
ceph/test/regression_test.go
Outdated
|
||
// creating snapshots | ||
// snapshots[0] and snapshots[1] have diff with the image | ||
// snapshots[2] and snapshots[2] has no diff with the image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo?
// snapshots[2] and snapshots[2] has no diff with the image | |
// snapshots[2] and snapshots[3] has no diff with the image |
ceph/test/regression_test.go
Outdated
Expect(err).NotTo(HaveOccurred()) | ||
} | ||
// crate snapshot[3] with the same data as snapshot[2] | ||
// random file snapshot[3] is not exist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// random file snapshot[3] is not exist | |
// random file named snapshot[3] does not exist |
expectedDataName: t.snapshots[0], | ||
exportArgs: []string{ | ||
"-p", t.poolName, | ||
fmt.Sprintf("%s@%s", t.srcImageName, t.snapshots[0]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to check pool/image@snap
format, too.
ceph/test/cluster/block.go
Outdated
|
||
args := []string{path.Join(workDir, filename), path.Join(workDir, workFilename)} | ||
log.Printf("📂 diff %s", strings.Join(args, " ")) | ||
_, err := exec.Command("diff", args...).CombinedOutput() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be appropriate to use cmp(1) rather than diff(1) because the files are binary.
ceph/test/cluster/kubectl.go
Outdated
func Kubectl(args ...string) ([]byte, error) { | ||
if len(kubectlCmd) == 0 { | ||
return nil, fmt.Errorf("KUBECTL environment variable should be set") | ||
} | ||
|
||
icon := "⚓" | ||
if cephMatcher.MatchString(strings.Join(args, " ")) { | ||
icon = "🐙" | ||
} | ||
log.Printf("%s kubectl %s", icon, strings.Join(args, " ")) | ||
var stdout bytes.Buffer | ||
command := exec.Command(kubectlCmd, args...) | ||
command.Stdout = &stdout | ||
command.Stderr = os.Stderr | ||
|
||
err := command.Run() | ||
return stdout.Bytes(), err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we implement Kubectl
by using KubectlWithInput
as follows?
func Kubectl(args ...string) ([]byte, error) { | |
if len(kubectlCmd) == 0 { | |
return nil, fmt.Errorf("KUBECTL environment variable should be set") | |
} | |
icon := "⚓" | |
if cephMatcher.MatchString(strings.Join(args, " ")) { | |
icon = "🐙" | |
} | |
log.Printf("%s kubectl %s", icon, strings.Join(args, " ")) | |
var stdout bytes.Buffer | |
command := exec.Command(kubectlCmd, args...) | |
command.Stdout = &stdout | |
command.Stderr = os.Stderr | |
err := command.Run() | |
return stdout.Bytes(), err | |
} | |
func Kubectl(args ...string) ([]byte, error) { | |
return KubectlWithInput(nil, args...) | |
} |
} | ||
if string(after) != string(before) { | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we insert some sleeps for reproducibility?
ceph/test/cluster/kubectl.go
Outdated
} | ||
|
||
func CleanupGlobal() error { | ||
SCs, err := GetObjectList[storagev1.StorageClassList]("sc", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SCs, err := GetObjectList[storagev1.StorageClassList]("sc", "") | |
scs, err := GetObjectList[storagev1.StorageClassList]("sc", "") |
) | ||
|
||
func Rbd(args ...string) ([]byte, error) { | ||
return Kubectl(append([]string{"exec", "-n", ROOK_NAMESPACE, "deploy/rook-ceph-tools", "--", "rbd"}, args...)...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we write this line as follows?
return Kubectl(append([]string{"exec", "-n", ROOK_NAMESPACE, "deploy/rook-ceph-tools", "--", "rbd"}, args...)...) | |
return Kubectl("exec", "-n", ROOK_NAMESPACE, "deploy/rook-ceph-tools", "--", "rbd", args...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it, but couldn't.
Signed-off-by: Yuji Ito <[email protected]>
No description provided.