ET in your environment (docker)


setup your ute machine

bash environment ready

  • get bashrc file and edit it as you want
  1. scp root@10.106.218.35:/root/.bashrc /root/.bashrc
  • get sshd configure file and restart
    scp root@10.106.218.35:/etc/ssh/sshd_config /etc/ssh/sshd_config

    service sshd restart
  • setup maven
scp root@10.106.218.35:/opt/tools/apache-maven-3.3.9-bin.tar.gz /opt/tools
tar zxvf ./apache-maven-3.3.9-bin.tar.gz
scp root@10.106.218.35:/root/.m2/settings.xml /root/.m2/settings.xml
  • startup IDEA
idea

document

docker official document

docker installation

docker offical
Chinese guide

commands and examples

  • check docker version
    docker version
  • download docker images:
    docker pull <dockerImageName>
    example: docker pull archive.docker-registry.eecloud.nsn-net.net/btsmed/imp-redhat:latest
  • set proxy if pull timeout:

    mkdir -p /etc/systemd/system/docker.service.d
    echo '[Service]' > /etc/systemd/system/docker.service.d/http-proxy.conf
    echo 'Environment="HTTP_PROXY=http://10.144.1.10:8080/" "https_proxy=http://10.144.1.10:8080"' >> /etc/systemd/system/docker.service.d/http-proxy.conf
    systemctl daemon-reload
    service docker restart
    
  • check image info:
    docker images

  • remove images:
    docker rmi <dockerImageID>
    or
    docker rmi <imageREPOSITORY>:<imageTAG>
    example: docker rmi archive.docker-registry.eecloud.nsn-net.net/btsmed/imp-redhat:latest
  • Create docker container:
    docker run --privileged --name=<containerName> -itd <dockerImageName> /bin/bash
    example: docker run --privileged --name=container1 -itd archive.docker-registry.eecloud.nsn-net.net/btsmed/imp-redhat:latest /bin/bash
  • mount local path to container remote path
    docker run --privileged --name=<containername> -v <localpath>:<containerpath> -itd <dockerimage> /bin/bash
    example: docker run --privileged --name=container1 -v /home/workspace:/data -itd archive.docker-registry.eecloud.nsn-net.net/btsmed/imp-redhat:latest /bin/bash
  • check mount local path
    docker inspect -f "{{ .Mounts }}" 'dfcee' (CONTAINER ID)
  • login container:
    docker exec -it <containerName> /bin/bash
    or
    ssh root@containerIp (the password is root by default)
    example: docker exec -it container1 /bin/bash
  • check running container:
    docker ps
  • check all containers, includeing stoped
    docker ps -a
  • stop container:
    docker stop <containerName>
    example: docker stop container1
  • remove container:
    docker rm <containerName>
    example: docker rm container1
  • get container ip:
    docker inspect --format '{{.NetworkSettings.IPAddress}}' <containerName>
  • add eth1 in container:
    docker network create --driver=bridge <networkName>
    docker network connect <networkname> <containerName>
    example:
    docker network create --driver=bridge network1
    docker network connect network1 container1

run ET

  • put source code into your mount folder
  • mvn compile package
    mvn package -DskipTests=true -P CI
  • install imp under container
    rpm -i xxxx.rpm
  • run ET
    come into source code folder
    cd test/ET folder,prepare the ET data

    make dt (stop when nbs installed)
    
    make redis (and wait about 10 seconds)
    
  • run a single ET KEYWORD, use ‘-t’, get case name from robot file

    pybot -L trace -t 'NetAct Request BTSMED To Add TA Certificate And Remove' .
    
  • run a single ET File,use ‘-s’ , get robot file name and replace ‘_’ with ‘ ‘

    pybot -L trace -s 'Security BTSMED Account Parameters Config' .
    

  • the last “.” mean the log.html file output to the current directory

How to add Log in ET

  • add shell script to the keyword and return the result
    In ET robot file,there are Test Cases and Keywords,please add shell script in the keywords
    space is very important, please copy use

    ${result}=    Run Process    'shell script'    shell=True    timeout=${G_RUN_PROCESS_TIMEOUT}
    Log    ${result.stdout}
    

  • example:

    ${result}=    Run Process    pam_tally2    shell=True    timeout=${G_RUN_PROCESS_TIMEOUT}
    Log    ${result.stdout}
    

  • or

    ${result}=    Run Process    netstat -apn|grep 0.0.0.0:${G_NETACT_SERVER_PORT}|grep LISTEN    shell=True    timeout=${G_RUN_PROCESS_TIMEOUT}