2018년 2월 17일 토요일

[Automate Build] 0. Introduce - current system state

I am in charge of QA  in small Data Integration Tool company since I began to work in Jan 2017. QA team's role of our company is something special. QA Team must test product's functions, performance and UI, also fix bugs, keep VCS(svn) and report product's improvements. Sometimes, we develop new function and guide operation team how to use function property.

We have two members in our QA team include me, but senior and I don't have experience about this QA role. Therefore, we had to learn about QA role ourselves. I learned product's functions and working process on qa team during the first year. In second year, I think I should introduce CD and CI if I can.

These are my tasks.
1. Test product (function, performance, UI)
2. Fix bugs
3. Develop new functions
4. Build & Release product
5. Keep VCS(subversion)


1. Test product
There is not specific test. We have only one test checklist that is thirty pages include UI, function and performance to release. It complicated three type of test. There is not unit test. We have tested everything manually. I want to make test automation. Whenever svn was committed, I have to test A to Z manually. It takes so many times.

2. Fix bugs
When bug is reported to QA team, team manager want to fix bugs in QA team.
When bug is come from new source code, team manager also want to fix bugs in QA team. I think bug reports go to man who developed this function is better than come to qa team. I can accept this. But, I want to focus on QA and make CD, CI

3. Support to create new function
Customer requires new functions. Sometimes, I find technique for new functions. I make sample code and explain to software engineer about technique that I found.

4. Build & Release product
Product build manually by Ant at eclipse. This has problems. People must make mistake. If eclipse's environments was changed to do something, building will be wrong. It occurred many time for a year. It must change to automate

5. Keep subversion
We use only trunk branch in svn. It's terrible. All codes didn't test enough to release but, they are committed to trunk. We must use branches. I will make svn's branch strategy and guild this.

[Current work flow]
1. Test



2. Commit Source Code




Most needs
1. Function Test Automation.
2. Performance Test Automation.
3. UI Test Automation.
4. Integration Test Automation.
These spend time a lot. Especially, function test is very important last gate to deploy.


Future Tools
Version Control Tool : SVN
Continuous Integration Server : Jenkins
Issue Tracking System : redmine
Build Tool : ant (hope to use gradle)
UnitTest : JUnit
UITestTool : Katalon Studio & selenium
FunctionTestTool : SoapUI
Code Coverage Tool : Not yet.


Docker run command simple reference

docker run
Run command create and start container

If you don't have image to make container, Docker automatically search proper image and pull image.

1. you don't have image
# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

# docker run ubuntu
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
1be7f2b886e8: Pull complete 
6fbc4a21b806: Pull complete 
c71a6f8e1378: Pull complete 
4be3072e5a37: Pull complete 
06c6d2f59700: Pull complete 
Digest: sha256:e27e9d7f7f28d67aa9e2d7540bdc2b33254b452ee8e60f388875e5b7d9b2b696
Status: Downloaded newer image for ubuntu:latest

# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
d23a16d47ae7        ubuntu              "/bin/bash"         18 seconds ago      Exited (0) 17 seconds ago                       stoic_johnson

# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0458a4468cbc        3 weeks ago         112MB

2. you have image
# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0458a4468cbc        3 weeks ago         112MB

# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

# docker run ubuntu

# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
6fe3a86ac19a        ubuntu              "/bin/bash"         9 seconds ago       Exited (0) 8 seconds ago                       peaceful_kare

[options]

-it
Using for interactive processes
# docker run -it ubuntu:latest

root@b9f52826da9c:/# ll
total 72
drwxr-xr-x   1 root root 4096 Feb 17 03:58 ./
drwxr-xr-x   1 root root 4096 Feb 17 03:58 ../
-rwxr-xr-x   1 root root    0 Feb 17 03:58 .dockerenv*
drwxr-xr-x   2 root root 4096 Jan 23 22:49 bin/
drwxr-xr-x   2 root root 4096 Apr 12  2016 boot/
drwxr-xr-x   5 root root  360 Feb 17 03:58 dev/
drwxr-xr-x   1 root root 4096 Feb 17 03:58 etc/
drwxr-xr-x   2 root root 4096 Apr 12  2016 home/
drwxr-xr-x   8 root root 4096 Sep 13  2015 lib/
drwxr-xr-x   2 root root 4096 Jan 23 22:49 lib64/
drwxr-xr-x   2 root root 4096 Jan 23 22:49 media/
drwxr-xr-x   2 root root 4096 Jan 23 22:49 mnt/
drwxr-xr-x   2 root root 4096 Jan 23 22:49 opt/
dr-xr-xr-x 118 root root    0 Feb 17 03:58 proc/
drwx------   2 root root 4096 Jan 23 22:49 root/
drwxr-xr-x   1 root root 4096 Jan 23 22:49 run/
drwxr-xr-x   1 root root 4096 Jan 25 18:23 sbin/
drwxr-xr-x   2 root root 4096 Jan 23 22:49 srv/
dr-xr-xr-x  13 root root    0 Feb 17 03:58 sys/
drwxrwxrwt   2 root root 4096 Jan 23 22:49 tmp/
drwxr-xr-x   1 root root 4096 Jan 23 22:49 usr/
drwxr-xr-x   1 root root 4096 Jan 23 22:49 var/

-d
To start a container in detached mode (Running in background)
* Caution : Container will stop when any foreground process don't work in container
I use option '-it' to show running container detached mode on below code
# docker run -it -d ubuntu:latest 
8bb0beb95f0f9f85cbf781650baa2194693c6eb5a425a30bcd5c03b61b1539f3

# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
8bb0beb95f0f        ubuntu:latest       "/bin/bash"         4 seconds ago       Up 4 seconds                            quizzical_goodall

-p
Publish a container᾿s port or a range of ports to the host
docker run -p hostport:containerport
# docker run -d -p 12345:6379 redis
efb01ae0a176e72a1e0c7c1e0b418e1e8d338bf2366c2991af12ad8712c32933

$ telnet localhost 12345
Trying ::1...
Connected to localhost.
Escape character is '^]'.
set test abcde
+OK
get test
$5
abcde
^]
telnet> quit
Connection closed.

--rm
automatically clean up the container and remove the file system when the container exits
seunghyun@ubuntu:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
seunghyun@ubuntu:~$ docker run -it ubuntu
root@19c1e015546a:/# exit
exit
seunghyun@ubuntu:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
19c1e015546a        ubuntu              "/bin/bash"         6 seconds ago       Exited (0) 3 seconds ago                       quirky_booth
seunghyun@ubuntu:~$ docker run -it --rm ubuntu
root@28e77f58194b:/# exit
exit
seunghyun@ubuntu:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
19c1e015546a        ubuntu              "/bin/bash"         27 seconds ago      Exited (0) 24 seconds ago                       quirky_booth

--name
Defining a name can be a handy way to add meaning to a container
seunghyun@ubuntu:~$ docker run --name seunghyun ubuntu
seunghyun@ubuntu:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
seunghyun@ubuntu:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
ee741713119e        ubuntu              "/bin/bash"         5 seconds ago       Exited (0) 4 seconds ago                       seunghyun

reference : https://docs.docker.com/engine/reference/run/

2018년 2월 14일 수요일

Mounting Virtual Box sharedFolder on Ubuntu 16.04

1. Install VBoxGuestAdditions.iso
# apt-get install virtualbox-guest-additions-iso
# mkdir -p /media/iso
# mount /usr/share/virtualbox/VBoxGuestAdditions.iso /media/iso/
# sh /media/iso/VBoxLinuxAdditions.run

2. set sharedFolder on VirtualBox
VirtualBox - Setting - Shared Folders - adds new shared folder

In this case, I set folder named 'hostFolder' on hostOS


3. manual mount
# mkdir /share
# mount -t vboxsf hostFolder /share

4. set auto mount on boot
You should uncheck Auto-mount option in VirtualBox's setting.
# vi /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
...
/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0

# append below code
# mount sharedFolder on boot
hostFolder /share vboxsf defaults 0 0

# vi /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

# append below code
# mount sharedFolder on boot
vboxsf

# reboot

2018년 2월 5일 월요일

Host file copy to container, Container file copy to host

File copy

1. Host to Container
$ docker cp /path/foo.bar containername:/path/foo.bar

2. Container to Host
$ docker cp containername:/path/foo.bar /path/foo.bar

Change Linux hostid through shell script

check your current hostid
$ hostid
007f0101

make shell
$ vi hostid.sh

copy and paste below code
#!/bin/bash
#
# Purpose: Write the passed in parameter as hostid to /etc/hostid
#          If no parameter is passed, write current hostid to /etc/hostid
# Author:  Fazle Arefin [fazlearefin at yahoo dot com]
#

if [[ -n "$1" ]]; then
  host_id=$1
  # chars must be 0-9, a-f, A-F and exactly 8 chars
  egrep -o '^[a-fA-F0-9]{8}$' <<< $host_id || exit 1
else
  host_id=$(hostid)
fi

a=${host_id:6:2}
b=${host_id:4:2}
c=${host_id:2:2}
d=${host_id:0:2}

echo -ne \\x$a\\x$b\\x$c\\x$d > /etc/hostid &&
  echo "Success" 1>&2

exit 0

run script
# sh hostid.sh AABBCCDD
AABBCCDD
Success

If shell script doesn't work, maybe you should change mode (chmod)
# chmod 755 hostid.sh

check your changed hostid
$ hostid
AABBCCDD
참고 : https://github.com/fazlearefin/sysadm-scripts/blob/master/hostid.sh

2018년 2월 3일 토요일

Set static IP on Ubuntu 16.04

open file
# vi /etc/network/interfaces


Below is my default contents
# The primary network interface
auto enp0s3
iface enp0s3 inet dhcp


change to static address
# The primary network interface
auto enp0s3
iface enp0s3 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx
dns-nameservers xxx.xxx.xxx.xxx

network restart
# systemctl restart networking.service