diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-07-24 11:15:39 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-07-24 11:48:09 +0900 |
commit | 4390dfea9ab033490ef0f94329d7098ffd0ca4dc (patch) | |
tree | d30981a85871386df0e6532271d5329f823b234e /test/scenario_test | |
parent | 17deee6aa3e9a10179cda2e7e21fe435312b0051 (diff) |
test: build docker image once, use it for all tests
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'test/scenario_test')
-rw-r--r-- | test/scenario_test/bgp_router_test.py | 5 | ||||
-rw-r--r-- | test/scenario_test/ci-scripts/jenkins-build-script.sh | 17 | ||||
-rw-r--r-- | test/scenario_test/docker_control.py | 83 | ||||
-rw-r--r-- | test/scenario_test/ibgp_router_test.py | 5 | ||||
-rw-r--r-- | test/scenario_test/noseplugin.py | 2 | ||||
-rw-r--r-- | test/scenario_test/route_server_ipv4_v6_test.py | 4 | ||||
-rw-r--r-- | test/scenario_test/route_server_malformed_test.py | 4 | ||||
-rw-r--r-- | test/scenario_test/route_server_policy_test.py | 4 | ||||
-rw-r--r-- | test/scenario_test/route_server_test.py | 4 |
9 files changed, 32 insertions, 96 deletions
diff --git a/test/scenario_test/bgp_router_test.py b/test/scenario_test/bgp_router_test.py index 31792044..521c6af5 100644 --- a/test/scenario_test/bgp_router_test.py +++ b/test/scenario_test/bgp_router_test.py @@ -29,10 +29,7 @@ class GoBGPTestBase(unittest.TestCase): @classmethod def setUpClass(cls): - gobgp_ctn_image_name = 'osrg/gobgp' - if parser_option.use_local: - make_gobgp_ctn() - gobgp_ctn_image_name = 'gobgp' + gobgp_ctn_image_name = parser_option.gobgp_image g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1', ctn_image_name=gobgp_ctn_image_name, diff --git a/test/scenario_test/ci-scripts/jenkins-build-script.sh b/test/scenario_test/ci-scripts/jenkins-build-script.sh index 0ed43247..ac42289b 100644 --- a/test/scenario_test/ci-scripts/jenkins-build-script.sh +++ b/test/scenario_test/ci-scripts/jenkins-build-script.sh @@ -3,6 +3,7 @@ rm -rf /usr/local/jenkins/{bin,pkg,src} mkdir /usr/local/jenkins/{bin,pkg,src} mkdir -p /usr/local/jenkins/src/github.com/osrg/ +export GOBGP_IMAGE=gobgp export GOPATH=/usr/local/jenkins export GOROOT=/usr/local/go export GOBGP=/usr/local/jenkins/src/github.com/osrg/gobgp @@ -14,6 +15,10 @@ cd $GOBGP ls -al git log | head -20 +sudo docker rmi $(docker images | grep "^<none>" | awk "{print $3}") + +sudo fab -f $GOBGP/test/scenario_test/lib/base.py make_gobgp_ctn --set tag=$GOBGP_IMAGE + cd $GOBGP/gobgpd $GOROOT/bin/go get -v cd $GOBGP/test/scenario_test @@ -22,32 +27,32 @@ set +e sudo -E pip install -r pip-requires.txt # route server test -sudo -E python route_server_test.py --use-local --go-path $GOROOT/bin -s --with-xunit +sudo -E python route_server_test.py --gobgp-image $GOBGP_IMAGE --go-path $GOROOT/bin -s --with-xunit RET1=$? mv nosetests.xml ${WS}/nosetest.xml # route server ipv4 ipv6 test -sudo -E python route_server_ipv4_v6_test.py --use-local --go-path $GOROOT/bin -s --with-xunit +sudo -E python route_server_ipv4_v6_test.py --gobgp-image $GOBGP_IMAGE --go-path $GOROOT/bin -s --with-xunit RET2=$? mv nosetests.xml ${WS}/nosetest_ip.xml # route server malformed message test -sudo -E python route_server_malformed_test.py --use-local --go-path $GOROOT/bin -s --with-xunit +sudo -E python route_server_malformed_test.py --gobgp-image $GOBGP_IMAGE --go-path $GOROOT/bin -s --with-xunit RET3=$? mv nosetests.xml ${WS}/nosetest_malformed.xml # bgp router test -sudo -E python bgp_router_test.py --use-local --go-path $GOROOT/bin -s --with-xunit +sudo -E python bgp_router_test.py --gobgp-image $GOBGP_IMAGE --go-path $GOROOT/bin -s --with-xunit RET4=$? mv nosetests.xml ${WS}/nosetest_bgp.xml # route server policy test -sudo -E python route_server_policy_test.py --use-local --go-path $GOROOT/bin -s --with-xunit +sudo -E python route_server_policy_test.py --gobgp-image $GOBGP_IMAGE --go-path $GOROOT/bin -s --with-xunit RET5=$? mv nosetests.xml ${WS}/nosetest_policy.xml # bgp router test -sudo -E python ibgp_router_test.py --use-local --go-path $GOROOT/bin -s --with-xunit +sudo -E python ibgp_router_test.py --gobgp-image $GOBGP_IMAGE --go-path $GOROOT/bin -s --with-xunit RET6=$? mv nosetests.xml ${WS}/nosetest_ibgp.xml diff --git a/test/scenario_test/docker_control.py b/test/scenario_test/docker_control.py index 056d43cd..3232f566 100644 --- a/test/scenario_test/docker_control.py +++ b/test/scenario_test/docker_control.py @@ -126,9 +126,9 @@ def docker_container_run_quagga(quagga_num, bridge): local(cmd, capture=True) -def docker_container_run_gobgp(bridge): +def docker_container_run_gobgp(bridge, image='osrg/gobgp'): cmd = "docker run --privileged=true -v " + CONFIG_DIR + ":" + SHARE_VOLUME + " -d --name "\ - + GOBGP_CONTAINER_NAME + " -id osrg/gobgp" + + GOBGP_CONTAINER_NAME + " -id " + image local(cmd, capture=True) docker_container_set_ipaddress(bridge, GOBGP_CONTAINER_NAME, GOBGP_ADDRESS_0[IP_VERSION] + BASE_MASK[IP_VERSION]) @@ -391,7 +391,7 @@ def build_config_tools(go_path): local(cmd, capture=True) -def prepare_gobgp(log_debug, use_local): +def prepare_gobgp(log_debug, image='osrg/gobgp'): # cleanup gobgp container containers = docker_containers_get() @@ -401,32 +401,16 @@ def prepare_gobgp(log_debug, use_local): # set log option opt = "-l debug" if log_debug else "" do_build = False - # execute local gobgp program in the docker container if the input option is local make_startup_file(log_opt=opt) - if use_local: - print "execute gobgp program in local machine." - pwd = local("pwd", capture=True) - if A_PART_OF_CURRENT_DIR in pwd: - gobgp_path = re.sub(A_PART_OF_CURRENT_DIR, "", pwd) - cmd = "cp -r " + gobgp_path + " " + CONFIG_DIRR - local(cmd, capture=True) - make_install_file() - do_build = True - else: - print "local gobgp dosen't exist." - print "get the latest master gobgp from github." - else: - print "execute gobgp program of osrg/master in github." change_owner_to_root(CONFIG_DIR) - cmd = "docker run --privileged=true -v " + CONFIG_DIR + ":" + SHARE_VOLUME + " -d --name " \ - + GOBGP_CONTAINER_NAME + " -id osrg/gobgp" + + GOBGP_CONTAINER_NAME + " -id " + image local(cmd, capture=True) if do_build: build_gobgp() -def init_test_env_executor(quagga_num, use_local, go_path, log_debug=False, is_route_server=True): +def init_test_env_executor(quagga_num, image, go_path, log_debug=False, is_route_server=True): print "start initialization of test environment." if docker_container_check() or bridge_setting_check(): @@ -440,28 +424,13 @@ def init_test_env_executor(quagga_num, use_local, go_path, log_debug=False, is_r make_config(quagga_num, go_path, BRIDGE_0, ("" if is_route_server else "--normal-bgp")) # run gobgp docker container - docker_container_run_gobgp(BRIDGE_0) + docker_container_run_gobgp(BRIDGE_0, image) # set log option opt = "-l debug" if log_debug else "" do_build = False # execute local gobgp program in the docker container if the input option is local make_startup_file(log_opt=opt) - if use_local: - print "execute gobgp program in local machine." - pwd = local("pwd", capture=True) - if A_PART_OF_CURRENT_DIR in pwd: - gobgp_path = re.sub(A_PART_OF_CURRENT_DIR, "", pwd) - cmd = "cp -r " + gobgp_path + " " + CONFIG_DIRR - local(cmd, capture=True) - make_install_file() - do_build = True - else: - print "scenario_test directory is not." - print "execute gobgp program of osrg/master in github." - else: - print "execute gobgp program of osrg/master in github." - change_owner_to_root(CONFIG_DIR) start_gobgp(build=do_build) @@ -497,7 +466,7 @@ def init_policy_test_env_executor(quagga_num, use_ipv6=False, use_exabgp=False): print "complete initialization of test environment." -def init_ipv6_test_env_executor(quagga_num, use_local, go_path, log_debug=False): +def init_ipv6_test_env_executor(quagga_num, image, go_path, log_debug=False): print "start initialization of test environment." if docker_container_check() or bridge_setting_check(): @@ -511,28 +480,12 @@ def init_ipv6_test_env_executor(quagga_num, use_local, go_path, log_debug=False) make_config(quagga_num, go_path, BRIDGE_0) # run gobgp docker container - docker_container_run_gobgp(BRIDGE_0) + docker_container_run_gobgp(BRIDGE_0, image) # set log option opt = "-l debug" if log_debug else "" do_build = False - # execute local gobgp program in the docker container if the input option is local make_startup_file(log_opt=opt) - if use_local: - print "execute gobgp program in local machine." - pwd = local("pwd", capture=True) - if A_PART_OF_CURRENT_DIR in pwd: - gobgp_path = re.sub(A_PART_OF_CURRENT_DIR, "", pwd) - cmd = "cp -r " + gobgp_path + " " + CONFIG_DIRR - local(cmd, capture=True) - make_install_file() - do_build = True - else: - print "scenario_test directory is not." - print "execute gobgp program of osrg/master in github." - else: - print "execute gobgp program of osrg/master in github." - change_owner_to_root(CONFIG_DIR) start_gobgp(do_build) @@ -543,7 +496,7 @@ def init_ipv6_test_env_executor(quagga_num, use_local, go_path, log_debug=False) print "complete initialization of test environment." -def init_malformed_test_env_executor(use_local, go_path, exabgp_path, log_debug=False): +def init_malformed_test_env_executor(image, go_path, exabgp_path, log_debug=False): print "start initialization of exabgp test environment." if docker_container_check() or bridge_setting_check(): @@ -559,28 +512,12 @@ def init_malformed_test_env_executor(use_local, go_path, exabgp_path, log_debug make_config_append(100, go_path, BRIDGE_0, peer_opts) # run gobgp docker container - docker_container_run_gobgp(BRIDGE_0) + docker_container_run_gobgp(BRIDGE_0, image) # set log option opt = "-l debug" if log_debug else "" do_build = False make_startup_file(log_opt=opt) - # execute local gobgp program in the docker container if the input option is local - if use_local: - print "execute gobgp program in local machine." - pwd = local("pwd", capture=True) - if A_PART_OF_CURRENT_DIR in pwd: - gobgp_path = re.sub(A_PART_OF_CURRENT_DIR, "", pwd) - cmd = "cp -r " + gobgp_path + " " + CONFIG_DIRR - local(cmd, capture=True) - make_install_file() - do_build = True - else: - print "scenario_test directory is not." - print "execute gobgp program of osrg/master in github." - else: - print "execute gobgp program of osrg/master in github." - change_owner_to_root(CONFIG_DIR) if exabgp_path != "": diff --git a/test/scenario_test/ibgp_router_test.py b/test/scenario_test/ibgp_router_test.py index 26e07757..567d8687 100644 --- a/test/scenario_test/ibgp_router_test.py +++ b/test/scenario_test/ibgp_router_test.py @@ -29,10 +29,7 @@ class GoBGPTestBase(unittest.TestCase): @classmethod def setUpClass(cls): - gobgp_ctn_image_name = 'osrg/gobgp' - if parser_option.use_local: - make_gobgp_ctn() - gobgp_ctn_image_name = 'gobgp' + gobgp_ctn_image_name = parser_option.gobgp_image g1 = GoBGPContainer(name='g1', asn=65000, router_id='192.168.0.1', ctn_image_name=gobgp_ctn_image_name, diff --git a/test/scenario_test/noseplugin.py b/test/scenario_test/noseplugin.py index 1eae95bb..39929645 100644 --- a/test/scenario_test/noseplugin.py +++ b/test/scenario_test/noseplugin.py @@ -8,7 +8,7 @@ class OptionParser(Plugin): def options(self, parser, env=os.environ): super(OptionParser, self).options(parser, env=env) - parser.add_option('--use-local', action="store_true", dest="use_local", default=False) + parser.add_option('--gobgp-image', action="store", dest="gobgp_image", default="osrg/gobgp") parser.add_option('--exabgp-path', action="store", dest="exabgp_path", default="") parser.add_option('--go-path', action="store", dest="go_path", default="") parser.add_option('--gobgp-log-level', action="store", diff --git a/test/scenario_test/route_server_ipv4_v6_test.py b/test/scenario_test/route_server_ipv4_v6_test.py index bc9e234d..ce3dc36e 100644 --- a/test/scenario_test/route_server_ipv4_v6_test.py +++ b/test/scenario_test/route_server_ipv4_v6_test.py @@ -37,10 +37,10 @@ class GoBGPIPv6Test(GoBGPTestBase): def test_01_ipv4_ipv6_neighbor_established(self): print "test_ipv4_ipv6_neighbor_established" - use_local = parser_option.use_local + image = parser_option.gobgp_image go_path = parser_option.go_path log_debug = True if parser_option.gobgp_log_level == 'debug' else False - fab.init_ipv6_test_env_executor(self.quagga_num, use_local, go_path, log_debug) + fab.init_ipv6_test_env_executor(self.quagga_num, image, go_path, log_debug) print "please wait (" + str(self.initial_wait_time) + " second)" time.sleep(self.initial_wait_time) fab.docker_container_ipv6_quagga_append_executor([3, 4], go_path) diff --git a/test/scenario_test/route_server_malformed_test.py b/test/scenario_test/route_server_malformed_test.py index 75c641c2..296f3645 100644 --- a/test/scenario_test/route_server_malformed_test.py +++ b/test/scenario_test/route_server_malformed_test.py @@ -72,12 +72,12 @@ def test_malformed_packet(): print "pattern element is " + str(len(pattern)) sys.exit(1) - use_local = parser_option.use_local + image = parser_option.gobgp_image log_debug = True if parser_option.gobgp_log_level == 'debug' else False go_path = parser_option.go_path exabgp_path = parser_option.exabgp_path - fab.init_malformed_test_env_executor(use_local, go_path, exabgp_path, log_debug) + fab.init_malformed_test_env_executor(image, go_path, exabgp_path, log_debug) for pkey in pattern: conf_file = pwd + "/exabgp_test_conf/" + pkey diff --git a/test/scenario_test/route_server_policy_test.py b/test/scenario_test/route_server_policy_test.py index 4f524228..204b55b1 100644 --- a/test/scenario_test/route_server_policy_test.py +++ b/test/scenario_test/route_server_policy_test.py @@ -64,9 +64,9 @@ class GoBGPTest(GoBGPTestBase): def setUpClass(cls): print 'prepare gobgp' cls.go_path = parser_option.go_path - cls.use_local = parser_option.use_local + cls.image = parser_option.gobgp_image cls.log_debug = True if parser_option.gobgp_log_level == 'debug' else False - fab.prepare_gobgp(cls.log_debug, cls.use_local) + fab.prepare_gobgp(cls.log_debug, cls.image) fab.build_config_tools(cls.go_path) @print_elapsed_time diff --git a/test/scenario_test/route_server_test.py b/test/scenario_test/route_server_test.py index 63063d50..db75e97d 100644 --- a/test/scenario_test/route_server_test.py +++ b/test/scenario_test/route_server_test.py @@ -37,10 +37,10 @@ class GoBGPTest(GoBGPTestBase): def test_01_neighbor_established(self): print "test_neighbor_established" - use_local = parser_option.use_local + image = parser_option.gobgp_image go_path = parser_option.go_path log_debug = True if parser_option.gobgp_log_level == 'debug' else False - fab.init_test_env_executor(self.quagga_num, use_local, go_path, log_debug) + fab.init_test_env_executor(self.quagga_num, image, go_path, log_debug) print "please wait " + str(self.initial_wait_time) + " second" time.sleep(self.initial_wait_time) |