This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
404 additions
and
335 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,68 @@ | ||
package suites | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
"github.com/onsi/ginkgo/reporters" | ||
. "github.com/onsi/gomega" | ||
|
||
// log "github.com/sirupsen/logrus" | ||
|
||
kubectl "github.com/mesosphere/kudo-cassandra-operator/tests/utils/kubectl" | ||
k8s "github.com/mesosphere/kudo-cassandra-operator/tests/utils/k8s" | ||
kudo "github.com/mesosphere/kudo-cassandra-operator/tests/utils/kudo" | ||
) | ||
|
||
var ( | ||
TestName = "simple-install-uninstall-test" | ||
OperatorName = "cassandra" | ||
TestNamespace = fmt.Sprintf("%s-namespace", TestName) | ||
TestInstance = "cassandra-instance" | ||
KubeConfigPath = os.Getenv("KUBECONFIG") | ||
KubectlPath = os.Getenv("KUBECTL_PATH") | ||
KubectlOptions = kubectl.NewKubectlOptions( | ||
KubectlPath, | ||
KubeConfigPath, | ||
TestNamespace, | ||
"", | ||
) | ||
OperatorDirectory = os.Getenv("OPERATOR_DIRECTORY") | ||
) | ||
|
||
var _ = Describe("Simple install and uninstall test", func() { | ||
It("Installs the operator from a directory", func() { | ||
// TODO: Assert that it isn't running. | ||
kudo.InstallOperatorFromDirectory( | ||
KubectlOptions, OperatorDirectory, TestNamespace, TestInstance, []string{}, | ||
) | ||
// TODO: Assert that it is running. | ||
}) | ||
It("Uninstalls the operator", func() { | ||
kudo.UninstallOperator( | ||
KubectlOptions, OperatorName, TestNamespace, TestInstance, | ||
) | ||
// TODO: Assert that it isn't running. | ||
}) | ||
}) | ||
|
||
var _ = BeforeSuite(func() { | ||
kudo.UninstallOperator( | ||
KubectlOptions, OperatorName, TestNamespace, TestInstance, | ||
) | ||
k8s.CreateNamespace(KubectlOptions, TestNamespace) | ||
}) | ||
|
||
var _ = AfterSuite(func() { | ||
k8s.DeleteNamespace(KubectlOptions, TestNamespace) | ||
}) | ||
|
||
func TestService(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
junitReporter := reporters.NewJUnitReporter(fmt.Sprintf( | ||
"%s-junit.xml", TestName, | ||
)) | ||
RunSpecsWithDefaultAndCustomReporters(t, TestName, []Reporter{junitReporter}) | ||
} |
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 @@ | ||
package suites |
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,59 @@ | ||
package k8s | ||
|
||
import ( | ||
"fmt" | ||
|
||
. "github.com/mesosphere/kudo-cassandra-operator/tests/utils/kubectl" | ||
|
||
log "github.com/sirupsen/logrus" | ||
corev1 "k8s.io/api/core/v1" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func CreateNamespace(options *KubectlOptions, namespaceName string) error { | ||
clientset, err := GetKubernetesClientFromOptions(options) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
namespace := corev1.Namespace{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: namespaceName, | ||
}, | ||
} | ||
|
||
log.Info(fmt.Sprintf("Creating namespace '%s'", namespaceName)) | ||
_, err = clientset.CoreV1().Namespaces().Create(&namespace) | ||
|
||
if err != nil { | ||
if apierrors.IsAlreadyExists(err) { | ||
log.Info(fmt.Sprintf("Namespace '%s' already exists, skipping", namespaceName)) | ||
} else { | ||
log.Info(fmt.Sprintf("Error creating namespace '%s'", namespaceName)) | ||
} | ||
} else { | ||
log.Info(fmt.Sprintf("Created namespace '%s'", namespaceName)) | ||
} | ||
return err | ||
} | ||
|
||
func DeleteNamespace(options *KubectlOptions, namespaceName string) error { | ||
clientset, err := GetKubernetesClientFromOptions(options) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Info(fmt.Sprintf("Deleting namespace '%s'", namespaceName)) | ||
err = clientset.CoreV1().Namespaces().Delete( | ||
namespaceName, | ||
&metav1.DeleteOptions{}, | ||
) | ||
if err != nil { | ||
log.Warn(fmt.Errorf("Error deleting namespace '%s': %s", namespaceName, err)) | ||
return err | ||
} else { | ||
log.Info(fmt.Sprintf("Deleted namespace '%s'", namespaceName)) | ||
return nil | ||
} | ||
} |
Oops, something went wrong.