Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Development/QA environments and the Go tools in it

Development/QA environments and the Go tools in it

Kenichi Masuda

August 10, 2018
Tweet

More Decks by Kenichi Masuda

Other Decks in Technology

Transcript

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

    Engineer • 2016/10-: started as SET(Software engineer in Test) 今回: SETが作った環境・ツールの話
  2. 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に向けて
  3. 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
  4. SET(Software Engineer in Test) • Did ◦ Local development environment

    ◦ QA environment ◦ PR based environments ◦ Automate UI Test ◦ CI/CD ◦ Refactoring
  5. 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
  6. Did

  7. 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
  8. 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
  9. QA env Architecture in US • Monolith -> Microservices •

    PHP -> Go • Manually deploy with Web UI -> Automatically
  10. 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
  11. 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)
  12. 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
  13. 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に近づける(増やす・減 らす)
  14. grpc-translator • gRPC-HTTP変換ツール • MS間の通信はgRPC • 何かとRESTで喋りたいときがある • ex: QAエンジニアがテストデータ入れる

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

    Annotationをもとにサービス探索 • GRPC Server Reflection Protocolでサービス の仕様を取得する • その仕様に合わせてサービスをコールする • レスポンス • OSSになるはず!