Development/QA environments and the Go tools in it

A2a2d96ab7fae2ccc4fb8e88cc7f8698?s=47 masudak
August 10, 2018

Development/QA environments and the Go tools in it

A2a2d96ab7fae2ccc4fb8e88cc7f8698?s=128

masudak

August 10, 2018
Tweet

Transcript

  1. メルカリにおける開発環境/QA環境と、 そこで使われるGoのツールについて mercari.go #2 @masudak

  2. About me

  3. About me HN: @masudak Team: • 2016/04-: joined as Backend

    Engineer • 2016/10-: started as SET(Software engineer in Test) 今回: SETが作った環境・ツールの話
  4. Agenda • 簡単にSETの紹介 • 作った環境 • そこで使われているGoの様々なツールの紹 介

  5. SET(Software Engineer in Test) • 2016/10: 創設 • Mission ◦

    Improve engineering productivity ◦ Encourage quality improvement • Other companies ◦ SDET, SWET, SETI “SETs are developers who write test code and automation as their primary task” https://testing.googleblog.com/2011/04/set-career-pa th.html?m=1 See also: SETチームの設立背景と次世代のSETに向けて
  6. SET(Software Engineer in Test) • Position ◦ Backend SET, Frontend

    SET, Microservices SET, iOS SET and so on • History ◦ Determined to release “UK App” ◦ A few env as “Code of Infrastructure” ◦ A lot of regression tests
  7. SET(Software Engineer in Test) • Did ◦ Local development environment

    ◦ QA environment ◦ PR based environments ◦ Automate UI Test ◦ CI/CD ◦ Refactoring
  8. Development flow

  9. Development flow • PMs create specifications and fix it on

    Jira • Engineers and designers implement it in “local environment development” • Request it to review of members as a PR • LGTM • QA engineers make “QA” in “QA environment” • PMs approve it • Engineers release it
  10. Did

  11. Local development environment • For all engineers and designers •

    Prepare docker images ◦ Apache, gaurun, widebullet, chocon • Execute “make init, make start” • Docker for Mac with docker-compose • Set IP in local • And then, access from dev client
  12. QA environment of monolith • Environment for QA engineers •

    GCP(GLB, GCE, GCS, GCR) • Ansible • Docker • Web UI ◦ set “branch name” and “target” • Deploy branch environment
  13. None
  14. Last year

  15. QA env Architecture in US • Monolith -> Microservices •

    PHP -> Go • Manually deploy with Web UI -> Automatically
  16. First

  17. QA env Architecture in US

  18. QA env Architecture in US • Template manifest of k8s

    • CircleCI: ◦ replace the template to PR number ◦ apply the template ◦ create deployment and service of k8s • Go proxy ◦ get HTTP header from client ◦ proxy each service with the header • Application to delete ◦ get webhook when closing PR ◦ destroy existing pod
  19. Go proxy

  20. Go proxy director := func(req *http.Request) { xPrNumber := req.Header.Get("X-QA-PR")

    apisPort := 3000 req.URL.Scheme = "http" if xPrNumber != "" { req.URL.Host = fmt.Sprintf("api-%s:%d", xPrNumber, apisPort) } else { req.URL.Host = fmt.Sprintf("-api:%d", apisPort) } } rp := &httputil.ReverseProxy{ Director: director, } rp.ServeHTTP(w, req)
  21. Second

  22. QA environment of microservices • Pull Request Replication Controller •

    詳しくはこちら ◦ https://www.slideshare.net/VishalBanthi a1/kubernetes-controller-for-pull-reques t-based-environment • k8sのコントローラーを作成 • reconciliation loop ◦ Current State -> Desired State
  23. QA environment of microservices • サービスディスカバリのために事前に Annotationをk8sのサービスに付与 annotation: pr-rc.alpha.example.com/repository: https://github.com/exaple/hello-service

    • k8s APIを用いてN秒に一回取得 • 該当レポジトリへGitHub API経由でアクセス (desired state) • クラスタ内の情報をk8s API経由で取得 (current state) • Replicasetをdesiredに近づける(増やす・減 らす)
  24. QA environment of microservices • おかげで、PRごとの環境が自動で作られる • OSSにもなる予定

  25. Third

  26. grpc-translator • gRPC-HTTP変換ツール • MS間の通信はgRPC • 何かとRESTで喋りたいときがある • ex: QAエンジニアがテストデータ入れる

    • grpc-gatewayとかあるけど • protoファイルを編集したくない • RESTなげたら、gRPC話してほしい
  27. grpc-translator • サービスディスカバリのためにAnnotationをRC に事前に付与 Annotation: translator/proto-service: my.package.MyService • JSON-RPCでリクエストを受付 •

    Annotationをもとにサービス探索 • GRPC Server Reflection Protocolでサービス の仕様を取得する • その仕様に合わせてサービスをコールする • レスポンス • OSSになるはず!
  28. おわりに • SETは生産性や品質をキーワードに多くの業 務をやってる • それらの低下はビジネス力の低下 • Goのプロダクトやツールは至るところで使われ ています!!

  29. ご清聴 ありがとうございました