Skip to content

Commit 9b24dbd

Browse files
authored
test: [NPM] Use fakeexec for ipsm and iptm tests (#868)
* iptmgr * more iptm testing * grep call * progress * progress * ipsm * ioshim * update tests * package restructure * fix broken test and delint * reduce scope of ioshim * reduce scope of ioshim * ioshim scope * require no error, retrigger ci * ut return multiple results * fix tests from master changes * unexport ioshim * update ut * fix tests * vendor * test fix * go version * go version * pipeline fixes * fix tests
1 parent a53c2f8 commit 9b24dbd

File tree

22 files changed

+720
-582
lines changed

22 files changed

+720
-582
lines changed

.github/workflows/cyclonus-netpol-test.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ jobs:
2121
- name: Checkout
2222
uses: actions/checkout@v2
2323

24-
24+
- uses: actions/setup-go@v2
25+
with:
26+
go-version: '^1.16'
2527

2628
- name: Setup Kind
2729
uses: engineerd/[email protected]
@@ -44,10 +46,11 @@ jobs:
4446
kind load docker-image acnpublic.azurecr.io/azure-npm:cyclonus --name npm-kind
4547
kubectl apply -f ./npm/azure-npm.yaml
4648
47-
- name: Check Kind after installation
49+
- name: Check Cluster Components
4850
run: |
4951
sleep 10
5052
kubectl get po -owide -A
53+
kubectl describe ds azure-npm -n kube-system
5154
5255
- name: Run Cyclonus network policy test
5356
run: make test-cyclonus

.github/workflows/repo-hygiene.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
go-version: [1.16.x]
16-
os: [ubuntu-latest, windows-latest]
16+
os: [ubuntu-latest]
1717
name: Lint
1818
runs-on: ${{ matrix.os }}
1919
steps:

.pipelines/npm/npm-conformance-tests.yaml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
trigger:
2-
- main
2+
- master
33

44
variables:
55
- name: AZURE_CLUSTER
@@ -17,15 +17,15 @@ jobs:
1717
demands:
1818
- agent.os -equals Linux
1919
- Role -equals Build
20-
container:
21-
image: "$(BUILD_IMAGE)"
2220
steps:
2321

2422
- checkout: self
2523

2624
- script: |
27-
go env
2825
go version
26+
go env
27+
which go
28+
echo $PATH
2929
mkdir -p '$(GOBIN)'
3030
mkdir -p '$(GOPATH)/pkg'
3131
BUILD_NUMBER=$(Build.BuildNumber)
@@ -48,8 +48,6 @@ jobs:
4848
demands:
4949
- agent.os -equals Linux
5050
- Role -equals Build
51-
container:
52-
image: "$(BUILD_IMAGE)"
5351
dependsOn: [setup]
5452
variables:
5553
GOBIN: "$(GOPATH)/bin" # Go binaries path
@@ -72,7 +70,6 @@ jobs:
7270
addPipelineData: false
7371

7472
- script: |
75-
go env
7673
echo Tag: $(TAG)
7774
echo ResourceGroup: $(RESOURCE_GROUP)
7875
VERSION=$(TAG) make azure-npm-image
@@ -91,6 +88,7 @@ jobs:
9188
- bash: |
9289
cd kubernetes
9390
git checkout vakr/sleepinnpmtests
91+
export PATH=$PATH:/usr/local/go/bin/
9492
make WHAT=test/e2e/e2e.test
9593
displayName: 'Build Kubernetes e2e.test'
9694
- publish: $(System.DefaultWorkingDirectory)/kubernetes/_output/local/bin/linux/amd64
@@ -104,8 +102,6 @@ jobs:
104102
demands:
105103
- agent.os -equals Linux
106104
- Role -equals Build
107-
container:
108-
image: "$(BUILD_IMAGE)"
109105
dependsOn: [setup]
110106
variables:
111107
RESOURCE_GROUP: $[ dependencies.setup.outputs['EnvironmentalVariables.RESOURCE_GROUP'] ]
@@ -140,8 +136,6 @@ jobs:
140136
demands:
141137
- agent.os -equals Linux
142138
- Role -equals Build
143-
container:
144-
image: "$(BUILD_IMAGE)"
145139
dependsOn: [Create_cluster, Build_test, setup]
146140
variables:
147141
RESOURCE_GROUP: $[ dependencies.setup.outputs['EnvironmentalVariables.RESOURCE_GROUP'] ]
@@ -201,8 +195,6 @@ jobs:
201195
demands:
202196
- agent.os -equals Linux
203197
- Role -equals Build
204-
container:
205-
image: "$(BUILD_IMAGE)"
206198
condition: always()
207199
dependsOn: [Run_test, setup]
208200
variables:

.pipelines/pipeline.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ stages:
2323
echo "##vso[task.setvariable variable=Tag;isOutput=true]$(git describe --tags --always --dirty)"
2424
echo "##vso[task.setvariable variable=ImageTag;isOutput=true]$(git describe --tags --always --dirty)-test"
2525
sudo chown -R $(whoami):$(whoami) .
26+
go version
27+
go env
28+
which go
29+
echo $PATH
2630
name: "EnvironmentalVariables"
2731
displayName: "Set environmental variables"
2832
condition: always()
@@ -37,7 +41,6 @@ stages:
3741
pool:
3842
name: "$(BUILD_POOL_NAME_DEFAULT)"
3943
steps:
40-
4144
- script: |
4245
GOOS=windows make all-binaries VERSION=$(TAG)
4346
name: "BuildWindows"

cni/client/client_unit_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import (
1313

1414
func TestGetState(t *testing.T) {
1515
calls := []testutils.TestCmd{
16-
{Cmd: []string{"./azure-vnet"}, Stdout: `{"ContainerInterfaces":{"3f813b02-eth0":{"PodName":"metrics-server-77c8679d7d-6ksdh","PodNamespace":"kube-system","PodEndpointID":"3f813b02-eth0","ContainerID":"3f813b029429b4e41a09ab33b6f6d365d2ed704017524c78d1d0dece33cdaf46","IPAddresses":[{"IP":"10.241.0.17","Mask":"//8AAA=="}]},"6e688597-eth0":{"PodName":"tunnelfront-5d96f9b987-65xbn","PodNamespace":"kube-system","PodEndpointID":"6e688597-eth0","ContainerID":"6e688597eafb97c83c84e402cc72b299bfb8aeb02021e4c99307a037352c0bed","IPAddresses":[{"IP":"10.241.0.13","Mask":"//8AAA=="}]}}}`},
16+
{Cmd: []string{"/opt/cni/bin/azure-vnet"}, Stdout: `{"ContainerInterfaces":{"3f813b02-eth0":{"PodName":"metrics-server-77c8679d7d-6ksdh","PodNamespace":"kube-system","PodEndpointID":"3f813b02-eth0","ContainerID":"3f813b029429b4e41a09ab33b6f6d365d2ed704017524c78d1d0dece33cdaf46","IPAddresses":[{"IP":"10.241.0.17","Mask":"//8AAA=="}]},"6e688597-eth0":{"PodName":"tunnelfront-5d96f9b987-65xbn","PodNamespace":"kube-system","PodEndpointID":"6e688597-eth0","ContainerID":"6e688597eafb97c83c84e402cc72b299bfb8aeb02021e4c99307a037352c0bed","IPAddresses":[{"IP":"10.241.0.13","Mask":"//8AAA=="}]}}}`},
1717
}
1818

19-
fakeexec, _ := testutils.GetFakeExecWithScripts(calls)
19+
fakeexec := testutils.GetFakeExecWithScripts(calls)
2020

2121
c := New(fakeexec)
2222
state, err := c.GetEndpointState()
@@ -34,10 +34,10 @@ func TestGetState(t *testing.T) {
3434

3535
func TestGetVersion(t *testing.T) {
3636
calls := []testutils.TestCmd{
37-
{Cmd: []string{"./azure-vnet", "-v"}, Stdout: `Azure CNI Version v1.4.0-2-g984c5a5e-dirty`},
37+
{Cmd: []string{"/opt/cni/bin/azure-vnet", "-v"}, Stdout: `Azure CNI Version v1.4.0-2-g984c5a5e-dirty`},
3838
}
3939

40-
fakeexec, _ := testutils.GetFakeExecWithScripts(calls)
40+
fakeexec := testutils.GetFakeExecWithScripts(calls)
4141

4242
c := New(fakeexec)
4343
version, err := c.GetVersion()

cns/cnireconciler/podinfoprovider_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111

1212
func newCNIStateFakeExec(stdout string) exec.Interface {
1313
calls := []testutils.TestCmd{
14-
{Cmd: []string{"./azure-vnet"}, Stdout: stdout},
14+
{Cmd: []string{"/opt/cni/bin/azure-vnet"}, Stdout: stdout},
1515
}
1616

17-
fake, _ := testutils.GetFakeExecWithScripts(calls)
17+
fake := testutils.GetFakeExecWithScripts(calls)
1818
return fake
1919
}
2020

cns/cnireconciler/version_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010

1111
func newCNIVersionFakeExec(ver string) exec.Interface {
1212
calls := []testutils.TestCmd{
13-
{Cmd: []string{"./azure-vnet", "-v"}, Stdout: ver},
13+
{Cmd: []string{"/opt/cni/bin/azure-vnet", "-v"}, Stdout: ver},
1414
}
1515

16-
fake, _ := testutils.GetFakeExecWithScripts(calls)
16+
fake := testutils.GetFakeExecWithScripts(calls)
1717
return fake
1818
}
1919

0 commit comments

Comments
 (0)