Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

Moto Ishizawa Software Engineer, Kanmu, Inc.

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

h2spec • A conformance testing tool for HTTP/2 server • Written in Go as a command line tool • Used by many HTTP/2 server implementors :)

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

Why Go? • Easy to implement command-line tools that work on multiple OS • Single binary! • O ffi cial HTTP/2 package was available early

Slide 8

Slide 8 text

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…)

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

protospec

Slide 11

Slide 11 text

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)

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Writing conformance test case with YAML (8/8)

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

Thanks!