Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sharing test cases of internet protocols with Go and OCI Artifacts

Sharing test cases of internet protocols with Go and OCI Artifacts

Moto Ishizawa

April 24, 2021
Tweet

More Decks by Moto Ishizawa

Other Decks in Programming

Transcript

  1. .PUP*TIJ[BXB
    ,BONV *OD
    4IBSJOHUFTUDBTFTPGJOUFSOFUQSPUPDPMT
    XJUI(PBOE0$*"SUJGBDUT

    View Slide

  2. Moto Ishizawa
    Software Engineer, Kanmu, Inc.

    View Slide

  3. We are hiring!
    https://kanmu.co.jp/jobs/

    View Slide

  4. Problems in implementing HTTP/2 server
    • Writing tests requires a deep understanding of the HTTP/2 speci
    fi
    cation

    • Many implementors are writing similar tests for their own implementations

    • Di
    ff
    erent programming languages make it di
    ffi
    cult to share tests between
    implementations

    View Slide

  5. h2spec
    • A conformance testing tool for HTTP/2 server

    • Written in Go as a command line tool

    • Used by many HTTP/2 server implementors :)

    View Slide

  6. What is conformance testing tool?
    • Send data to the server according to the speci
    fi
    cation

    • Check the response from the server to make sure it complies with the
    speci
    fi
    cation

    • In HTTP/2, it is mainly tested by sending frames
    􀧘
    􀏜
    HTTP/2 Server
    h2spec
    Send frames
    Check response

    View Slide

  7. Why Go?
    • Easy to implement command-line tools that work on multiple OS

    • Single binary!

    • O
    ffi
    cial HTTP/2 package was available early

    View Slide

  8. Challenges in h2spec
    • Knowledge of Go is required to add or change test cases

    • Even if you want to change a part of the test, you need to rebuild it

    • Di
    ffi
    cult to cover all implementation di
    ff
    erences…

    • Want to test other protocols as well (QUIC, TLS v1.3, etc…)

    View Slide

  9. protospec
    • A general-purpose conformance testing tool implemented in Go

    • Easy to write test cases in YAML format

    • Test cases can be easily shared as OCI Artifacts

    • https://github.com/summerwind/protospec

    View Slide

  10. protospec

    View Slide

  11. Writing conformance test case with YAML (1/8)
    A client MUST send the connection preface (Section 3.5)
    and then MAY immediately send HTTP/2 frames to such a server;
    servers can identify these connections by the presence of the
    connection preface.
    RFC7540 - Hypertext Transfer Protocol Version 2 (HTTP/2)

    View Slide

  12. Writing conformance test case with YAML (2/8)
    Multiple tests can be de
    fi
    ned in a single

    YAML
    fi
    le

    View Slide

  13. Writing conformance test case with YAML (3/8)
    De
    fi
    ne title and description of test

    View Slide

  14. Writing conformance test case with YAML (4/8)
    A single test consists of multiple steps

    View Slide

  15. Writing conformance test case with YAML (5/8)
    Send connection preface

    View Slide

  16. Writing conformance test case with YAML (6/8)
    Send SETTINGS frame

    View Slide

  17. Writing conformance test case with YAML (7/8)
    Wait for receiving of SETTINGS frame

    View Slide

  18. Writing conformance test case with YAML (8/8)

    View Slide

  19. Sharing test cases as container images
    • Test cases can be shared like docker containers

    • pushes the test cases to the registry, pulls
    them from the registry

    • Thanks to OCI Artifacts!
    protospec push protospec pull

    View Slide

  20. What is OCI Artifacts?
    • A mechanism for storing arbitrary
    fi
    les in a container image

    • One of the ways to use OCI Distribution and OCI Image, not a speci
    fi
    cation

    • Many container registries (ECR, GitHub, etc…) are supported

    • Used by Helm and Open Policy Agent to manage their con
    fi
    guration
    fi
    les

    • https://github.com/opencontainers/artifacts

    View Slide

  21. Using OCI Artifacts in your code
    • ORAS makes it easy to support OCI Artifacts in your code

    • ORAS is a command line tool, but can also be used as a package

    • https://github.com/deislabs/oras

    View Slide

  22. Pushing artifacts to the registry (1/4)
    Importing the ORAS package

    View Slide

  23. Pushing artifacts to the registry (2/4)
    Creating a docker client
    Resolver will be used to resolve the name of the container image

    View Slide

  24. Pushing artifacts to the registry (3/4)
    Adding a
    fi
    le to the memory store

    View Slide

  25. Pushing artifacts to the registry (4/4)
    Pushing the contents of the memory store to the container registry
    Name of container image to push

    View Slide

  26. Pulling artifacts from the registry (1/2)
    Create a
    fi
    le store and map it to ‘spec’ directory

    View Slide

  27. Pulling artifacts from the registry (2/2)
    Pulling the container image and extract it to the
    fi
    le store
    Name of container image to pull

    View Slide

  28. Conclusion
    • protospec enables sharing of test cases for conformance testing

    • Go is a good language for implementing command line tools!

    • ORAS makes it possible to use OCI Artifacts in your Go code

    View Slide

  29. Thanks!

    View Slide