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

Adding New Test Group #106

Open
lingamac opened this issue Jun 19, 2019 · 0 comments
Open

Adding New Test Group #106

lingamac opened this issue Jun 19, 2019 · 0 comments

Comments

@lingamac
Copy link

lingamac commented Jun 19, 2019

Hi,
I would like to Add new test group to test some http2 related changes. I tried creating new floder under app and add group in h2spec.go but it is not accepting.

Let me know how to add new group.
Tried following changes. h2spec.go
package h2spec

import (
"fmt"
"time"
"app/nbsf" //<<new group
"github.com/summerwind/h2spec/client"
"github.com/summerwind/h2spec/config"
"github.com/summerwind/h2spec/generic"
"github.com/summerwind/h2spec/hpack"
"github.com/summerwind/h2spec/http2"
"github.com/summerwind/h2spec/log"
"github.com/summerwind/h2spec/reporter"
"github.com/summerwind/h2spec/spec"
)

nbsf.go
package nbsf

import "github.com/summerwind/h2spec/spec"

var key = "nbsf"

func NewTestGroup(section string, name string) *spec.TestGroup {
return &spec.TestGroup{
Key: key,
Section: section,
Name: name,
}
}

func Spec() *spec.TestGroup {
tg := &spec.TestGroup{
Key: key,
Name: "Nbsf PCF tests",
}

tg.AddTestGroup(NbsfRegister())
//tg.AddTestGroup(DeRegisterNbsf())
//tg.AddTestGroup(StreamsAndMultiplexing())
//tg.AddTestGroup(FrameDefinitions())

return tg

}
Test case
package nbsf

import (
"golang.org/x/net/http2"

"github.com/summerwind/h2spec/config"
"github.com/summerwind/h2spec/spec"

)

func NbsfRegister() *spec.TestGroup {
tg := NewTestGroup("1", "Register_Nbsf")

// RFC7540, 6.1:
// DATA frames (type=0x0) convey arbitrary, variable-length
// sequences of octets associated with a stream. One or more
// DATA frames are used, for instance, to carry HTTP request
// or response payloads.
tg.AddTestCase(&spec.TestCase{
            Desc:        "Sends a DATA frame",
            Requirement: "The endpoint MUST accept DATA frame.",
            Run: func(c *config.Config, conn *spec.Conn) error {
                var streamID uint32 = 1

                err := conn.Handshake()

                if err != nil {
                    return err
                }

                headers := spec.CommonHeaders(c)
                headers[0].Value = "POST"
                hp := http2.HeadersFrameParam{
                    StreamID:      streamID,
                    EndStream:     false,
                    EndHeaders:    true,
                    BlockFragment: conn.EncodeHeaders(headers),
                }

                conn.WriteHeaders(hp)
                conn.WriteData(streamID, true, []byte("test"))

                return spec.VerifyHeadersFrame(conn, streamID)
        },
})

return tg
}

I compiled and ran
root@00d798a70d3e:/go/src/app# ./h2spec nbsf
No matched tests found.

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

No branches or pull requests

1 participant