本帖最后由 八戒你干嘛 于 2017-8-9 14:52 编辑
3-3. JobTracker中转站详见https://github.com/ltsopensource/light-task-scheduler中JobTracker和LTS-Admin(管理后台)部署wiki,需要配zookeeper和mysql,事先要启这2个服务。 3-4.执行用例Docker集群单个执行用例Docker容器由TaskTracker、测试工程、Java环境、Maven等组成; Dockerfile如下: - FROM progrium/busybox
- MAINTAINER hugang <hugang1010@163.com>
- # Install cURL
- RUN opkg-install curl
- # Java Version
- ENV JAVA_VERSION_MAJOR 8
- ENV JAVA_VERSION_MINOR 91
- ENV JAVA_VERSION_BUILD 14
- ENV JAVA_PACKAGE jdk
- # Download and unarchive Java
- RUN curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie"\
- http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_PACKAGE}-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz \
- | gunzip -c - | tar -xf - -C /opt &&\
- ln -s /opt/jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR} /opt/jdk &&\
- rm -rf /opt/jdk/*src.zip \
- /opt/jdk/lib/missioncontrol \
- /opt/jdk/lib/visualvm \
- /opt/jdk/lib/*javafx* \
- /opt/jdk/jre/lib/plugin.jar \
- /opt/jdk/jre/lib/ext/jfxrt.jar \
- /opt/jdk/jre/bin/javaws \
- /opt/jdk/jre/lib/javaws.jar \
- /opt/jdk/jre/lib/desktop \
- /opt/jdk/jre/plugin \
- /opt/jdk/jre/lib/deploy* \
- /opt/jdk/jre/lib/*javafx* \
- /opt/jdk/jre/lib/*jfx* \
- /opt/jdk/jre/lib/amd64/libdecora_sse.so \
- /opt/jdk/jre/lib/amd64/libprism_*.so \
- /opt/jdk/jre/lib/amd64/libfxplugins.so \
- /opt/jdk/jre/lib/amd64/libglass.so \
- /opt/jdk/jre/lib/amd64/libgstreamer-lite.so \
- /opt/jdk/jre/lib/amd64/libjavafx*.so \
- /opt/jdk/jre/lib/amd64/libjfx*.so
- # Set environment
- ENV JAVA_HOME /opt/jdk
- ENV PATH ${PATH}:${JAVA_HOME}/bin
- # maven
- ENV MAVEN_VERSION 3.3.9
- RUN mkdir -p /usr/share/maven \
- && curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \
- | gunzip -c - | tar -xf - -C /usr/share/maven \
- && ln -s /usr/share/maven/apache-maven-${MAVEN_VERSION}/bin/mvn /usr/bin/mvn
- ENV MAVEN_HOME /usr/share/maven
- RUN mkdir /FastTest
- RUN mkdir /lts-examples
- # test cases project
- ADD FastTest /FastTest
- # tasktracker
- ADD lts-examples /lts-examples
- # Executer shell
- ADD runcase.sh /
- # add settings.xml
- ADD settings.xml /
- WORKDIR /lts-examples/lts-example-tasktracker/lts-example-tasktracker-java/
- # CMD run maven
- CMD mvn exec:java -Dexec.mainClass="com.github.ltsopensource.example.java.Main" -s /settings.xml
复制代码Docker容器使用了busybox基础镜像,该基础镜像占用空间较少; 将测试工程FastTest, lts-examples(TaskTracker), runcase.sh(job任务执行的脚本,执行TestNG), settings.xml(私有仓库等配置等)添加到镜像中;启动docker容器时,同时把TaskTracker任务启起来。 启动容器: - docker run -d --net=host -v /data1/hugang/docker-distributedtest/docker-addresource/lib_path:/lib_path -it docker-distributed-self
- -v参数指将实体机下/data1/hugang/docker-distributedtest/docker-addresource/lib_path挂载到docker容器/lib_path目录下
复制代码docker集群使用swarm, 具体搭建参见:
https://docs.docker.com/engine/swarm/swarm-tutorial/create-swarm/ 或在RIO 2607的博客里找到中文版的搭建方式 3-5.测试结果解析器直接在测试工程里执行分布式任务,stdout如下:
将每个docker容器执行用例结果进行归并和展示。 4.总结分布式测试系统维护的成本是比较高的,当执行的用例数在千级以下,是没必要弄这套东西的;如果当你的执行用例数在千级以上,维护分布式测试系统,还是适合的,用空间换时间,减少你的时间成本。 DockerDistributedTest系统还在初级阶段,还有很多优化点,比如回传的结果怎么截取,只传回必要数据;结果可视化等等。
|