-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from rh-messaging/nb-travis-ci-hello-world
Initial travis-ci for qdr-shipshape repo
- Loading branch information
Showing
6 changed files
with
234 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
sudo: required | ||
dist: bionic | ||
language: go | ||
go: | ||
- master | ||
|
||
go_import_path: github.com/rh-messaging/qdr-shipshape | ||
|
||
services: | ||
- docker | ||
|
||
git: | ||
depth: 1 | ||
|
||
env: | ||
global: | ||
- KUBECONFIG=$HOME/.kube/config | ||
- KUBERNETES_VERSION=$(curl -k -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) | ||
- GO111MODULE=on | ||
|
||
before_install: | ||
# Setup kubectl | ||
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/linux/amd64/kubectl | ||
- chmod +x kubectl | ||
- sudo mv kubectl /usr/local/bin/ | ||
|
||
# Get tools | ||
- env GO111MODULE=off go get sigs.k8s.io/kind | ||
- env GO111MODULE=off go get -u github.com/onsi/ginkgo/ginkgo | ||
|
||
# Create a new Kubernetes cluster using KinD | ||
- kind create cluster | ||
- kubectl cluster-info | ||
|
||
|
||
script: | ||
- env GO111MODULE=on make travis-tests | ||
- make unit-tests |
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,29 @@ | ||
package messaging_test | ||
|
||
import ( | ||
"github.com/rh-messaging/qdr-shipshape/pkg/messaging" | ||
"testing" | ||
) | ||
|
||
const ( | ||
message = "Hello_World" | ||
) | ||
|
||
func TestGenerateMessageContent(t *testing.T) { | ||
message_len := len(message) | ||
_test := func(t *testing.T, expected string, _len int) { | ||
received := messaging.GenerateMessageContent(message, _len) | ||
if received != expected { | ||
t.Error( | ||
"Expected", expected, | ||
"Got", received, | ||
) | ||
} | ||
} | ||
|
||
_test(t, message[0:message_len-1], message_len-1) | ||
_test(t, message, message_len) | ||
_test(t, message+"H", message_len+1) | ||
_test(t, "", 0) | ||
_test(t, "", -1) | ||
} |
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,67 @@ | ||
package send_receive | ||
|
||
import ( | ||
"fmt" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/rh-messaging/qdr-shipshape/pkg/spec/interconnect" | ||
"github.com/rh-messaging/shipshape/pkg/api/client/amqp" | ||
"github.com/rh-messaging/shipshape/pkg/api/client/amqp/qeclients" | ||
"github.com/rh-messaging/shipshape/pkg/framework/log" | ||
) | ||
|
||
const ( | ||
MessageCount int = 100 | ||
) | ||
|
||
var _ = Describe("Exchanges AnyCast messages across the nodes", func() { | ||
|
||
It("Exchanges small messages", func() { | ||
var ( | ||
pythonSender *qeclients.AmqpQEClientCommon | ||
pythonReceiver *qeclients.AmqpQEClientCommon | ||
err error | ||
) | ||
|
||
ctx := travisFramework.GetFirstContext() | ||
base_url := fmt.Sprintf("amqp://%s:5672/", interconnect.GetDefaultServiceName(IcInteriorRouterName, ctx.Namespace)) | ||
url := base_url + "anycastAddress" | ||
|
||
By("Deploying one Python sender and one Python receiver") | ||
|
||
pythonSenderBuilder := qeclients.NewSenderBuilder("sender-"+IcInteriorRouterName, qeclients.Python, *ctx, url) | ||
pythonSenderBuilder.Messages(MessageCount) | ||
pythonSenderBuilder.MessageContentFromFile(ConfigMapName, "small-message.txt") | ||
pythonSender, err = pythonSenderBuilder.Build() | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(pythonSender).NotTo(BeNil()) | ||
|
||
pythonReceiverBuilder := qeclients.NewReceiverBuilder("receiver-"+IcInteriorRouterName, qeclients.Python, *ctx, url) | ||
pythonReceiverBuilder.Messages(MessageCount) | ||
pythonReceiver, err = pythonReceiverBuilder.Build() | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(pythonReceiver).NotTo(BeNil()) | ||
|
||
err = pythonSender.Deploy() | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
err = pythonReceiver.Deploy() | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
pythonSender.Wait() | ||
Expect(pythonSender.Status()).To(Equal(amqp.Success)) | ||
|
||
pythonReceiver.Wait() | ||
Expect(pythonReceiver.Status()).To(Equal(amqp.Success)) | ||
|
||
log.Logf("Sender %s - Results - Delivered: %d - Released: %d - Modified: %d", | ||
pythonSender.Name, pythonSender.Result().Delivered, pythonSender.Result().Released, pythonSender.Result().Modified) | ||
|
||
log.Logf("Receiver %s - Results - Delivered: %d - Released: %d - Modified: %d", | ||
pythonReceiver.Name, pythonReceiver.Result().Delivered, pythonReceiver.Result().Released, pythonReceiver.Result().Modified) | ||
|
||
Expect(pythonReceiver.Result().Delivered).To(Equal(MessageCount)) | ||
Expect(pythonSender.Result().Delivered).To(Equal(MessageCount)) | ||
|
||
}) | ||
}) |
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,14 @@ | ||
package send_receive_test | ||
|
||
import ( | ||
"github.com/rh-messaging/qdr-shipshape/pkg/testcommon" | ||
"testing" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
testcommon.Initialize(m) | ||
} | ||
|
||
func TestInterioredge(t *testing.T) { | ||
testcommon.RunSpecs(t, "travis_send_receive", "travis-ci base test") | ||
} |
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,82 @@ | ||
package send_receive | ||
|
||
import ( | ||
"github.com/interconnectedcloud/qdr-operator/pkg/apis/interconnectedcloud/v1alpha1" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/rh-messaging/qdr-shipshape/pkg/messaging" | ||
"github.com/rh-messaging/shipshape/pkg/apps/qdrouterd/deployment" | ||
"github.com/rh-messaging/shipshape/pkg/apps/qdrouterd/qdrmanagement" | ||
"github.com/rh-messaging/shipshape/pkg/apps/qdrouterd/qdrmanagement/entities" | ||
"github.com/rh-messaging/shipshape/pkg/framework" | ||
"github.com/rh-messaging/shipshape/pkg/framework/operators" | ||
v1 "k8s.io/api/core/v1" | ||
"time" | ||
) | ||
|
||
const ( | ||
IcInteriorRouterName = "interior" | ||
ConfigMapName = "messaging-files" | ||
) | ||
|
||
var IcInteriorRouterSpec *v1alpha1.InterconnectSpec = &v1alpha1.InterconnectSpec{ | ||
DeploymentPlan: v1alpha1.DeploymentPlanType{ | ||
Size: 1, | ||
Image: "quay.io/interconnectedcloud/qdrouterd:latest", | ||
Role: "interior", | ||
Placement: "Any", | ||
}, | ||
} | ||
|
||
var ( | ||
travisFramework *framework.Framework | ||
ConfigMap *v1.ConfigMap | ||
) | ||
|
||
var _ = BeforeEach(func() { | ||
// Initializes using only Qdr Operator | ||
travisFramework = framework.NewFrameworkBuilder("travis").WithBuilders(operators.SupportedOperators[operators.OperatorTypeQdr]).Build() | ||
|
||
messaging.GenerateSmallMediumLargeMessagesConfigMap(travisFramework, ConfigMapName) | ||
|
||
deployInterconnect() | ||
By("Validating router created") | ||
time.Sleep(5 * time.Second) //wait for router to start | ||
validateNetwork() | ||
}) | ||
|
||
func validateNetwork() { | ||
var delayS int = 10 | ||
var timeoutS int = 60 | ||
ctx := travisFramework.GetFirstContext() | ||
|
||
podList, err := ctx.ListPodsForDeploymentName(IcInteriorRouterName) | ||
Expect(err).To(BeNil()) | ||
Expect(len(podList.Items)).To(Equal(1)) | ||
pod := podList.Items[0] | ||
|
||
nodes, err := qdrmanagement.QdmanageQueryWithRetries(*ctx, pod.Name, entities.Node{}, delayS, | ||
timeoutS, nil, func(es []entities.Entity, err error) bool { | ||
return err != nil || len(es) == 1 //what does this mean? | ||
}) | ||
|
||
Expect(err).To(BeNil()) | ||
Expect(len(nodes)).To(Equal(1)) | ||
} | ||
|
||
func deployInterconnect() { | ||
// Deploying Interconnect using provided context | ||
ctx := travisFramework.GetFirstContext() | ||
|
||
ic, err := deployment.CreateInterconnectFromSpec(*ctx, IcInteriorRouterSpec.DeploymentPlan.Size, | ||
IcInteriorRouterName, *IcInteriorRouterSpec) | ||
|
||
Expect(err).To(BeNil()) | ||
Expect(ic).NotTo(BeNil()) | ||
|
||
// Wait for Interconnect deployment | ||
err = framework.WaitForDeployment(ctx.Clients.KubeClient, ctx.Namespace, | ||
IcInteriorRouterName, int(IcInteriorRouterSpec.DeploymentPlan.Size), | ||
framework.RetryInterval, framework.Timeout) | ||
Expect(err).To(BeNil()) | ||
} |