这是indexloc提供的服务,不要输入任何密码
Skip to content

Adding New Test Group #106

@lingamac

Description

@lingamac

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions