-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: add multik8s Ginkgo test replacing shell script with
- Loading branch information
1 parent
337687f
commit 859c723
Showing
3 changed files
with
108 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package multik8s | ||
|
||
import ( | ||
"bytes" | ||
_ "embed" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"testing" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestMtest(t *testing.T) { | ||
if os.Getenv("E2ETEST") == "" { | ||
t.Skip("Run under e2e/") | ||
} | ||
|
||
RegisterFailHandler(Fail) | ||
|
||
SetDefaultEventuallyPollingInterval(time.Second) | ||
SetDefaultEventuallyTimeout(3 * time.Minute) | ||
|
||
RunSpecs(t, "rbd backup system test with multiple k8s clusters") | ||
} | ||
|
||
var _ = Describe("Mantle", func() { | ||
Context("wait controller to be ready", waitControllerToBeReady) | ||
Context("replication", replicationTestSuite) | ||
}) | ||
|
||
var ( | ||
kubectlPrefix0 = os.Getenv("KUBECTL0") | ||
kubectlPrefix1 = os.Getenv("KUBECTL1") | ||
) | ||
|
||
func execAtLocal(cmd string, input []byte, args ...string) ([]byte, []byte, error) { | ||
var stdout, stderr bytes.Buffer | ||
command := exec.Command(cmd, args...) | ||
command.Stdout = &stdout | ||
command.Stderr = &stderr | ||
|
||
if len(input) != 0 { | ||
command.Stdin = bytes.NewReader(input) | ||
} | ||
|
||
err := command.Run() | ||
return stdout.Bytes(), stderr.Bytes(), err | ||
} | ||
|
||
// input can be nil | ||
func kubectl(clusterNo int, input []byte, args ...string) ([]byte, []byte, error) { | ||
kubectlPrefix := "" | ||
switch clusterNo { | ||
case 0: | ||
kubectlPrefix = kubectlPrefix0 | ||
case 1: | ||
kubectlPrefix = kubectlPrefix1 | ||
default: | ||
panic(fmt.Sprintf("invalid clusterNo: %d", clusterNo)) | ||
} | ||
if len(kubectlPrefix) == 0 { | ||
panic("Either KUBECTL0 or KUBECTL1 environment variable is not set") | ||
} | ||
return execAtLocal(kubectlPrefix, input, args...) | ||
} | ||
|
||
func checkDeploymentReady(clusterNo int, namespace, name string) error { | ||
_, stderr, err := kubectl( | ||
clusterNo, nil, | ||
"-n", namespace, "wait", "--for=condition=Available", "deploy", name, "--timeout=1m", | ||
) | ||
if err != nil { | ||
return fmt.Errorf("kubectl wait deploy failed. stderr: %s, err: %w", string(stderr), err) | ||
} | ||
return nil | ||
} | ||
|
||
func waitControllerToBeReady() { | ||
It("wait for mantle-controller to be ready", func() { | ||
Eventually(func() error { | ||
return checkDeploymentReady(0, "rook-ceph", "mantle-controller") | ||
}).Should(Succeed()) | ||
|
||
Eventually(func() error { | ||
return checkDeploymentReady(0, "rook-ceph", "mantle-controller") | ||
}).Should(Succeed()) | ||
}) | ||
} | ||
|
||
func replicationTestSuite() { | ||
Describe("make sure SyncToRemote becomes true after a MantleBackup is created", func() { | ||
// FIXME | ||
return | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.