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. 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
  2. h2spec • A conformance testing tool for HTTP/2 server •

    Written in Go as a command line tool • Used by many HTTP/2 server implementors :)
  3. 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
  4. Why Go? • Easy to implement command-line tools that work

    on multiple OS • Single binary! • O ffi cial HTTP/2 package was available early
  5. 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…)
  6. 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
  7. 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)
  8. 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
  9. 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
  10. 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
  11. Pushing artifacts to the registry (2/4) Creating a docker client

    Resolver will be used to resolve the name of the container image
  12. Pushing artifacts to the registry (4/4) Pushing the contents of

    the memory store to the container registry Name of container image to push
  13. Pulling artifacts from the registry (1/2) Create a fi le

    store and map it to ‘spec’ directory
  14. 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
  15. 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