Skip to content

Conversation

juagargi
Copy link
Contributor

@juagargi juagargi commented Mar 10, 2020

Adding the corresponding lib/ctrl/colibri_mgmt structs for (de)serialization of the capnp messages.
Added only those types needed for colibri_mgmt.Request. The Response type is still pending.
Added UT to check correct (de)serialization.

After this, still pending before the colibri store:

  • Finish the Response type.
  • Application level types, that include fields from capnp messages and colibri HbH extension.

This change is Reviewable

@juagargi juagargi force-pushed the colibri.reservation_store branch from be45fbb to 0fd3422 Compare March 10, 2020 12:59
@juagargi juagargi changed the title WIP: Capnp structs counter parts Capnp structs counter parts Mar 10, 2020
@oncilla oncilla changed the title Capnp structs counter parts colibri: add ctrl structs for requests Mar 18, 2020
Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

Reviewed 16 of 16 files at r1.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @juagargi)


go/lib/ctrl/colibri_mgmt/colibri_mgmt_test.go, line 31 at r1 (raw file):

	}
	buffer, err := root.PackRoot()
	if err != nil {

testify/require

require.NoError(t, err)


go/lib/ctrl/colibri_mgmt/colibri_mgmt_test.go, line 35 at r1 (raw file):

	}
	if len(buffer) != 7 {
		t.Fatalf("Expected 15 bytes, got %d", len(buffer))

require.Len(t, buffer, 7)


go/lib/ctrl/colibri_mgmt/colibri_mgmt_test.go, line 37 at r1 (raw file):

		t.Fatalf("Expected 15 bytes, got %d", len(buffer))
	}
	copy, err := colibri_mgmt.NewFromRaw(buffer)

don't shadow go keywords


go/lib/ctrl/colibri_mgmt/colibri_mgmt_test.go, line 48 at r1 (raw file):

		t.Fatalf("Error serializing root: %v", err)
	}
	if bytes.Compare(buffer, otherBuffer) != 0 {

testify/assert

assert.Equal


go/lib/ctrl/colibri_mgmt/colibri_mgmt_test.go, line 55 at r1 (raw file):

// tests serialization for all types of requests
func TestSerializeRequest(t *testing.T) {
	setup := &colibri_mgmt.SegmentSetup{

this can be a table driven test:

testCases := map[string]struct{
    Request *colibri_mgmt.Request
}{
  "setup": {
    Request: &colibri_mgmt.Request{
      Which: proto.Request_Which_segmentSetup,
      SegmentSetup: ...
    },  
  },
  ...
}

for name, tc := range testCases {
  name, tc := name, tc
  t.Run(name, func(t *testing.T){
    t.Parallel()
    root := &colibri_mgmt.ColibriRequestPayload{
      Which:   proto.ColibriRequestPayload_Which_request,
      Request: request,
    }
    // All the code from serializeAndCompareRoot(t, root)
  })
}

Copy link
Contributor Author

@juagargi juagargi left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @oncilla)


go/lib/ctrl/colibri_mgmt/colibri_mgmt_test.go, line 31 at r1 (raw file):

Previously, Oncilla wrote…

testify/require

require.NoError(t, err)

Done.


go/lib/ctrl/colibri_mgmt/colibri_mgmt_test.go, line 35 at r1 (raw file):

Previously, Oncilla wrote…

require.Len(t, buffer, 7)

Done.


go/lib/ctrl/colibri_mgmt/colibri_mgmt_test.go, line 37 at r1 (raw file):

Previously, Oncilla wrote…

don't shadow go keywords

Done.


go/lib/ctrl/colibri_mgmt/colibri_mgmt_test.go, line 48 at r1 (raw file):

Previously, Oncilla wrote…

testify/assert

assert.Equal

Done.


go/lib/ctrl/colibri_mgmt/colibri_mgmt_test.go, line 55 at r1 (raw file):

Previously, Oncilla wrote…

this can be a table driven test:

testCases := map[string]struct{
    Request *colibri_mgmt.Request
}{
  "setup": {
    Request: &colibri_mgmt.Request{
      Which: proto.Request_Which_segmentSetup,
      SegmentSetup: ...
    },  
  },
  ...
}

for name, tc := range testCases {
  name, tc := name, tc
  t.Run(name, func(t *testing.T){
    t.Parallel()
    root := &colibri_mgmt.ColibriRequestPayload{
      Which:   proto.ColibriRequestPayload_Which_request,
      Request: request,
    }
    // All the code from serializeAndCompareRoot(t, root)
  })
}

Done.

Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@juagargi juagargi force-pushed the colibri.reservation_store branch from 8e031e7 to f311032 Compare March 24, 2020 12:30
Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@oncilla oncilla merged commit 49d44a4 into scionproto:master Mar 24, 2020
@juagargi juagargi deleted the colibri.reservation_store branch March 24, 2020 13:50
stygerma pushed a commit to stygerma/scion that referenced this pull request Apr 22, 2020
Add the corresponding `lib/ctrl/colibri_mgmt` structs for (de)serialization of the capnp messages.
Add only those types needed for `colibri_mgmt.Request`. The `Response` type is still pending.
Add unit tests to check correct (de)serialization.
stygerma pushed a commit to stygerma/scion that referenced this pull request Apr 22, 2020
Add the corresponding `lib/ctrl/colibri_mgmt` structs for (de)serialization of the capnp messages.
Add only those types needed for `colibri_mgmt.Request`. The `Response` type is still pending.
Add unit tests to check correct (de)serialization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants