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 full-size slide

  2. Moto Ishizawa
    Software Engineer, Kanmu, Inc.

    View full-size slide

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

    View full-size 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 full-size 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 full-size 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 full-size 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 full-size 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 full-size 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 full-size slide

  10. 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 full-size slide

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

    YAML
    fi
    le

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  18. 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 full-size slide

  19. 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 full-size slide

  20. 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  24. 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 full-size slide

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

    View full-size slide

  26. 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 full-size slide

  27. 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 full-size slide