Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create pfcpiface unit tests' scaffolding #431

Merged
merged 33 commits into from Feb 1, 2022

Conversation

EmanueleGallone
Copy link
Contributor

@EmanueleGallone EmanueleGallone commented Jan 27, 2022

PR's aim is to introduce a new Make rule to execute pfpciface unit tests with coverage.

TODO:

  • Add test scaffolding
  • Add Make rule to run tests locally
  • Add CI to run unit tests

@EmanueleGallone EmanueleGallone changed the title [SDFAB-848][DRAFT] Create pfcpiface testing scaffolding [SDFAB-848][DRAFT] Create pfcpiface unit tests' scaffolding Jan 27, 2022
@EmanueleGallone EmanueleGallone marked this pull request as draft January 27, 2022 11:25
@EmanueleGallone EmanueleGallone changed the title [SDFAB-848][DRAFT] Create pfcpiface unit tests' scaffolding [SDFAB-848] Create pfcpiface unit tests' scaffolding Jan 27, 2022
@EmanueleGallone EmanueleGallone changed the title [SDFAB-848] Create pfcpiface unit tests' scaffolding Create pfcpiface unit tests' scaffolding Jan 27, 2022
@EmanueleGallone EmanueleGallone marked this pull request as ready for review January 27, 2022 16:02
Makefile Outdated Show resolved Hide resolved
@pudelkoM
Copy link
Member

I'd really like to have the scaffolding in place before modifying parseFlowDesc with port ranges. If we're unsure about the actual unit test structure, I'd be ok with leaving it empty in this PR and adding it later.

@EmanueleGallone
Copy link
Contributor Author

EmanueleGallone commented Jan 31, 2022

I was not able to make the CI execute the tests, although they do run locally. It returned this error (see screenshot), when executing make test:

image

I will implement CI for unit-testing in a later PR, if that' ok

osinstom
osinstom previously approved these changes Jan 31, 2022
Copy link
Contributor

@osinstom osinstom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mergeable, waiting for CI to pass

@pudelkoM
Copy link
Member

pudelkoM commented Jan 31, 2022

I think the problem is that CI runs an older Go version which does not have the new timer.Reset method. We should run the tests in the same environment as the actual binary. That is, docker ghcr.io/omec-project/upf-epc/bess_build golang:latest.

See these comments:

Makefile Outdated Show resolved Hide resolved
Copy link
Member

@pudelkoM pudelkoM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

@pudelkoM
Copy link
Member

Hey, it works:

rm -rf /home/runner/work/upf-epc/upf-epc/.coverage
mkdir -p /home/runner/work/upf-epc/upf-epc/.coverage
docker run --rm -v /home/runner/work/upf-epc/upf-epc:/upf-epc -w /upf-epc golang:latest \
	go test \
		-race \
		-coverprofile=.coverage/coverage-unit.txt \
		-covermode=atomic \
		-v \
		./pfcpiface
Unable to find image 'golang:latest' locally
latest: Pulling from library/golang
0c6b8ff8c37e: Already exists
412caad352a3: Already exists
e6d3e61f7a50: Already exists
461bb1d8c517: Already exists
9297634c9537: Already exists
6a0b51344be5: Already exists
856234c9f319: Already exists
Digest: sha256:301609ebecc0ec4cd3174294220a4d9c92aab9015b3a2958297d7663aac627a1
Status: Downloaded newer image for golang:latest
go: downloading github.com/Showmax/go-fqdn v1.0.0
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/google/gopacket v1.1.19
go: downloading github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
go: downloading github.com/libp2p/go-reuseport v0.1.0
go: downloading github.com/p4lang/p4runtime v1.3.0
go: downloading github.com/prometheus/client_golang v1.11.0
go: downloading github.com/sirupsen/logrus v1.8.1
go: downloading github.com/wmnsk/go-pfcp v0.0.14
go: downloading google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a
go: downloading google.golang.org/grpc v1.43.0
go: downloading google.golang.org/protobuf v1.27.1
go: downloading github.com/stretchr/testify v1.7.0
go: downloading golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
go: downloading golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/prometheus/common v0.26.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.1.1
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading github.com/prometheus/procfs v0.6.0
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369
go: downloading golang.org/x/text v0.3.4
=== RUN   TestParseFAR
=== RUN   TestParseFAR/Valid_Uplink_FAR_input_with_create_operation
=== RUN   TestParseFAR/Valid_Downlink_FAR_input_with_update_operation
--- PASS: TestParseFAR (0.00s)
    --- PASS: TestParseFAR/Valid_Uplink_FAR_input_with_create_operation (0.00s)
    --- PASS: TestParseFAR/Valid_Downlink_FAR_input_with_update_operation (0.00s)
=== RUN   TestParseFARShouldError
=== RUN   TestParseFARShouldError/Uplink_FAR_with_invalid_action
=== RUN   TestParseFARShouldError/Downlink_FAR_with_invalid_action
=== RUN   TestParseFARShouldError/Malformed_Downlink_FAR_with_missing_FARID
--- PASS: TestParseFARShouldError (0.00s)
    --- PASS: TestParseFARShouldError/Uplink_FAR_with_invalid_action (0.00s)
    --- PASS: TestParseFARShouldError/Downlink_FAR_with_invalid_action (0.00s)
    --- PASS: TestParseFARShouldError/Malformed_Downlink_FAR_with_missing_FARID (0.00s)
PASS
coverage: 1.6% of statements
ok  	github.com/omec-project/upf-epc/pfcpiface	0.127s	coverage: 1.6% of statements

pudelkoM
pudelkoM previously approved these changes Jan 31, 2022
@pudelkoM pudelkoM merged commit 202056c into omec-project:master Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants