Quantcast
Channel: Mimul's Developer World
Viewing all articles
Browse latest Browse all 133

veewee를 통해 glu(linkedin의 배포 및 모니터링 툴) 테스트 환경 자동화

$
0
0
veewee 도구를 활용해서 VM 이미지를 자동으로 만들어서 테스트 환경을 구축해 놓으면, 나중에도 동일한 환경 구성과 다른 개발자들도 쉽게 테스트 환경을 만들어 줄 수 있어서 시간 절약에 도움이 많이 된다.
그래서 보통 box 이미지는 Vagrantbox.es에서 여러가지 OS의 Box를 다운받아서 사용한다. 하지만, 그 안에는 원하는 형태의 소프트웨어가 안들어 있을 수도 있고, 표준 시간대 등 변경 사항들이 있을 수 있고 또, 바이러스 등도 존재할 수도 있어서 좀 큰 업체들은 자신의 입맛에 맞는 박스 이미지를 만들어서 git 저장소등에서 관리를 한다.
그래서 이런 방식으로 박스 이미지를 veewee로 만들어서 테스트 환경을 구축하는 방식에 대해서 기술해 보도록 한다. 아래는 Mac OSX에서 테스트한 내용이다.

필요한 설치 도구들

본 테스트 환경을 구축하는데 필수적인 오픈소스 도구들이니 한번 설치해 보고 익혀 보는 것도 재미있다.
  • RVM - Ruby 환경 관리해주는 도구.
  • Ruby(1.9.3) - veewee, Vagrant 사용을 위해 필요함.
  • RubyGem - veewee, Vagrant 사용을 위해 필요함.
  • Bundler - 종속 라이브러리 자동 관리.
  • VirtualBox - veewee, Vagrant가 VM을 빌드하고 사용하기 위해 VirtualBox를 사용함.
  • veewee - vagrant의 플러그인으로 작동하고 새로운 VM 이미지를 만드는 도구.
  • Vagrant - VM을 설정하고 실행하는 도구.
  • Ubuntu(Chef, Puppet, Ruby 설치됨) - glu의 설치 및 실행환경이 되는 OS.
아래는 테스트 환경을 만들기 위한 방법들을 순차적으로 기술하고 마지막에 문제 발생했을 때 대처한 내용을 기술했다.

- VirtualBox 설치 - 4.2.10버전을 설치함.
- Vagrant 설치
$ vagrant -v
Vagrant version 1.2.2

veewee 도구를 통해 VM 이미지 생성

전체 프로세스를 살펴보면 아래 그림처럼 도식화할 수 있다. 요약 설명해 본다면, veewee 프로젝트를 만들어서 OS별로 vagrant용 박스를 만들어내고, Vagrant 프로젝트에서 만들어진 박스를 가지고 glu 오픈 소스와 그에 필요한 소프트웨어들을 설치해서 테스트 서버를 구동시키는 과정까지 진행된다.


위 부분을 좀더 자동화시킬 수 있는 방법은 CI도구를 중간에 도입해주면 더 편리하게 테스트를 진행할 수 있게 된다.

1. RVM, Ruby, RubyGem 설치(루비 버전 관리를 위해)
$curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled> rvm list known

rvm으로 루비를 설치하고 사용 버전을 선택한다.
$ rvm install 1.9.3
$ rvm list known
$ rvm use 1.9.3 --default

그 다음으로 gem 업그레이드를 진행한다.
gem update

veewee를 설치한다.
$ git clone https://github.com/jedi4ever/veewee.git
$ cd veewee
$ bundle install

$ $ vi ~/.bash_profile
alias veewee="bundle exec veewee"
$ source ~/.bash_profile

$ veewee
Commands:
  veewee fusion          # Subcommand for Vmware fusion
  veewee help [COMMAND]  # help
  veewee kvm             # Subcommand for KVM
  veewee parallels       # Subcommand for Parallels
  veewee vbox            # Subcommand for VirtualBox
  veewee version         # Prints the Veewee version information

2. VM 이미지 생성
먼저 VM 정의파일을 만든다. 참고로 아래 명령어의 인자를 설명하자면, define 다음 인자들은 순서대로 Box 이름, 박스 정의 파일을 생성할때 사용할 템플릿 이름(template 디렉토리 참조)을 뜻한다.
$ veewee vbox define ubuntu-12.04-chef-puppet ubuntu-12.04.2-server-amd64

정의파일이 제대로 생성되었는지 확인한다.
$ ls -l definitions/
total 0
drwxr-xr-x   3 pepsi  staff  102  6 26 20:02 ./
drwxr-xr-x  21 pepsi  staff  714  6 26 20:02 ../
drwxr-xr-x  14 pepsi  staff  476  6 26 19:59 ubuntu-12.04-chef-puppet/

$ vi definitions/ubuntu-12.04-chef-puppet/definition.rb
  :postinstall_files => [
    "base.sh",
    "vagrant.sh",
    "virtualbox.sh",
    #"vmfusion.sh",
    "ruby.sh",
    "puppet.sh",
    "chef.sh",
    "cleanup.sh",
    "zerodisk.sh"
  ], 

"vmfusion.sh" 주석 처리해 둔다.

VM 빌드한다. 여기엔 definition.rb 정보를 기준으로 해 필요한 소프트웨어들을 설치하게 된다.
$ veewee vbox build 'ubuntu-12.04-chef-puppet' --nogui --force 

실제로 ubuntu-12.04-chef-puppet.vbox 파일 위치는 아래에 생성된다.
$ cd ~/VirtualBox\ VMs/
$ ls
./  .DS_Store    ubuntu-12.04-chef-puppet/

다음은 vagrant에서 사용하기 위해 VM Export를 진행한다.
$ veewee vbox export 'ubuntu-12.04-chef-puppet'

Export 명령을 실행하면 우리가 원하던 ubuntu-12.04-chef-puppet.box 파일이 생성된다. 그리고 정상적으로 실행되면 아래와 같이 커맨드들을 사용해서 Vagrant로 테스트 환경을 만들 수 있도록 하게 한다.
$ vagrant box add 'ubuntu-12.04-chef-puppet' 
  '/Users/pepsi/git/veewee/ubuntu-12.04-chef-puppet.box'

$ vagrant init 'ubuntu-12.04-chef-puppet'
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

로컬의 박스 파일을 드랍박스에 올리고(여러분들의 테스트를 위해서) glu용 Vagrantfile과 스크립트를 다운받아서 실제 glu의 테스트 환경을 구축해 본다.

3. glu 관련 패키지 설치
참고로 여러분은 여기서부터 진행해도 무방하다.
먼저 제가 작성한 Vagrantfile 및 glu 등의 설치파일 등 파일을 깃허브에 올렸으니, 여러분은 깃허브에서 다운받아서 아래의 순으로 처리를 하면 정상적인 테스트 환경을 볼 수 있습니다.
$ cd vagrantfiles/glu/
$ git clone git@github.com:mimul/glu-virtualbox.git
$ cd glu-virtualbox

vagrant up을 통해 VM을 구동하고 필요한 소프트웨어들을 설치한다.
$ vagrant up --glu-version=5.0.0

그 다움에는 실제 VM에 들어가서 glu 설치 디렉토리에 가서 셋업과 스타트 명령어를 실행해 glu서버를 구동하게 한다.
$ vagrant ssh
$ sudo su -l
$ cd /var/lib/glu
$ ./bin/tutorial.sh setup
$ ./bin/tutorial.sh start

테스트 화면



참고로 여러분이 혹시 테스트 하실려면 https://github.com/mimul/glu-virtualbox에 가서 git clone하신 다음 README 파일을 따라해 보시면 쉽게 테스트 환경을 구축할 수 있습니다.

Trouble Shooting

1. rvm 설치시 오류 발생할 경우 처리
- Error
Error: /opt/local/bin/port: port selfupdate failed: 
Error installing new MacPorts base: shell command failed (see log for details)

- 해결방안
a.  Launch Xcode
b.  Open Xcode preferences
c.  Click the Downloads option on the preferences panel
d.  Click the Components tab
e.  Find Command Line Tools and click Install.

2 signature validation 오류가 발생할 경우
- Error
failed verification with key /opt/local/share/macports/macports-pubkey.pem

- 해결방안
$ sudo port -f uninstall installed
$ sudo port clean all
$ sudo rm -rf \
 /opt/local \
 /Applications/DarwinPorts \ 
 /Applications/MacPorts \ 
 /Library/LaunchDaemons/org.macports.* \ 
 /Library/Receipts/DarwinPorts*.pkg \ 
 /Library/Receipts/MacPorts*.pkg \ 
 /Library/StartupItems/DarwinPortsStartup \ 
 /Library/Tcl/darwinports1.0 \ 
 /Library/Tcl/macports1.0 \ 
 ~/.macports

$ wget https://distfiles.macports.org/MacPorts/MacPorts-2.1.3.tar.gz
$ tar xvfz MacPorts-2.1.3.tar.gz
$ cd MacPorts-2.1.3
$ ./configure;make;sudo make install
$ sudo port -d selfupdate
$ sudo port upgrade outdated


Viewing all articles
Browse latest Browse all 133

Trending Articles