Save 37% off PRO during our Black Friday Sale! »

Sharing test cases of internet protocols with Go and OCI Artifacts

Sharing test cases of internet protocols with Go and OCI Artifacts

20e958629852b653fad35c99706fc3ac?s=128

Moto Ishizawa

April 24, 2021
Tweet

Transcript

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

  2. Moto Ishizawa Software Engineer, Kanmu, Inc.

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

  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
  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 :)
  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
  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
  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…)
  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
  10. protospec

  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)
  12. Writing conformance test case with YAML (2/8) Multiple tests can

    be de fi ned in a single YAML fi le
  13. Writing conformance test case with YAML (3/8) De fi ne

    title and description of test
  14. Writing conformance test case with YAML (4/8) A single test

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

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

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

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

  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
  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
  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
  22. Pushing artifacts to the registry (1/4) Importing the ORAS package

  23. Pushing artifacts to the registry (2/4) Creating a docker client

    Resolver will be used to resolve the name of the container image
  24. Pushing artifacts to the registry (3/4) Adding a fi le

    to the memory store
  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
  26. Pulling artifacts from the registry (1/2) Create a fi le

    store and map it to ‘spec’ directory
  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
  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
  29. Thanks!