Skip to content

Commit

Permalink
Handle reviewer comments on E2E pod scheduling patch
Browse files Browse the repository at this point in the history
* ClusterIndex
* addNodeSelectorRequirement function extracted
* Testing the GW to GW case along with the NonGW to NonGW case.
  • Loading branch information
mangelajo committed Sep 16, 2019
1 parent d04a4f3 commit 8dee790
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
4 changes: 2 additions & 2 deletions test/e2e/dataplane/tcp_pod_to_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ var _ = Describe("[dataplane] Basic Pod to Service tests across clusters without
testPod2ServiceTCP(f, framework.NonGatewayNode, framework.NonGatewayNode)
})

It("Should be able to perform a Pod to Service TCP connection and exchange data between different clusters NonGW to GW", func() {
testPod2ServiceTCP(f, framework.NonGatewayNode, framework.GatewayNode)
It("Should be able to perform a Pod to Service TCP connection and exchange data between different clusters GW to GW", func() {
testPod2ServiceTCP(f, framework.GatewayNode, framework.GatewayNode)
})
})

Expand Down
6 changes: 3 additions & 3 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const (
PollInterval = 100 * time.Millisecond
)

type TestCluster int
type ClusterIndex int

const (
ClusterA TestCluster = iota
ClusterA ClusterIndex = iota
ClusterB
ClusterC
)
Expand Down Expand Up @@ -109,7 +109,7 @@ func (f *Framework) BeforeEach() {
}

for idx, clientSet := range f.ClusterClients {
switch TestCluster(idx) {
switch ClusterIndex(idx) {
case ClusterA: // On the first cluster we let k8s generate a name for the namespace
namespace := generateNamespace(clientSet, f.BaseName, namespaceLabels)
f.Namespace = namespace.GetName()
Expand Down
30 changes: 13 additions & 17 deletions test/e2e/framework/network_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
// create a test pod inside the current test namespace on the specified cluster.
// The pod will listen on TestPort over TCP, send sendString over the connection,
// and write the network response in the pod termination log, then exit with 0 status
func (f *Framework) CreateTCPCheckListenerPod(cluster TestCluster, scheduling TestPodScheduling, sendString string) *v1.Pod {
func (f *Framework) CreateTCPCheckListenerPod(cluster ClusterIndex, scheduling TestPodScheduling, sendString string) *v1.Pod {

tcpCheckListenerPod := v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -54,7 +54,7 @@ func (f *Framework) CreateTCPCheckListenerPod(cluster TestCluster, scheduling Te
// The pod will connect to remoteIP:TestPort over TCP, send sendString over the
// connection, and write the network response in the pod termination log, then
// exit with 0 status
func (f *Framework) CreateTCPCheckConnectorPod(cluster TestCluster, scheduling TestPodScheduling, remoteIP string, sendString string) *v1.Pod {
func (f *Framework) CreateTCPCheckConnectorPod(cluster ClusterIndex, scheduling TestPodScheduling, remoteIP string, sendString string) *v1.Pod {

tcpCheckConnectorPod := v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -105,23 +105,11 @@ func nodeAffinity(scheduling TestPodScheduling) *v1.Affinity {

switch scheduling {
case GatewayNode:
nodeSelReqs = append(nodeSelReqs, v1.NodeSelectorRequirement{
Key: gatewayLabel,
Operator: v1.NodeSelectorOpIn,
Values: []string{"true"},
})
addNodeSelectorRequirement(&nodeSelReqs, gatewayLabel, v1.NodeSelectorOpIn, []string{"true"})

case NonGatewayNode:
nodeSelReqs = append(nodeSelReqs, v1.NodeSelectorRequirement{
Key: gatewayLabel,
Operator: v1.NodeSelectorOpDoesNotExist,
})

nodeSelReqs = append(nodeSelReqs, v1.NodeSelectorRequirement{
Key: gatewayLabel,
Operator: v1.NodeSelectorOpNotIn,
Values: []string{"true"},
})
addNodeSelectorRequirement(&nodeSelReqs, gatewayLabel, v1.NodeSelectorOpDoesNotExist, nil)
addNodeSelectorRequirement(&nodeSelReqs, gatewayLabel, v1.NodeSelectorOpNotIn, []string{"true"})
}

affinity := v1.Affinity{
Expand All @@ -137,3 +125,11 @@ func nodeAffinity(scheduling TestPodScheduling) *v1.Affinity {
}
return &affinity
}

func addNodeSelectorRequirement(nodeSelReqs *[]v1.NodeSelectorRequirement, label string, op v1.NodeSelectorOperator, values []string) {
*nodeSelReqs = append(*nodeSelReqs, v1.NodeSelectorRequirement{
Key: label,
Operator: v1.NodeSelectorOpNotIn,
Values: []string{"true"},
})
}
4 changes: 2 additions & 2 deletions test/e2e/framework/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
. "github.com/onsi/gomega"
)

func (f *Framework) WaitForPodToBeReady(waitedPod *v1.Pod, cluster TestCluster) *v1.Pod {
func (f *Framework) WaitForPodToBeReady(waitedPod *v1.Pod, cluster ClusterIndex) *v1.Pod {
var finalPod *v1.Pod
pc := f.ClusterClients[cluster].CoreV1().Pods(f.Namespace)
err := wait.PollImmediate(5*time.Second, 2*time.Minute, func() (bool, error) {
Expand All @@ -36,7 +36,7 @@ func (f *Framework) WaitForPodToBeReady(waitedPod *v1.Pod, cluster TestCluster)
return finalPod
}

func (f *Framework) WaitForPodFinishStatus(waitedPod *v1.Pod, cluster TestCluster) (terminationCode int32, terminationMessage string) {
func (f *Framework) WaitForPodFinishStatus(waitedPod *v1.Pod, cluster ClusterIndex) (terminationCode int32, terminationMessage string) {
pc := f.ClusterClients[cluster].CoreV1().Pods(f.Namespace)
err := wait.PollImmediate(5*time.Second, 2*time.Minute, func() (bool, error) {
pod, err := pc.Get(waitedPod.Name, metav1.GetOptions{})
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
TestAppLabel = "test-app"
)

func (f *Framework) CreateTCPService(cluster TestCluster, selectorName string, port int) *v1.Service {
func (f *Framework) CreateTCPService(cluster ClusterIndex, selectorName string, port int) *v1.Service {

tcpService := v1.Service{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 8dee790

Please sign in to comment.