Monday, May 16, 2016

Docker




LXC vs LXD vs Docker

Linux Container technologies:
  • LXC
  • OpenVZ
  • Linux-VServer
  • FreeBSD jail
  • Solaris Zones
------------
  • Docker specializes in deploying apps (it encapsulates an app and its identity)
  • LXD specializes in deploying (Linux) Virtual Machines (it acts like a Linux virtual machine)


Accroding to RedHat, Containers using the libvirt-lxc tooling have been deprecated from RHEL7.1. Linux containers framework is now based on the docker command-line interface.
Linux containers are essentially the clone() system call, SELinux, and Cgroups; whether they are of a LXC or Docker (through libcontainer) type is mostly irrelevant as the Linux kernel itself “does” the process isolation.

--------------------
Docker Howto:
Tutorials:

Docker Commands

Here is a summary of currently available (version 0.7.1) docker commands:
attach: Attach to a running container
build:  Build a container from a Dockerfile
commit: Create a new image from a container's changes
cp:     Copy files/folders from the containers filesystem to the host path
diff:       Inspect changes on a container's filesystem
events: Get real time events from the server
export: Stream the contents of a container as a tar archive
history:    Show the history of an image
images: List images
import: Create a new filesystem image from the contents of a tarball
info:   Display system-wide information
insert: Insert a file in an image
inspect:    Return low-level information on a container
kill:       Kill a running container
load:   Load an image from a tar archive
login:  Register or Login to the docker registry server
logs:   Fetch the logs of a container
port:   Lookup the public-facing port which is NAT-ed to PRIVATE_PORT
ps:     List containers
pull:       Pull an image or a repository from the docker registry server
push:   Push an image or a repository to the docker registry server
restart:    Restart a running container
rm:     Remove one or more containers
rmi:        Remove one or more images
run:        Run a command in a new container
save:   Save an image to a tar archive
search: Search for an image in the docker index
start:  Start a stopped container
stop:   Stop a running container
tag:        Tag an image into a repository
top:        Lookup the running processes of a container
version:    Show the docker version information
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
-aattach to STDIN
-drun container in background
-hcontainer hostname
-i, --interactivekeep STDIN open even if not attached
--ip=""container ipv4 address
--link=[]add link to another container
--name=""Assign a name to the container
-P, --publish-allPublish all exposed ports to random ports
-p, --publish=[]publish a container's ports to the host
--rmAutomatically remove the container when it exists
-u, --user="<name|uid>[:<group|gid>]"username
-v, --volume=[host-src:]container-dest[:<options>]Bind mount a volume. The comma-delimited `options` are [rw|ro], [z|Z], [[r]shared|[r]slave|[r]private], and [nocopy]. The 'host-src' is an absolute path or a name value.
--volumes-from=[]Mount volumes from the specified container(s)
-w, --workdir=""Working directory inside the container
The -p flag can take a few different formats:
ip:hostPort:containerPort| ip::containerPort | hostPort:containerPort | containerPort
Essentially, you can omit either ip or hostPort, but you must always specify a containerPort to expose. Docker will automatically provide an ip and hostPort if they are omitted. Additionally, all of these publishing rules will default to tcp. If you need udp, simply tack it on to the end such as -p 1234:1234/udp.
============
Docker images are store under /var/lib/docker directory vary depending on the driver Docker is using for storage.  In most places this will be aufs but the RedHats went with devicemapper. You can manually set the storage driver with the -s or --storage-driver= option to the Docker daemon.
  • /var/lib/docker/{driver-name} will contain the driver specific storage for contents of the images.
  • /var/lib/docker/graph/<id> now only contains metadata about the image, in the json and layersize files.
In the case of aufs:
  • /var/lib/docker/aufs/diff/<id> has the file contents of the images.
  • /var/lib/docker/repositories-aufs is a JSON file containing local image information. This can be viewed with the command docker images.
In the case of devicemapper:
  • /var/lib/docker/devicemapper/devicemapper/data stores the images
  • /var/lib/docker/devicemapper/devicemapper/metadata the metadata
  • Note these files are thin provisioned "sparse" files so aren't as big as they seem.
The images are stored in /var/lib/docker/graph/<id>/layer.
Note that images are just diffs from the parent image. The parent ID is stored with the image's metadata /var/lib/docker/graph/<id>/json.
When you docker run an image. AUFS will 'merge' all layers into one usable file system.

-------
* Increase the storage disk for one container which defaults to 10G
* Increase the total data space used by docker on your platform, which defaults to (type ‘docker info’): Data Space Total: 107.4 GB

# docker info
 ...
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Total: 107.4 GB
 ...
 Data loop file: /home/docker/devicemapper/devicemapper/data
 Metadata loop file: /home/docker/devicemapper/devicemapper/metadata
Modify docker config file "/etc/sysconfig/docker" option:
OPTIONS='--selinux-enabled=false --storage-opt dm.no_warn_on_loop_devices=true –storage-opt dm.basesize=400G -g /home/docker'
Create 400G data file:
# dd if=/dev/zero of=/home/docker/devicemapper/devicemapper/data bs=1G count=0 seek=400
Docker default ip is 172.17.42.1/16 assign to virtual interface docker0. But docker0 is no ordinary interface. It is a virtual Ethernet bridge that automatically forwards packets between any other network interfaces that are attached to it. This lets containers communicate both with the host machine and with each other. Every time Docker creates a container, it creates a pair of “peer” interfaces that are like opposite ends of a pipe — a packet sent on one will be received on the other. It gives one of the peers to the container to become its eth0interface and keeps the other peer, with a unique name likevethAQI2QT, out in the namespace of the host machine. By binding every veth* interface to the docker0 bridge, Docker creates a virtual subnet shared between the host machine and every Docker container.

Docker is based on so called images. These images are comparable to virtual machine images and contain files, configurations and installed programs. And just like virtual machine images you can start instances of them. A running instance of an image is called container. You can make changes to a container (e.g. delete a file), but these changes will not affect the image. However, you can create a new image from a running container (and all it changes) using docker commit <container-id> <new-image-name>. Export is used to persist a container, and save is used to persist a image. exportwill give you a flat .tar archive containing your container filesystem, all the metadata will be lost, so in case you try to run the container with that image you have remention the CMD and other metdata. (Export-Import creates new Container where as the Save-Load shows time of the original file created.)
docker save and docker load will preserve image metadata (CMD, ENTRYPOINT, etc) and all layers.docker export and docker import don't preserve metadata. This is by design and it's not being changed.
docker export does not export everything about the container — just the filesystem. So, when importing the dump back into a new docker image, additional flags need to be specified to recreate the context.
docker export - saves a container’s running or paused instance to a file
docker save - saves a non-running container image to a file
# sudo docker export <CONTAINER ID> > /home/export.tar
# sudo docker save <image> > /home/save.tar

In rhel 7, create static route file:
# cat /etc/sysconfig/network-scripts/route-em2
172.17.117.0/24 via 172.16.131.1 dev em2
Then the docker interface ip become 172.18.0.1/16

- yum install docker
  # yum install -y docker
  # systemctl disable firewalld && systemctl stop firewalld
  # systemctl enable docker && systemctl start docker
  # docker version
  # docker info
  . to install a CentOS 7 distribution
  # docker pull centos:centos7
  . To display the list of locally available images
  # docker images
  . Show all containers (default shows just running)
  # docker ps -a
  . To test your new image
  # docker run centos:centos7 /bin/ping google.com -c 2
  . create a container
  # mkdir -p /var/www/html
  # restorecon -R /var/www
  # docker run -d -p 8000:8000 --name="python_web" -v /usr/sbin:/usr/sbin -v /usr/bin:/usr/bin -v /usr/lib64:/usr/lib64 -w /var/www/html -v /var/www/html:/var/www/html centos:centos7 /bin/python -m SimpleHTTPServer 8000
  # netstat -tupln | grep 8000
  . stop/remove all docker containers (in bash)
  $ docker stop $(docker ps -a -q)
  $ docker rm $(docker ps -a -q)
  . clean up old containers
  $ docker ps -a | grep 'weeks ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm 
  . copy docker image to another machine
  # docker save -o <save image to path> <image name>
  Or # docker save <image name> > saved.tar
  # docker load -i <path to image tar file>
  Or # docker save <image> | bzip2 | ssh user@host 'bunzip2 | docker load'
  Or # docker save <image> | gzip -9 -c > image.tgz
       # gunzip -c image.tgz | docker load
  . start a stopped container
  # docker start -ai 665b4a1e17b6 # by ID
  # docker start -ai mad_brattain # by name
  . attach to a running container
  # docker attach 665b4a1e17b6
  or to different shell


  # docker exec -i -t 665b4a1e17b6 /bin/bash


  . script to auto upgrade docker images http://stackoverflow.com/questions/26423515/how-to-automatically-update-your-docker-containers-if-base-images-are-updated




  .  to get the number of restarts for container “my-container”
  # docker inspect -f "{{ .RestartCount }}" my-container

  . to get the last time the container was (re)started
 # docker inspect -f "{{ .State.StartedAt }}" my-container
  .wowo
 # docker
  .wowo
 # docker
  .wowo
 # docker
  .wowo
 # docker
  .wowo
 # docker
  .wowo
 # docker

Tuesday, April 26, 2016

SI notes


Django

EMC
  • https://vblurbs.com/2014/05/08/isilon-back-to-basics-series-part-1-isilon-overview/
  • http://isiblog.emc.com/2014/05/creating-smb-shares-expansion-variables-emc-isilon-onefs/
  • cli guide https://www.emc.com/collateral/TechnicalDocument/docu56048.pdf
  • web guide https://www.emc.com/collateral/TechnicalDocument/docu50220.pdf
  • OneFS 7.2 Documentatioin https://community.emc.com/docs/DOC-40113
  • SMB share provisioning https://youtu.be/5TAmqE8epzg
  • pocket survive guide http://sapsg.blogspot.com/2012/11/isilon.html

Saturday, April 9, 2016

云测试中QA团队的作用

http://www.lofter.com/tag/mobilerrunner
  公司转向云部署模式或使用云测试服务来测试一个app时有不少好处。本文将介绍高水平的云概念并讨论云测试中质量工程师的作用。
  我们来看看云测试时需要考虑哪些吧。
  根据一份Gartner报告,云计算是“一套规则,技术和用于提供IT功能(软件,平台和基础设施)并将之作为一项按需扩展弹性服务的商业模式”
  云计算的五大特征
  --它使用动态的,共享的和虚拟的基础设施
  --它是弹性的,可扩展的(根据负载增加和减少)
  --它根据消费定价
  --它可以用在各种常用网络上
  基于部署模式,有公共云,私有云,混合云和社区云。
  为云用户提供的云服务模式
  高水平的有三种模式:SaaS, PaaS, and IaaS。但是这些已经被最近开发的更多服务模式扩充了。主要云服务模式有:
  --软件即服务(SaaS)– 例: QuickBooks Online accounting software on the cloud, Yahoo mail, Gmail
  --平台即服务(PaaS)– 例: Google AppEngine, Amazon Beanstalk, Saleforce’s Heroku, Cloud Foundry (开源PaaS)
  --基础设施即服务(IaaS)– 例: Amazon Elastic Compute Cloud service(s), S3, Windows Azure Storage
  --数据库即服务(DBaaS)– 例: Oracle Cloud database service, Amazon Relational Database Service – MySQL, Microsoft SQL Azure, Amazon DynamoDB, MongoDB database as a service
  --分布式计算即服务(big data)– 例: Hortonworks, Cloudera, MapR, AWS
  --测试即服务(TaaS)– 例: Soasta, HP, Keynote, Perfectomobile, Gomez
  --内存内缓存服务– 例: Amazon Elasticache
  --后端即服务– 例: Parse, Stackmob, Cocoafish
  --集成平台即服务– 例: Mule Software
  云计算和云测试的好处有?
  --业务敏捷性和快速上市时间模式云计算提供即消应用云的资源如IT基础设施,软件平台和商业应用.
  --优化IT成本——云可以减少你的部分IT运营成本。
  --现收现付模式——云计算的一个重要特征就是它的按需功能。计算,存储功能或app资源只在需要时用,且你只需支付你使用的。 
  --资产高回报——云计算通过卸载数据中心帮助减少IT成本,IT运营人员和相关成本。
  --创新推动者——云提供一种方法来创建更多业务和IT组织内部的创新。
  --业务试验推动者——云为业务试验和减少风险提供一个平台
  让我们将测试分为高水平的两类:
  1.测试云中的app。
  2.使用云测试服务测试app。
  测试云app
  使用之前提到的一种部署模式将App部署在云中。测试员测试功能、集成、端到端、负载、压力、和安全等测试的各个方面。
  例子:小业务要用的QuickBooks Online (SaaS) cloud accounting software, Gmail, and Yahoo Mail。
  Web app:app用户界面是通过浏览器和web服务(SOAP, RESTful)并使用客户端工具(如Chrome Postman, SOAPUI)或使用基于java的单元测试框架来测试的。
  移动app:app下到智能机上,并用真实设备和/或模拟器测试。
  例如:iPhone 的QuickBooks Online,Android 的QuickBooks Online,和iPhone/Android 的Yahoo Mail.
  他们交互式地自动地为测试web和移动app提供基于云的测试平台。云测试服务供应商需要维护测试基础设施,提供持续集成工具和自动化工具。这种服务模式也称为测试即服务(TaaS).有时,term这个术语也可以指外包测试模型。但是本文的重点是云测试服务模式而不是外包模式。
  例如:Soasta, HP, Keynote, Perfectomobile, Gomez
  一些优点和之前提到的云计算的优点一样。以下是一些不一样的优点:
  --复杂性和资源:app在增加在改变,先在还多维。例如,一个webapp需在不同的操作系统上用不同的浏览器测试。如果是一个移动app,那么就需要在不同的移动设备,移动网络并按照如3G, 4G, Wi-Fi和Wi-Max的标准来测试。创建很复杂的测试实例需要资金和资源。云为测试提供所需基础设施和工具。
  --成本效益:组织不需要投入时间,资源和资金来维护测试实例。我们只需要为在云中的使用付费。如果你在进行负载测试,你就不需要等测试实例准备好了。工具许可证和维护费用被取消了。
  --更快的交付周期:因为测试员基于其要求的配置快速地得到测试实例,一个云测试服务可以被集成到我们的持续集成系统中,所以它积极影响了上市时间。这也支持使用多台虚拟机器的测试平行执行。
  --稳定的测试实例:如果没有服务(储存空间用完,资金用完,服务器宕机,等),测试工程师通常会记录事件。因为云测试服务是SLA驱动的,多数时间测试实例在增长和运行。
  --按需自动化服务:测试实例是从大范围的虚拟环境以自助服务的方式来按需提供的。测试可以手动也可以自动进行。
  --多地执行测试:对于负载测试,可以通过选择实例,服务器和服务器位置来按需形成负载。
  1.云就绪
  --你的app准备好要在云中测试吗?如果没有,建议QA团队花时间考虑安全和防火墙等问题以便让云就绪。
  --确保测试,测试框架和工具准备好使用任何一个云测试服务供应商而非锁定一个供应商/工具来进行测试。
  如果你的组织计划使用云部署模式,那你就需要确保测试的可测试性和各种类型包含在发展蓝图内。
  --了解云供应商提供的云部署模式,模式和技术。
  --想出一个云测试策略。这也应该覆盖将被执行的测试,手动或自动化测试,以及测试执行的持续时间。
  --列出你的app平台/技术的组件和它的版本,比如app服务器,web服务器,函数库,数据库和操作系统。
  --与你的团队和主题专家重新评估策略。
  3.列出相关服务/系统
  比如,如果你的app被集成到内部/外部相关服务中,那么当你的app部署到云上或用云测试服务测试时确保相关的组件工作。
  --如果你的app被部署到云中,确保云部署服务提供商和测试服务提供商能够彼此交流一下。
  --如果你的app被部署到你那儿,要确保你的云测试服务提供商可以接触到app和集成组件。
  确定将在云测试环境中执行的手动和自动化测试。因为测试服务成本是基于使用,花时间计划测试执行很有效。
 云测试中QA团队的作用 - arting804 - arting804的博客
图1. 选择云测试服务提供商的准则
  5.为在云中测试移动/webapp选择正确的供应商。在选择供应商前,彻底了解你公司的具体需求以及服务提供商提供了什么。使用他们的免费试用机会去了解。有效地花时间和金钱在此任务上很好。
  6.安全:QA团队应该带上白帽子。维基百科上说术语“白帽子”在网络俚语中指一个有道德的电脑黑客,或是一个电脑安全专家,精通渗透测试以及其他测试方法,确保组织信息系统的安全。了解资产的安全责任,比如物理安全,网络基础设施,虚拟机器,传输中的数据,静止数据,操作系统,凭证,策略和配置。一直要在你的手动/自动化云测试中使用非敏感合成数据。云安全联盟(CSA)是一个非盈利组织,它的使命是促进最佳实践的使用以在云计算中提供安全保障。云安全联盟是由行业从业者,企业,协会以及其他关键利益相关者组成的大联盟。根据CSA 2013报告,以下是前九大威胁:
  a. 数据泄露
  b.数据丢失
  c.账户劫持
  d.不安全的应用程序接口
  e.拒接服务
  f.恶意的内部员工
  g.滥用云服务
  h.不够关心
  i.共享技术问题
  7.规定遵守
  我们应该要知道云供应商规定的用以维护安全并保护数据的限制。遵守责任基本大家都知道——云供应商提供基础设施的保障,且你的公司负责在基础设施之上的app的遵守。我们需要了解如Sarbanes-Oxley, ISO 2001, ITIL, SAE 116, SAS Type I and II, HIPAA, PCI,等由云供应商基于你们公司具体要求而规定的标准。我们可以基于我们的业务需求要求审计员制作的报告和证明。政府组织有特殊的监管需求。比如,亚马逊网络服务(AWS)GovCloud(美国)是用来解决美国政府机构,教育机构,其他用户和合作伙伴的特定监管需求的。
  了解云服务提供商的服务水平协议很重要。它指出了服务不满足服务承诺时的正常运行时间,以及申请信贷请求的规定。
  确保云服务被正确使用,因为会按你的使用收费。同时,确保服务能被充分利用。大多数云供应商提供资源使用报告。验证报告以确保你为你已经使用的服务付费。
  云供应商的位置对于网络延迟和性能测试很重要。比如,世界各地都有亚马逊的弹性计算云(EC2)。这些地方包括域和可用区。每个域都是一个独立的地理区域,都拥有多个独立的可用区。
  除了成功的业务云如电子商务网站,还有更多云可以解决全球贫困,农业问题和健康问题。我们看到医生使用社交媒体来和其他医生联系以获得建议和第二意见。移动和云计算都在不断发展,移动云计算同样也如此。这样就导致了更多该领域的标准。
  移动手机的使用增加了。IEEE将移动云列为2014的尖端技术趋势之一。IEEE说到:“移动和云计算在融合,创造一个新平台——它有可能提供无限的计算资源。移动设备被其内存,处理能力及电池寿命所限制。但是结合云计算,数据进程和存储可能会在移动设备外发生。IDC宣称“第三平台”能更好地同步数据,提高可靠性和可扩展性,使集成以及随时随地使用商业应用程序和协作服务更容易,增加用户体验和对新服务的探索。
  举例:一个移动应用程序监控设备的位置。该移动设备不断基于设备的移动将其位置信息发送给云上的数据库。一个汽车传感器即时将数据发送到云。分析数据,发送的结果可以提高燃料效率。
  作为适量保证工程师,我们需要学会它并享受云测试带来的好处。
版权声明:本文出自 SPASVO泽众软件测试网:http://www.spasvo.com/news/html/201514151919.html

Tuesday, November 17, 2015