ll言語でもhudsonを使おう!

25
1 Copyright 2010 KLab Inc. All rights reserved. LL 言言言言 Hudson 言言言言 ! 2010/02/25 言言言言言 言言言言

Upload: klab

Post on 20-Jun-2015

5.979 views

Category:

Technology


8 download

DESCRIPTION

2010/02/25開催 Cyber Agent様 × KLab勉強会資料

TRANSCRIPT

Page 1: LL言語でもHudsonを使おう!

1Copyright 2010 KLab Inc. All rights reserved.

LL 言語でも Hudson を使おう !

2010/02/25

研究開発部 佐々木健一

Page 2: LL言語でもHudsonを使おう!

2Copyright 2010 KLab Inc. All rights reserved.

自己紹介

Page 3: LL言語でもHudsonを使おう!

3Copyright 2010 KLab Inc. All rights reserved.

自己紹介

• 名前– 佐々木健一

• 沿革– ~ 2009 年 8 月

• プロジェクトマネジメント部に在籍• 自社向け携帯サイト開発フレームワーク作成 (Java)• Hudson をコツコツ使う

– 2009 年 9 月~• マネジメントよりモノづくりが好きで現部署へ• LL 言語にも CI の必要性を感じつつ今へ至る

• 技術– 大昔は C,C++– 今は Java な人です。– Python や Ruby 、 Haskell 、 Scala をかじった

Page 4: LL言語でもHudsonを使おう!

4Copyright 2010 KLab Inc. All rights reserved.

Hudson(CI サーバ ) に対する誤解

• Java 専用 CI サーバ ?–Java 界隈では話題–LL 言語には使えないのでは

• インストール面倒 ?– JavaVM のインストール– Tomcat のインストール– XML との戦い– ああ、ヤダヤダ

Page 5: LL言語でもHudsonを使おう!

5Copyright 2010 KLab Inc. All rights reserved.

CI (Continuous Integration) サーバ ?

• 携帯サイト展開後不具合出しは大変– 結合してから判明する不具合もある– 切羽詰ってるし

• 問題は早期に検出したほうがよい– しかも手間なく– 小人さんが自動でやってくれるとうれしいな

あ• そんな小人さん

– Continuous Integration ( 継続結合 ) サーバ

Page 6: LL言語でもHudsonを使おう!

6Copyright 2010 KLab Inc. All rights reserved.

Hudson とは

Web アプリです

複数ジョブを登録でき

Hudson 先生

ジョブの状況をお天気アイコンで表

ジョブを自動的に実施して結果を残してくれる

Page 7: LL言語でもHudsonを使おう!

7Copyright 2010 KLab Inc. All rights reserved.

Hudson のインストールは簡単だ

Page 8: LL言語でもHudsonを使おう!

8Copyright 2010 KLab Inc. All rights reserved.

インストールを簡単にする工夫が

• Tomcat とか Servlet コンテナ不要– ファイルは hudson.war ひとつだけ– java -jar hudson.war で起動できる

• Winstone という超小型 Servlet Container 内包

– Tomcat に組み込むことも可能• 各種 OS 向け Package が用意されている

– 佐々木は debian lenny で使ってみました

Page 9: LL言語でもHudsonを使おう!

9Copyright 2010 KLab Inc. All rights reserved.

Windows

• JNLP(Java WebStart) 経由で動かせる– http://wiki.hudson-ci.org/display/HUDSON/

Installing+Hudson+as+a+Windows+service

• Windows Service として登録

Page 10: LL言語でもHudsonを使おう!

10Copyright 2010 KLab Inc. All rights reserved.

Debian GNU/Linux (lenny)

• debian パッケージとして提供されてる

• Hudson 配布元を追加

• インストール

# wget -O - http://hudson-ci.org/debian/hudson-ci.org.key | sudo apt-key add -# vi /etc/apt/sources.listdeb http://hudson-ci.org/debian binary/

# apt-get update# aptiude install openjdk-6-jdk# aptitude install hudson

Page 11: LL言語でもHudsonを使おう!

11Copyright 2010 KLab Inc. All rights reserved.

PHP 継続プロファイリング環境構築

Page 12: LL言語でもHudsonを使おう!

12Copyright 2010 KLab Inc. All rights reserved.

Hudson は Java 専用ではない

• 確かに Hudson は java で書かれている– shell スクリプト呼べる– LL 言語用 Plugin もある– 使う上で Java の知識必須ではない

• Hudson の Plugin 開発には Java の知識必要

• PHP 環境向けにセットアップ– Shell スクリプト呼べるので PHP でも問題な

い– 継続プロファイリング環境を構築してみた

Page 13: LL言語でもHudsonを使おう!

13Copyright 2010 KLab Inc. All rights reserved.

継続プロファイリング環境とは

• 開発中からプロファイリングを行う• 単体テストと同じ考えで• 継続して行う• 回帰的に行う• 結果を時系列に可視化

• 意義• 性能問題の早期発見• 問題の可視化はモチベーションあがる

Page 14: LL言語でもHudsonを使おう!

14Copyright 2010 KLab Inc. All rights reserved.

継続プロファイリング環境  - 構成要素

• Hudson– 今回の主役

• Bazaar– 弊社で使用中の分散 SCM (git とか Mercuri

al の仲間 )

• XDEBUG– PHP 拡張。プロファイリングやコードカバ

レージを可能にする。• webgrind

– プロファイル結果 web 可視化ツール

Page 15: LL言語でもHudsonを使おう!

15Copyright 2010 KLab Inc. All rights reserved.

継続プロファイリング環境  - 構成要素

http://scm-svr/~sasaki-k/bzr-repo/

bzr push

http://hudson-srv/webgrind

scm-svr hudson-srv

開発者

ソースリポジトリを監視

自動チェックアウト &デブロイ

Page 16: LL言語でもHudsonを使おう!

16Copyright 2010 KLab Inc. All rights reserved.

構築手順 (1/4)   on Debian GNU/Linux (lenny)

• PHP / Xdebug 拡張

• ”You shuld add “extension=xdebug.so” to php.ini” と出力されるが無視– 間違いらしいので注意 (Xdebug 本家サイトより )

• 正しくは – zend_extension=“xdebug.so へのフルパス”– /etc/php5/apache2/conf.d/xdebug.ini へ記述

• 有効にするには– xdebug.ini へ xdebug.profiler_enable = 1 を追記

# aptitude install php5-dev# aptitude install php5-mysql# pecl install xdebug

Page 17: LL言語でもHudsonを使おう!

17Copyright 2010 KLab Inc. All rights reserved.

構築手順 (2/4) on Debian GNU/Linux (lenny)

• bazaar– CVS 、 Subversion 、 git でも OK– debian で配布されているものは古い– pip で取得 (pip = setuptools の後継 )

# aptitude install python-dev# aptitude install libroot-python-dev# wget http://peak.telecommunity.com/dist/ez_setup.py# python ez_setup.py # easy_install pip# pip install bzr

Page 18: LL言語でもHudsonを使おう!

18Copyright 2010 KLab Inc. All rights reserved.

構築手順 (3/4) on Debian GNU/Linux (lenny)

• webgrind– Xdebug が出力する cachegrind.out の可視化– PHP で記述– http://code.google.com/p/webgrind/ より取得

• DocumentRoot の適当な場所へ配置

# cat .htaccessphp_flag xdebug.profiler_enable 0

webgrind 自身がプロファイリングされないように

Page 19: LL言語でもHudsonを使おう!

19Copyright 2010 KLab Inc. All rights reserved.

構築手順 (4/4) on Debian GNU/Linux (lenny)

• Hudson から Bazaar コマンドを呼び出すため– Hudson Bazaar plugin

必要な plugin にチェック入れて「インストールボタンクリ

ック」

Page 20: LL言語でもHudsonを使おう!

20Copyright 2010 KLab Inc. All rights reserved.

demo

• パフォーマンス問題コードを用意• 解消されるまでを確認

Page 21: LL言語でもHudsonを使おう!

21Copyright 2010 KLab Inc. All rights reserved.

webgrind

関数単独で要したコスト

関数呼び出し先も含んで要したコス

これがボトルネックになっていることがわかる

Page 22: LL言語でもHudsonを使おう!

22Copyright 2010 KLab Inc. All rights reserved.

まとめ

• Hudson は Java 以外でも使える• Hudson 自体のインストールは簡単

– PHP 環境の方が大変• CI を LL 言語にも導入してソースの健康維

持を図りましょう

やらなきゃ☆ Hudson!

Page 23: LL言語でもHudsonを使おう!

23Copyright 2010 KLab Inc. All rights reserved.

参考資料 (1/2)

• Hudson– http://hudson-ci.org/

• Hudson Debian packages– http://hudson-ci.org/debian/

• Installing Hudson– http://wiki.hudson-ci.org/display/HUDSON/Inst

alling+Hudson

• Hudson で PHP のユニットテスト– http://d.hatena.ne.jp/ssogabe/20081102/1225

642743

Page 24: LL言語でもHudsonを使おう!

24Copyright 2010 KLab Inc. All rights reserved.

参考資料 (2/2)

• Xdebug– http://xdebug.org/index.php

• WebGrind– http://code.google.com/p/webgrind/

• Profiling PHP with Xdebug and Webgrind– http://www.chrisabernethy.com/php-profiling-x

debug-webgrind/

Page 25: LL言語でもHudsonを使おう!

25Copyright 2010 KLab Inc. All rights reserved.

ご静聴ありがとうございました

質問た~~~いむ