Skip to content

Commit 74debed

Browse files
chore(github-actions): test execution with low resources (#5729)
* chore(gihtub-actions): added test execution with low resources Signed-off-by: ivan katliarchuk <[email protected]> * chore(gihtub-actions): added test execution with low resources Signed-off-by: ivan katliarchuk <[email protected]> * chore(gihtub-actions): added test execution with low resources Signed-off-by: ivan katliarchuk <[email protected]> * chore(gihtub-actions): added test execution with low resources Signed-off-by: ivan katliarchuk <[email protected]> * chore(gihtub-actions): added test execution with low resources Signed-off-by: ivan katliarchuk <[email protected]> * chore(gihtub-actions): added test execution with low resources Signed-off-by: ivan katliarchuk <[email protected]> * chore(gihtub-actions): added test execution with low resources Signed-off-by: ivan katliarchuk <[email protected]> * chore(gihtub-actions): added test execution with low resources Signed-off-by: ivan katliarchuk <[email protected]> * chore(gihtub-actions): added test execution with low resources Signed-off-by: ivan katliarchuk <[email protected]> --------- Signed-off-by: ivan katliarchuk <[email protected]>
1 parent 111df9f commit 74debed

File tree

3 files changed

+83
-75
lines changed

3 files changed

+83
-75
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
check-latest: true
3535
id: go
3636

37-
- name: Install CI
37+
- name: Install Dependencies
3838
run: |
3939
go get -v -t -d ./...
4040
@@ -45,6 +45,9 @@ jobs:
4545
if: github.actor == 'nektos/act' && matrix.os == 'ubuntu-latest'
4646

4747
- name: Test
48+
env:
49+
GOMAXPROCS: 1
50+
GOMEMLIMIT: 2048MiB
4851
run: make test
4952

5053
- name: Send coverage

source/istio_gateway_test.go

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package source
1919
import (
2020
"context"
2121
"errors"
22+
"fmt"
2223
"testing"
2324

2425
"github.com/stretchr/testify/assert"
@@ -30,6 +31,7 @@ import (
3031
v1 "k8s.io/api/core/v1"
3132
networkv1 "k8s.io/api/networking/v1"
3233
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
34+
"k8s.io/apimachinery/pkg/types"
3335
"k8s.io/client-go/kubernetes/fake"
3436

3537
"sigs.k8s.io/external-dns/endpoint"
@@ -1523,25 +1525,6 @@ func testGatewayEndpoints(t *testing.T) {
15231525
}
15241526

15251527
func TestGatewaySource_GWSelectorMatchServiceSelector(t *testing.T) {
1526-
svc := &v1.Service{
1527-
ObjectMeta: metav1.ObjectMeta{
1528-
Name: "fake-service",
1529-
Namespace: "default",
1530-
},
1531-
Spec: v1.ServiceSpec{
1532-
Selector: map[string]string{
1533-
"app": "demo",
1534-
"env": "prod",
1535-
"team": "devops",
1536-
"version": "v1",
1537-
"release": "stable",
1538-
"track": "daily",
1539-
"tier": "backend",
1540-
},
1541-
ExternalIPs: []string{"10.10.10.255"},
1542-
},
1543-
}
1544-
15451528
tests := []struct {
15461529
name string
15471530
selectors map[string]string
@@ -1585,25 +1568,31 @@ func TestGatewaySource_GWSelectorMatchServiceSelector(t *testing.T) {
15851568
},
15861569
}
15871570

1588-
for _, tt := range tests {
1571+
for i, tt := range tests {
15891572
t.Run(tt.name, func(t *testing.T) {
15901573
fakeKubeClient := fake.NewClientset()
15911574
fakeIstioClient := istiofake.NewSimpleClientset()
15921575

1593-
src, err := NewIstioGatewaySource(
1594-
t.Context(),
1595-
fakeKubeClient,
1596-
fakeIstioClient,
1597-
"",
1598-
"",
1599-
"",
1600-
false,
1601-
false,
1602-
)
1603-
require.NoError(t, err)
1604-
require.NotNil(t, src)
1605-
1606-
_, err = fakeKubeClient.CoreV1().Services(svc.Namespace).Create(t.Context(), svc, metav1.CreateOptions{})
1576+
svc := &v1.Service{
1577+
ObjectMeta: metav1.ObjectMeta{
1578+
Name: "fake-service",
1579+
Namespace: "default",
1580+
UID: types.UID(fmt.Sprintf("fake-service-uid-%d", i)),
1581+
},
1582+
Spec: v1.ServiceSpec{
1583+
Selector: map[string]string{
1584+
"app": "demo",
1585+
"env": "prod",
1586+
"team": "devops",
1587+
"version": "v1",
1588+
"release": "stable",
1589+
"track": "daily",
1590+
"tier": "backend",
1591+
},
1592+
ExternalIPs: []string{"10.10.10.255"},
1593+
},
1594+
}
1595+
_, err := fakeKubeClient.CoreV1().Services(svc.Namespace).Create(t.Context(), svc, metav1.CreateOptions{})
16071596
require.NoError(t, err)
16081597

16091598
gw := &networkingv1beta1.Gateway{
@@ -1624,6 +1613,19 @@ func TestGatewaySource_GWSelectorMatchServiceSelector(t *testing.T) {
16241613
_, err = fakeIstioClient.NetworkingV1beta1().Gateways(gw.Namespace).Create(context.Background(), gw, metav1.CreateOptions{})
16251614
require.NoError(t, err)
16261615

1616+
src, err := NewIstioGatewaySource(
1617+
t.Context(),
1618+
fakeKubeClient,
1619+
fakeIstioClient,
1620+
"",
1621+
"",
1622+
"",
1623+
false,
1624+
false,
1625+
)
1626+
require.NoError(t, err)
1627+
require.NotNil(t, src)
1628+
16271629
res, err := src.Endpoints(t.Context())
16281630
require.NoError(t, err)
16291631

source/istio_virtualservice_test.go

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package source
1919
import (
2020
"context"
2121
"errors"
22+
"fmt"
2223
"testing"
2324

2425
"github.com/stretchr/testify/assert"
@@ -31,6 +32,7 @@ import (
3132
v1 "k8s.io/api/core/v1"
3233
networkv1 "k8s.io/api/networking/v1"
3334
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35+
"k8s.io/apimachinery/pkg/types"
3436
"k8s.io/client-go/kubernetes/fake"
3537

3638
"sigs.k8s.io/external-dns/endpoint"
@@ -49,7 +51,7 @@ type VirtualServiceSuite struct {
4951
}
5052

5153
func (suite *VirtualServiceSuite) SetupTest() {
52-
fakeKubernetesClient := fake.NewSimpleClientset()
54+
fakeKubernetesClient := fake.NewClientset()
5355
fakeIstioClient := istiofake.NewSimpleClientset()
5456
var err error
5557

@@ -189,7 +191,7 @@ func TestNewIstioVirtualServiceSource(t *testing.T) {
189191

190192
_, err := NewIstioVirtualServiceSource(
191193
context.TODO(),
192-
fake.NewSimpleClientset(),
194+
fake.NewClientset(),
193195
istiofake.NewSimpleClientset(),
194196
"",
195197
ti.annotationFilter,
@@ -2213,26 +2215,7 @@ func TestVirtualServiceSourceGetGateway(t *testing.T) {
22132215
}
22142216
}
22152217

2216-
func TestGatewaySource_GWVServiceSelectorMatchServiceSelector(t *testing.T) {
2217-
svc := &v1.Service{
2218-
ObjectMeta: metav1.ObjectMeta{
2219-
Name: "fake-service",
2220-
Namespace: "default",
2221-
},
2222-
Spec: v1.ServiceSpec{
2223-
Selector: map[string]string{
2224-
"app": "demo",
2225-
"env": "prod",
2226-
"team": "devops",
2227-
"version": "v1",
2228-
"release": "stable",
2229-
"track": "daily",
2230-
"tier": "backend",
2231-
},
2232-
ExternalIPs: []string{"10.10.10.255"},
2233-
},
2234-
}
2235-
2218+
func TestIstioVirtualServiceSource_GWServiceSelectorMatchServiceSelector(t *testing.T) {
22362219
tests := []struct {
22372220
name string
22382221
selectors map[string]string
@@ -2244,7 +2227,7 @@ func TestGatewaySource_GWVServiceSelectorMatchServiceSelector(t *testing.T) {
22442227
"version": "v1",
22452228
},
22462229
expected: []*endpoint.Endpoint{
2247-
endpoint.NewEndpoint("example.org", endpoint.RecordTypeA, "10.10.10.255").WithLabel("resource", "gateway/default/fake-gateway"),
2230+
endpoint.NewEndpoint("example.org", endpoint.RecordTypeA, "10.10.10.255").WithLabel("resource", "virtualservice/default/fake-vservice"),
22482231
},
22492232
},
22502233
{
@@ -2259,7 +2242,7 @@ func TestGatewaySource_GWVServiceSelectorMatchServiceSelector(t *testing.T) {
22592242
"tier": "backend",
22602243
},
22612244
expected: []*endpoint.Endpoint{
2262-
endpoint.NewEndpoint("example.org", endpoint.RecordTypeA, "10.10.10.255").WithLabel("resource", "gateway/default/fake-gateway"),
2245+
endpoint.NewEndpoint("example.org", endpoint.RecordTypeA, "10.10.10.255").WithLabel("resource", "virtualservice/default/fake-vservice"),
22632246
},
22642247
},
22652248
{
@@ -2271,29 +2254,36 @@ func TestGatewaySource_GWVServiceSelectorMatchServiceSelector(t *testing.T) {
22712254
"app": "demo",
22722255
},
22732256
expected: []*endpoint.Endpoint{
2274-
endpoint.NewEndpoint("example.org", endpoint.RecordTypeA, "10.10.10.255").WithLabel("resource", "gateway/default/fake-gateway"),
2257+
endpoint.NewEndpoint("example.org", endpoint.RecordTypeA, "10.10.10.255").WithLabel("resource", "virtualservice/default/fake-vservice"),
22752258
},
22762259
},
22772260
}
2278-
for _, tt := range tests {
2261+
for i, tt := range tests {
22792262
t.Run(tt.name, func(t *testing.T) {
22802263
fakeKubeClient := fake.NewClientset()
22812264
fakeIstioClient := istiofake.NewSimpleClientset()
22822265

2283-
src, err := NewIstioGatewaySource(
2284-
t.Context(),
2285-
fakeKubeClient,
2286-
fakeIstioClient,
2287-
"",
2288-
"",
2289-
"",
2290-
false,
2291-
false,
2292-
)
2293-
require.NoError(t, err)
2294-
require.NotNil(t, src)
2266+
svc := &v1.Service{
2267+
ObjectMeta: metav1.ObjectMeta{
2268+
Name: "fake-service",
2269+
Namespace: "default",
2270+
UID: types.UID(fmt.Sprintf("fake-service-uid-%d", i)),
2271+
},
2272+
Spec: v1.ServiceSpec{
2273+
Selector: map[string]string{
2274+
"app": "demo",
2275+
"env": "prod",
2276+
"team": "devops",
2277+
"version": "v1",
2278+
"release": "stable",
2279+
"track": "daily",
2280+
"tier": "backend",
2281+
},
2282+
ExternalIPs: []string{"10.10.10.255"},
2283+
},
2284+
}
22952285

2296-
_, err = fakeKubeClient.CoreV1().Services(svc.Namespace).Create(context.Background(), svc, metav1.CreateOptions{})
2286+
_, err := fakeKubeClient.CoreV1().Services(svc.Namespace).Create(context.Background(), svc, metav1.CreateOptions{})
22972287
require.NoError(t, err)
22982288

22992289
gw := &networkingv1beta1.Gateway{
@@ -2315,7 +2305,7 @@ func TestGatewaySource_GWVServiceSelectorMatchServiceSelector(t *testing.T) {
23152305
require.NoError(t, err)
23162306

23172307
gwService := &networkingv1beta1.VirtualService{
2318-
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "default"},
2308+
ObjectMeta: metav1.ObjectMeta{Name: "fake-vservice", Namespace: "default"},
23192309
Spec: istionetworking.VirtualService{
23202310
Gateways: []string{gw.Namespace + "/" + gw.Name},
23212311
Hosts: []string{"example.org"},
@@ -2325,6 +2315,19 @@ func TestGatewaySource_GWVServiceSelectorMatchServiceSelector(t *testing.T) {
23252315
_, err = fakeIstioClient.NetworkingV1beta1().VirtualServices(gwService.Namespace).Create(t.Context(), gwService, metav1.CreateOptions{})
23262316
require.NoError(t, err)
23272317

2318+
src, err := NewIstioVirtualServiceSource(
2319+
t.Context(),
2320+
fakeKubeClient,
2321+
fakeIstioClient,
2322+
"",
2323+
"",
2324+
"",
2325+
false,
2326+
false,
2327+
)
2328+
require.NoError(t, err)
2329+
require.NotNil(t, src)
2330+
23282331
res, err := src.Endpoints(t.Context())
23292332
require.NoError(t, err)
23302333

0 commit comments

Comments
 (0)