From ecf345349ab88232554d8852ec8048a6dfc33cec Mon Sep 17 00:00:00 2001 From: BjornMagnussonXA Date: Wed, 24 Nov 2021 08:25:15 +0100 Subject: [PATCH] Exposed external kafka port in test env Port 30098 is exposed for docker on localhost Port 30099 is exposed as nodeport for kube Issue-ID: NONRTRIC-618 Signed-off-by: BjornMagnussonXA Change-Id: I3b8c8f54691ba7d262bd0efa698ba09df1c883e0 --- test/common/mr_api_functions.sh | 8 +++ test/common/test_env-onap-guilin.sh | 2 + test/common/test_env-onap-honolulu.sh | 2 + test/common/test_env-onap-istanbul.sh | 2 + test/common/test_env-oran-cherry.sh | 2 + test/common/test_env-oran-d-release.sh | 2 + test/common/test_env-oran-e-release.sh | 2 + test/common/testcase_common.sh | 70 ++++++++++++++----------- test/simulator-group/dmaapmr/app.yaml | 8 +-- test/simulator-group/dmaapmr/docker-compose.yml | 7 +-- test/simulator-group/dmaapmr/svc.yaml | 7 ++- 11 files changed, 74 insertions(+), 38 deletions(-) diff --git a/test/common/mr_api_functions.sh b/test/common/mr_api_functions.sh index 20021316..c6feb459 100755 --- a/test/common/mr_api_functions.sh +++ b/test/common/mr_api_functions.sh @@ -372,6 +372,9 @@ __dmaapmr_export_vars() { export MR_KAFKA_SERVICE_PATH export MR_ZOOKEEPER_SERVICE_PATH + + export MR_KAFKA_KUBE_NODE_PORT + export MR_KAFKA_DOCKER_LOCALHOST_PORT } # Export env vars for config files, docker compose and kube resources @@ -509,6 +512,9 @@ start_mr() { __check_service_start $MR_DMAAP_APP_NAME $MR_DMAAP_PATH$MR_DMAAP_ALIVE_URL + echo " Kafka TCP node port $MR_KAFKA_KUBE_NODE_PORT" + + if [ $# -gt 0 ]; then if [ $(($#%3)) -eq 0 ]; then while [ $# -gt 0 ]; do @@ -608,6 +614,8 @@ start_mr() { __check_service_start $MR_DMAAP_APP_NAME $MR_DMAAP_PATH$MR_DMAAP_ALIVE_URL + echo " Kafka TCP node port $MR_KAFKA_DOCKER_LOCALHOST_PORT" + if [ $# -gt 0 ]; then if [ $(($#%3)) -eq 0 ]; then while [ $# -gt 0 ]; do diff --git a/test/common/test_env-onap-guilin.sh b/test/common/test_env-onap-guilin.sh index 4ae753c2..3254e062 100755 --- a/test/common/test_env-onap-guilin.sh +++ b/test/common/test_env-onap-guilin.sh @@ -212,6 +212,8 @@ MR_DMAAP_COMPOSE_DIR="dmaapmr" # Dir in simulator_grou MR_STUB_COMPOSE_DIR="mrstub" # Dir in simulator_group for mr stub for - docker-compose MR_KAFKA_APP_NAME="message-router-kafka" # Kafka app name, if just named "kafka" the image will not start... MR_KAFKA_PORT=9092 # Kafka port number +MR_KAFKA_DOCKER_LOCALHOST_PORT=30098 # Kafka port number for docker localhost +MR_KAFKA_KUBE_NODE_PORT=30099 # Kafka node port number for kube MR_ZOOKEEPER_APP_NAME="zookeeper" # Zookeeper app name MR_ZOOKEEPER_PORT="2181" # Zookeeper port number MR_DMAAP_HOST_MNT_DIR="/mnt" # Basedir localhost for mounted files diff --git a/test/common/test_env-onap-honolulu.sh b/test/common/test_env-onap-honolulu.sh index 17d738f0..f82d54fe 100755 --- a/test/common/test_env-onap-honolulu.sh +++ b/test/common/test_env-onap-honolulu.sh @@ -256,6 +256,8 @@ MR_DMAAP_COMPOSE_DIR="dmaapmr" # Dir in simulator_grou MR_STUB_COMPOSE_DIR="mrstub" # Dir in simulator_group for mr stub for - docker-compose MR_KAFKA_APP_NAME="message-router-kafka" # Kafka app name, if just named "kafka" the image will not start... MR_KAFKA_PORT=9092 # Kafka port number +MR_KAFKA_DOCKER_LOCALHOST_PORT=30098 # Kafka port number for docker localhost +MR_KAFKA_KUBE_NODE_PORT=30099 # Kafka node port number for kube MR_ZOOKEEPER_APP_NAME="zookeeper" # Zookeeper app name MR_ZOOKEEPER_PORT="2181" # Zookeeper port number MR_DMAAP_HOST_MNT_DIR="/mnt" # Basedir localhost for mounted files diff --git a/test/common/test_env-onap-istanbul.sh b/test/common/test_env-onap-istanbul.sh index 2a6268e7..b2b0d2ed 100644 --- a/test/common/test_env-onap-istanbul.sh +++ b/test/common/test_env-onap-istanbul.sh @@ -259,6 +259,8 @@ MR_DMAAP_COMPOSE_DIR="dmaapmr" # Dir in simulator_grou MR_STUB_COMPOSE_DIR="mrstub" # Dir in simulator_group for mr stub for - docker-compose MR_KAFKA_APP_NAME="message-router-kafka" # Kafka app name, if just named "kafka" the image will not start... MR_KAFKA_PORT=9092 # Kafka port number +MR_KAFKA_DOCKER_LOCALHOST_PORT=30098 # Kafka port number for docker localhost +MR_KAFKA_KUBE_NODE_PORT=30099 # Kafka node port number for kube MR_ZOOKEEPER_APP_NAME="zookeeper" # Zookeeper app name MR_ZOOKEEPER_PORT="2181" # Zookeeper port number MR_DMAAP_HOST_MNT_DIR="/mnt" # Basedir localhost for mounted files diff --git a/test/common/test_env-oran-cherry.sh b/test/common/test_env-oran-cherry.sh index 513afaaa..b1204ccd 100755 --- a/test/common/test_env-oran-cherry.sh +++ b/test/common/test_env-oran-cherry.sh @@ -259,6 +259,8 @@ MR_DMAAP_COMPOSE_DIR="dmaapmr" # Dir in simulator_grou MR_STUB_COMPOSE_DIR="mrstub" # Dir in simulator_group for mr stub for - docker-compose MR_KAFKA_APP_NAME="message-router-kafka" # Kafka app name, if just named "kafka" the image will not start... MR_KAFKA_PORT=9092 # Kafka port number +MR_KAFKA_DOCKER_LOCALHOST_PORT=30098 # Kafka port number for docker localhost +MR_KAFKA_KUBE_NODE_PORT=30099 # Kafka node port number for kube MR_ZOOKEEPER_APP_NAME="zookeeper" # Zookeeper app name MR_ZOOKEEPER_PORT="2181" # Zookeeper port number MR_DMAAP_HOST_MNT_DIR="/mnt" # Basedir localhost for mounted files diff --git a/test/common/test_env-oran-d-release.sh b/test/common/test_env-oran-d-release.sh index 7e495eee..cde9849b 100755 --- a/test/common/test_env-oran-d-release.sh +++ b/test/common/test_env-oran-d-release.sh @@ -278,6 +278,8 @@ MR_DMAAP_COMPOSE_DIR="dmaapmr" # Dir in simulator_grou MR_STUB_COMPOSE_DIR="mrstub" # Dir in simulator_group for mr stub for - docker-compose MR_KAFKA_APP_NAME="message-router-kafka" # Kafka app name, if just named "kafka" the image will not start... MR_KAFKA_PORT=9092 # Kafka port number +MR_KAFKA_DOCKER_LOCALHOST_PORT=30098 # Kafka port number for docker localhost +MR_KAFKA_KUBE_NODE_PORT=30099 # Kafka node port number for kube MR_ZOOKEEPER_APP_NAME="zookeeper" # Zookeeper app name MR_ZOOKEEPER_PORT="2181" # Zookeeper port number MR_DMAAP_HOST_MNT_DIR="/mnt" # Basedir localhost for mounted files diff --git a/test/common/test_env-oran-e-release.sh b/test/common/test_env-oran-e-release.sh index fc547feb..cd0d0400 100755 --- a/test/common/test_env-oran-e-release.sh +++ b/test/common/test_env-oran-e-release.sh @@ -304,6 +304,8 @@ MR_DMAAP_COMPOSE_DIR="dmaapmr" # Dir in simulator_grou MR_STUB_COMPOSE_DIR="mrstub" # Dir in simulator_group for mr stub for - docker-compose MR_KAFKA_APP_NAME="message-router-kafka" # Kafka app name, if just named "kafka" the image will not start... MR_KAFKA_PORT=9092 # Kafka port number +MR_KAFKA_DOCKER_LOCALHOST_PORT=30098 # Kafka port number for docker localhost +MR_KAFKA_KUBE_NODE_PORT=30099 # Kafka node port number for kube MR_ZOOKEEPER_APP_NAME="zookeeper" # Zookeeper app name MR_ZOOKEEPER_PORT="2181" # Zookeeper port number MR_DMAAP_HOST_MNT_DIR="/mnt" # Basedir localhost for mounted files diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh index b171d9fe..e1c90d64 100755 --- a/test/common/testcase_common.sh +++ b/test/common/testcase_common.sh @@ -1726,6 +1726,10 @@ __clean_containers() { for imagename in $APP_SHORT_NAMES; do docker ps -a --filter "label=nrttest_app=$imagename" --filter "network=$DOCKER_SIM_NWNAME" --format ' {{.Label "nrttest_dp"}}\n{{.Label "nrttest_app"}}\n{{.Names}}' >> $running_contr_file done + running_contr_file_empty="No docker containers running, started by previous test execution" + if [ -s $running_contr_file ]; then + running_contr_file_empty="" + fi # Kill all containers started by the test env - to speed up shut down docker kill $(docker ps -a --filter "label=nrttest_app" --format '{{.Names}}') &> /dev/null @@ -1773,37 +1777,41 @@ __clean_containers() { tab_heading3="$tab_heading3"" " done - echo " $tab_heading1$tab_heading2$tab_heading3"" Actions" - cntr=0 - while read p; do - if (( $cntr % 3 == 0 ));then - row="" - heading=$p - heading_len=$tab_heading1_len - fi - if (( $cntr % 3 == 1));then - heading=$p - heading_len=$tab_heading2_len - fi - if (( $cntr % 3 == 2));then - contr=$p - heading=$p - heading_len=$tab_heading3_len - fi - while (( ${#heading} < $heading_len)); do - heading="$heading"" " - done - row=$row$heading - if (( $cntr % 3 == 2));then - echo -ne $row$SAMELINE - echo -ne " $row ${GREEN}stopping...${EGREEN}${SAMELINE}" - docker stop $(docker ps -qa --filter name=${contr} --filter network=$DOCKER_SIM_NWNAME) &> /dev/null - echo -ne " $row ${GREEN}stopped removing...${EGREEN}${SAMELINE}" - docker rm --force $(docker ps -qa --filter name=${contr} --filter network=$DOCKER_SIM_NWNAME) &> /dev/null - echo -e " $row ${GREEN}stopped removed ${EGREEN}" - fi - let cntr=cntr+1 - done <$running_contr_file + if [ ! -z "$running_contr_file_empty" ]; then + echo $running_contr_file_empty | indent1 + else + echo " $tab_heading1$tab_heading2$tab_heading3"" Actions" + cntr=0 + while read p; do + if (( $cntr % 3 == 0 ));then + row="" + heading=$p + heading_len=$tab_heading1_len + fi + if (( $cntr % 3 == 1));then + heading=$p + heading_len=$tab_heading2_len + fi + if (( $cntr % 3 == 2));then + contr=$p + heading=$p + heading_len=$tab_heading3_len + fi + while (( ${#heading} < $heading_len)); do + heading="$heading"" " + done + row=$row$heading + if (( $cntr % 3 == 2));then + echo -ne $row$SAMELINE + echo -ne " $row ${GREEN}stopping...${EGREEN}${SAMELINE}" + docker stop $(docker ps -qa --filter name=${contr} --filter network=$DOCKER_SIM_NWNAME) &> /dev/null + echo -ne " $row ${GREEN}stopped removing...${EGREEN}${SAMELINE}" + docker rm --force $(docker ps -qa --filter name=${contr} --filter network=$DOCKER_SIM_NWNAME) &> /dev/null + echo -e " $row ${GREEN}stopped removed ${EGREEN}" + fi + let cntr=cntr+1 + done <$running_contr_file + fi echo "" diff --git a/test/simulator-group/dmaapmr/app.yaml b/test/simulator-group/dmaapmr/app.yaml index 01c9014b..1a9d40a5 100644 --- a/test/simulator-group/dmaapmr/app.yaml +++ b/test/simulator-group/dmaapmr/app.yaml @@ -80,6 +80,8 @@ spec: ports: - name: http containerPort: $MR_KAFKA_PORT + - name: http-external + containerPort: $MR_KAFKA_KUBE_NODE_PORT env: - name: enableCadi value: 'false' @@ -90,11 +92,11 @@ spec: - name: KAFKA_ZOOKEEPER_SESSION_TIMEOUT_MS value: '40000' - name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP - value: 'INTERNAL_PLAINTEXT:PLAINTEXT,EXTERNAL_PLAINTEXT:PLAINTEXT' + value: 'INTERNAL_PLAINTEXT:PLAINTEXT,EXTERNAL_PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT' - name: KAFKA_ADVERTISED_LISTENERS - value: 'INTERNAL_PLAINTEXT://$MR_KAFKA_SERVICE_PATH' + value: 'INTERNAL_PLAINTEXT://$MR_KAFKA_SERVICE_PATH,PLAINTEXT_HOST://localhost:$MR_KAFKA_KUBE_NODE_PORT' - name: KAFKA_LISTENERS - value: 'INTERNAL_PLAINTEXT://0.0.0.0:$MR_KAFKA_PORT' + value: 'INTERNAL_PLAINTEXT://0.0.0.0:$MR_KAFKA_PORT,PLAINTEXT_HOST://0.0.0.0:$MR_KAFKA_KUBE_NODE_PORT' - name: KAFKA_INTER_BROKER_LISTENER_NAME value: INTERNAL_PLAINTEXT - name: KAFKA_CONFLUENT_SUPPORT_METRICS_ENABLE diff --git a/test/simulator-group/dmaapmr/docker-compose.yml b/test/simulator-group/dmaapmr/docker-compose.yml index c2c1fba1..492fab1b 100644 --- a/test/simulator-group/dmaapmr/docker-compose.yml +++ b/test/simulator-group/dmaapmr/docker-compose.yml @@ -50,14 +50,15 @@ services: container_name: $MR_KAFKA_APP_NAME ports: - "$MR_KAFKA_PORT:$MR_KAFKA_PORT" + - "$MR_KAFKA_DOCKER_LOCALHOST_PORT:$MR_KAFKA_DOCKER_LOCALHOST_PORT" environment: enableCadi: 'false' KAFKA_ZOOKEEPER_CONNECT: $MR_ZOOKEEPER_APP_NAME:$MR_ZOOKEEPER_PORT KAFKA_ZOOKEEPER_CONNECTION_TIMEOUT_MS: 40000 KAFKA_ZOOKEEPER_SESSION_TIMEOUT_MS: 40000 - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL_PLAINTEXT:PLAINTEXT,EXTERNAL_PLAINTEXT:PLAINTEXT - KAFKA_ADVERTISED_LISTENERS: INTERNAL_PLAINTEXT://$MR_KAFKA_SERVICE_PATH - KAFKA_LISTENERS: INTERNAL_PLAINTEXT://0.0.0.0:$MR_KAFKA_PORT + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL_PLAINTEXT:PLAINTEXT,EXTERNAL_PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT + KAFKA_ADVERTISED_LISTENERS: INTERNAL_PLAINTEXT://$MR_KAFKA_SERVICE_PATH,PLAINTEXT_HOST://localhost:$MR_KAFKA_DOCKER_LOCALHOST_PORT + KAFKA_LISTENERS: INTERNAL_PLAINTEXT://0.0.0.0:$MR_KAFKA_PORT,PLAINTEXT_HOST://0.0.0.0:$MR_KAFKA_DOCKER_LOCALHOST_PORT KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL_PLAINTEXT KAFKA_CONFLUENT_SUPPORT_METRICS_ENABLE: 'false' KAFKA_OPTS: -Djava.security.auth.login.config=/etc/kafka/secrets/jaas/zk_client_jaas.conf diff --git a/test/simulator-group/dmaapmr/svc.yaml b/test/simulator-group/dmaapmr/svc.yaml index 446c59da..913b13e2 100644 --- a/test/simulator-group/dmaapmr/svc.yaml +++ b/test/simulator-group/dmaapmr/svc.yaml @@ -25,12 +25,17 @@ metadata: run: $MR_KAFKA_APP_NAME autotest: DMAAPMR spec: - type: ClusterIP + type: NodePort ports: - port: $MR_KAFKA_PORT targetPort: $MR_KAFKA_PORT protocol: TCP name: http + - port: $MR_KAFKA_KUBE_NODE_PORT + targetPort: $MR_KAFKA_KUBE_NODE_PORT + protocol: TCP + name: http-external + nodePort: $MR_KAFKA_KUBE_NODE_PORT selector: run: $MR_KAFKA_APP_NAME --- -- 2.16.6