Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,20 @@ jobs:
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc
with:
registry: true
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f
with:
driver-opts: network=host
buildkitd-config-inline: |
[registry."kind-registry:5000"]
http = true
- uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8
with:
tags: ${{ steps.kind.outputs.LOCAL_REGISTRY }}/tmpbbs:test
build-args: |
VERSION=test
COMMIT=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
Expand Down
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ linters:
- gochecknoglobals
- godoclint
- gosec
- noctx
- paralleltest
- path: tests/integration
linters:
Expand Down
50 changes: 23 additions & 27 deletions tests/integration/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package integration_test
import (
"fmt"
"os/exec"
"path/filepath"
"testing"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -11,50 +12,45 @@ import (
"github.com/onsi/gomega/gexec"
)

const (
mainPort = 7800
mainOverlay = "kustomize/main"
mainNamespace = "tmpbbs"
)
const mainPort = 7800

var (
mainURL = fmt.Sprintf("http://localhost:%d", mainPort)
mainPortForwardSession *gexec.Session
)
var mainURL = fmt.Sprintf("http://localhost:%d", mainPort)

var _ = BeforeSuite(func() {
var (
session *gexec.Session
err error
)
deployOverlay("main", mainPort)
})

command := exec.Command("kubectl", "apply", "--kustomize", mainOverlay)
session, err = gexec.Start(command, GinkgoWriter, GinkgoWriter)
func TestIntegration(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Integration Suite")
}

func deployOverlay(name string, port int) {
path := filepath.Join("kustomize", name)
namespace := "tmpbbs-" + name

command := exec.Command("kubectl", "apply", "--kustomize", path)
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(session).Should(gexec.Exit(0))
DeferCleanup(func() {
deleteCommand := exec.Command("kubectl", "delete", "--kustomize", mainOverlay)
deleteCommand := exec.Command("kubectl", "delete", "--kustomize", path)
deleteSession, deleteErr := gexec.Start(deleteCommand, GinkgoWriter, GinkgoWriter)
Expect(deleteErr).NotTo(HaveOccurred())
Eventually(deleteSession, "30s").Should(gexec.Exit(0))
})

command = exec.Command("kubectl", "rollout", "status", "statefulset/tmpbbs", "--namespace", mainNamespace)
command = exec.Command("kubectl", "rollout", "status", "statefulset/tmpbbs", "--namespace", namespace)
session, err = gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(session, "2m30s").Should(gexec.Exit(0))

command = exec.Command("kubectl", "port-forward", "service/tmpbbs-http", "--namespace", mainNamespace,
fmt.Sprintf("%d:8080", mainPort))
mainPortForwardSession, err = gexec.Start(command, GinkgoWriter, GinkgoWriter)
command = exec.Command("kubectl", "port-forward", "service/tmpbbs-http", "--namespace", namespace,
fmt.Sprintf("%d:8080", port))
portForwardSession, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(mainPortForwardSession, "10s").Should(gbytes.Say("Forwarding from"))
Eventually(portForwardSession, "10s").Should(gbytes.Say("Forwarding from"))
DeferCleanup(func() {
mainPortForwardSession.Terminate()
portForwardSession.Terminate()
})
})

func TestIntegration(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Integration Suite")
}
2 changes: 2 additions & 0 deletions tests/integration/kustomize/main/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ images:
newName: kind-registry:5000/tmpbbs
newTag: test

namespace: tmpbbs-main

patches:
- path: tmpbbs.statefulset.yaml

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/kustomize/peer/tmpbbs.statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ spec:
- name: TMPBBS_CONFIG_FILE
value:
- name: TMPBBS_PULL_PEERS
value: tmpbbs-2.tmpbbs.tmpbbs.svc.cluster.local:8081
value: tmpbbs-2.tmpbbs.tmpbbs-main.svc.cluster.local:8081
40 changes: 5 additions & 35 deletions tests/integration/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,18 @@ import (
"io"
"net/http"
"net/url"
"os/exec"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
)

const (
peerPort = 7801
peerOverlay = "kustomize/peer"
peerNamespace = "tmpbbs-peer"
)

var _ = Describe("peer", Ordered, func() {
peerURL := fmt.Sprintf("http://localhost:%d", peerPort)
var tmpbbsURL string

BeforeAll(func() {
command := exec.Command("kubectl", "apply", "--kustomize", peerOverlay)
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(session).Should(gexec.Exit(0))
DeferCleanup(func() {
deleteCommand := exec.Command("kubectl", "delete", "--kustomize", peerOverlay)
deleteSession, deleteErr := gexec.Start(deleteCommand, GinkgoWriter, GinkgoWriter)
Expect(deleteErr).NotTo(HaveOccurred())
Eventually(deleteSession, "30s").Should(gexec.Exit(0))
})

command = exec.Command("kubectl", "rollout", "status", "statefulset/tmpbbs", "--namespace", peerNamespace)
session, err = gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(session, "1m").Should(gexec.Exit(0))

command = exec.Command("kubectl", "port-forward", "service/tmpbbs-http", "--namespace", peerNamespace,
fmt.Sprintf("%d:8080", peerPort))
peerPortForwardSession, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(peerPortForwardSession, "10s").Should(gbytes.Say("Forwarding from"))
DeferCleanup(func() {
peerPortForwardSession.Terminate()
})
port := 7801
deployOverlay("peer", port)
tmpbbsURL = fmt.Sprintf("http://localhost:%d", port)
})

It("pulls a post from main", func() {
Expand All @@ -59,7 +29,7 @@ var _ = Describe("peer", Ordered, func() {
Expect(resp.StatusCode).To(Equal(http.StatusOK))

Eventually(func() string {
peerResp, peerErr := http.Get(peerURL)
peerResp, peerErr := http.Get(tmpbbsURL)
Expect(peerErr).NotTo(HaveOccurred())
Expect(peerResp.StatusCode).To(Equal(http.StatusOK))
body, bodyErr := io.ReadAll(peerResp.Body)
Expand Down
Loading