-
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.
- Loading branch information
Wil Simpson
committed
Mar 21, 2024
1 parent
a52d4b8
commit ffb2aee
Showing
5 changed files
with
143 additions
and
1 deletion.
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,12 @@ | ||
package e2e_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Character e2e", func() { | ||
It("should work", func() { | ||
Expect(true).To(BeTrue()) | ||
}) | ||
}) |
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,12 @@ | ||
package e2e_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Chat e2e", func() { | ||
It("should work", func() { | ||
Expect(true).To(BeTrue()) | ||
}) | ||
}) |
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,102 @@ | ||
package e2e_test | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"encoding/gob" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/bxcodec/faker/v4" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/tools/clientcmd" | ||
) | ||
|
||
var ( | ||
clientset *kubernetes.Clientset | ||
testData *setupData | ||
) | ||
|
||
func TestE2e(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "E2E Suite") | ||
} | ||
|
||
type setupData struct { | ||
// Namespace used for SRO | ||
Namespace string | ||
|
||
// Namespace used for Agones | ||
AgonesNamespace string | ||
} | ||
|
||
var _ = SynchronizedBeforeSuite(func(ctx context.Context) []byte { | ||
testData := setupData{ | ||
Namespace: "sro-testing-" + faker.Username(), | ||
AgonesNamespace: "agones-system-testing-" + faker.Username(), | ||
} | ||
setupClientSet() | ||
|
||
Expect(clientset.CoreV1().Namespaces().Create( | ||
ctx, | ||
&corev1.Namespace{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: testData.Namespace, | ||
}, | ||
}, | ||
metav1.CreateOptions{}, | ||
)).To(Succeed()) | ||
Expect(clientset.CoreV1().Namespaces().Create( | ||
ctx, | ||
&corev1.Namespace{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: testData.AgonesNamespace, | ||
}, | ||
}, | ||
metav1.CreateOptions{}, | ||
)).To(Succeed()) | ||
|
||
return testData.encode() | ||
}, func(data []byte) { | ||
testData = decodeSetupData(data) | ||
setupClientSet() | ||
}) | ||
|
||
var _ = SynchronizedAfterSuite(func() {}, func(ctx context.Context) { | ||
Expect(clientset.CoreV1().Namespaces().Delete(ctx, testData.Namespace, metav1.DeleteOptions{})). | ||
NotTo(HaveOccurred()) | ||
Expect(clientset.CoreV1().Namespaces().Delete(ctx, testData.AgonesNamespace, metav1.DeleteOptions{})). | ||
NotTo(HaveOccurred()) | ||
}) | ||
|
||
func setupClientSet() { | ||
homeDir, err := os.UserHomeDir() | ||
Expect(err).NotTo(HaveOccurred(), "unable to get home directory") | ||
Expect(homeDir).NotTo(BeEmpty()) | ||
|
||
config, err := clientcmd.BuildConfigFromFlags("", filepath.Join(homeDir, ".kube", "config")) | ||
Expect(err).NotTo(HaveOccurred(), "unable to get kubernetes config") | ||
|
||
clientset, err = kubernetes.NewForConfig(config) | ||
Expect(err).NotTo(HaveOccurred(), "kubernetes config invalid") | ||
} | ||
|
||
func (s *setupData) encode() []byte { | ||
var buf *bytes.Buffer | ||
enc := gob.NewEncoder(buf) | ||
Expect(enc.Encode(s)).NotTo(HaveOccurred()) | ||
return buf.Bytes() | ||
} | ||
|
||
func decodeSetupData(in []byte) *setupData { | ||
buf := bytes.NewBuffer(in) | ||
out := &setupData{} | ||
dec := gob.NewDecoder(buf) | ||
Expect(dec.Decode(out)).NotTo(HaveOccurred()) | ||
return out | ||
} |
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,12 @@ | ||
package e2e_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Gamebackend e2e", func() { | ||
It("should work", func() { | ||
Expect(true).To(BeTrue()) | ||
}) | ||
}) |