Skip to content

Commit

Permalink
Fix meshgw tests (#3532)
Browse files Browse the repository at this point in the history
* Fix meshgw tests

* change protocol on mesh gw tests to tcp from mesh
  • Loading branch information
jm96441n committed Feb 1, 2024
1 parent a054e33 commit f694158
Showing 1 changed file with 144 additions and 2 deletions.
146 changes: 144 additions & 2 deletions control-plane/controllers/resources/mesh_gateway_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"testing"

logrtest "github.com/go-logr/logr/testr"
"github.com/hashicorp/consul/sdk/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
Expand All @@ -21,6 +20,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

pbmesh "github.com/hashicorp/consul/proto-public/pbmesh/v2beta1"
"github.com/hashicorp/consul/sdk/testutil"

"github.com/hashicorp/consul-k8s/control-plane/api/mesh/v2beta1"
"github.com/hashicorp/consul-k8s/control-plane/helper/test"
)
Expand Down Expand Up @@ -50,6 +52,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "consul",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
},
request: ctrl.Request{
Expand All @@ -73,6 +85,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "default",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&corev1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -99,6 +121,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "consul",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
},
request: ctrl.Request{
Expand All @@ -122,6 +154,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "default",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&rbacv1.Role{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -148,6 +190,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Name: "mesh-gateway",
UID: "abc123",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&rbacv1.Role{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -180,6 +232,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "consul",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
},
request: ctrl.Request{
Expand All @@ -203,6 +265,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "default",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -229,6 +301,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Name: "mesh-gateway",
UID: "abc123",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -261,6 +343,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "consul",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
},
request: ctrl.Request{
Expand All @@ -284,6 +376,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "default",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -310,6 +412,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Name: "mesh-gateway",
UID: "abc123",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -342,6 +454,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "consul",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
},
request: ctrl.Request{
Expand All @@ -365,6 +487,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Namespace: "default",
Name: "mesh-gateway",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -391,6 +523,16 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {
Name: "mesh-gateway",
UID: "abc123",
},
Spec: pbmesh.MeshGateway{
GatewayClassName: "consul",
Listeners: []*pbmesh.MeshGatewayListener{
{
Name: "wan",
Port: 8443,
Protocol: "tcp",
},
},
},
},
&corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -444,7 +586,7 @@ func TestMeshGatewayController_Reconcile(t *testing.T) {

res, err := controller.Reconcile(context.Background(), testCase.request)
if testCase.expectedErr != nil {
//require.EqualError(t, err, testCase.expectedErr.Error())
// require.EqualError(t, err, testCase.expectedErr.Error())
require.ErrorIs(t, err, testCase.expectedErr)
} else {
require.NoError(t, err)
Expand Down

0 comments on commit f694158

Please sign in to comment.