diff --git a/.circleci/config.yml b/.circleci/config.yml index 30f8a271d..75b665fd5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,4 @@ -version: 2 +version: 2.1 # Copyright (C) 2019-2020 LEIDOS. # @@ -24,121 +24,85 @@ version: 2 # Upload test results # Every run command should start with source ${INIT_ENV} to ensure all default dependencies are available jobs: - build: + sonar-scanner: # Pull docker image # XTERM used for better make output docker: - - image: ubuntu:bionic-20190807 + - image: usdotfhwaops/v2xhubamd:<< pipeline.git.branch >> environment: TERM: xterm - + INIT_ENV: /home/V2X-Hub/.base-image/init-env.sh # Set working directory - working_directory: "/home/V2X-Hub-build" + working_directory: "/home/V2X-Hub" # Pull code and execute tests | # Name of each run command defines purpose use steps: #setup remote docker - setup_remote_docker : docker_layer_caching: false - # Checkout PR branch - - checkout: - - run: - name: Install Sonar & Dependencies + - run: + name: Run Tests & Generate Gcovr Reports command: | - set -x - apt-get update - apt-get -y install curl unzip sudo cmake gcovr gcc-7 g++-7 libboost1.65-dev libboost-thread1.65-dev libboost-regex1.65-dev libboost-log1.65-dev libboost-program-options1.65-dev libboost1.65-all-dev libxerces-c-dev libcurl4-openssl-dev libsnmp-dev libmysqlclient-dev libjsoncpp-dev uuid-dev libusb-dev libusb-1.0-0-dev libftdi-dev swig liboctave-dev gpsd libgps-dev portaudio19-dev libsndfile1-dev libglib2.0-dev libglibmm-2.4-dev libpcre3-dev libsigc++-2.0-dev libxml++2.6-dev libxml2-dev liblzma-dev dpkg-dev libmysqlcppconn-dev libev-dev libuv-dev git vim zip build-essential libssl-dev qtbase5-dev qtbase5-dev-tools curl libqhttpengine-dev libgtest-dev libcpprest-dev librdkafka-dev - - cd /home/V2X-Hub-build/ - mkdir -p ext - cd /home/V2X-Hub-build/ext/ - git clone https://github.com/usdot-fhwa-OPS/libwebsockets.git - cd /home/V2X-Hub-build/ext/libwebsockets/ - cmake -DLWS_WITH_SHARED=OFF . - make - make install - cd ../../../.. - cd /home/V2X-Hub-build/ext - git clone https://github.com/usdot-fhwa-OPS/qhttpengine.git - cd /home/V2X-Hub-build/ext/qhttpengine - cmake . - make - make install - - cd /home/V2X-Hub-build/ext/server - cmake . - make - make install - - cd /home/V2X-Hub-build/ext/ccserver - cmake . - make - make install - - cd /usr/src/googletest - mkdir build - cd /usr/src/googletest/build - cmake .. - make - make install - cd /usr/src/googletest - rm -rf build - ln -s /usr/local/lib/libgtest.a /usr/lib/libgtest.a - ln -s /usr/local/lib/libgtest_main.a /usr/lib/libgtest_main.a - cd /usr/local/lib/ - ldconfig - - cd /home/V2X-Hub-build/ext/ - git clone https://github.com/HowardHinnant/date.git - cd /home/V2X-Hub-build/ext/date - cmake . - make - make install - ldconfig - - - cd ../../../../.. - cd /home/V2X-Hub-build - mkdir .base-image - SONAR_DIR=/opt/sonarqube - mkdir $SONAR_DIR - curl -o $SONAR_DIR/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip - curl -o $SONAR_DIR/build-wrapper.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip - curl -sL https://deb.nodesource.com/setup_10.x | bash - - sudo apt-get install -y nodejs - mkdir /opt/jq - curl -L "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64" -o /opt/jq/jq - chmod +x /opt/jq/jq - cd $SONAR_DIR - unzip $SONAR_DIR/sonar-scanner.zip -d . - unzip $SONAR_DIR/build-wrapper.zip -d . - rm $SONAR_DIR/sonar-scanner.zip - rm $SONAR_DIR/build-wrapper.zip - mv $(ls $SONAR_DIR | grep "sonar-scanner-") $SONAR_DIR/sonar-scanner/ - mv $(ls $SONAR_DIR | grep "build-wrapper-") $SONAR_DIR/build-wrapper/ - echo "export PATH=$PATH:/opt/jq/:$SONAR_DIR/sonar-scanner/bin/:$SONAR_DIR/build-wrapper/" > /home/V2X-Hub-build/.base-image/init-env.sh + source ${INIT_ENV} + cd /home/V2X-Hub/src + build-wrapper-linux-x86-64 --out-dir /home/V2X-Hub/bw-output bash build.sh + ./coverage.sh - run: - name: Build V2I-Hub + name: Run Sonar Scanner command: | - set -x - source /home/V2X-Hub-build/.base-image/init-env.sh - cd /home/V2X-Hub-build/src - build-wrapper-linux-x86-64 --out-dir ../bw-output ./build.sh + source ${INIT_ENV} + echo $PATH + cd /home/V2X-Hub/src/ + if [ -z "${CIRCLE_PULL_REQUEST}" ]; then + echo "Non-PR Build Detected. Running analysis on ${CIRCLE_BRANCH}" + cd /home/V2X-Hub/ + sonar-scanner -X -Dproject.settings=.sonarqube/sonar-scanner.properties -Dsonar.login=${SONAR_SCANNER_TOKEN} + exit 0; + else + echo "PR branch ${CIRCLE_BRANCH}" + echo "Repo name ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}" + echo "URL ${CIRCLE_PULL_REQUEST}" + export PR_NUM=`echo ${CIRCLE_PULL_REQUEST} | cut -d'/' -f7` + echo "PR number ${PR_NUM}" + export BASE_BRANCH_URL="https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${PR_NUM}" + export TARGET_BRANCH=$(curl "$BASE_BRANCH_URL" | jq '.base.ref' | tr -d '"') + echo "Target Branch = ${TARGET_BRANCH}" + cd /home/V2X-Hub/ + sonar-scanner -X -Dproject.settings=.sonarqube/sonar-scanner.properties -Dsonar.login=${SONAR_SCANNER_TOKEN} -Dsonar.pullrequest.base=${TARGET_BRANCH} -Dsonar.pullrequest.branch=${CIRCLE_BRANCH} -Dsonar.pullrequest.key=${PR_NUM} + fi + sonar-scanner_develop: + # Pull docker image + # XTERM used for better make output + docker: + - image: usdotfhwaops/v2xhubamd:latest + environment: + TERM: xterm + INIT_ENV: /home/V2X-Hub/.base-image/init-env.sh + # Set working directory + working_directory: "/home/V2X-Hub" + # Pull code and execute tests | + # Name of each run command defines purpose use + steps: + #setup remote docker + - setup_remote_docker : + docker_layer_caching: false - run: name: Run Tests & Generate Gcovr Reports command: | - set -x - cd /home/V2X-Hub-build/src + source ${INIT_ENV} + cd /home/V2X-Hub/src + build-wrapper-linux-x86-64 --out-dir /home/V2X-Hub/bw-output bash build.sh ./coverage.sh - run: name: Run Sonar Scanner command: | - set -x - source /home/V2X-Hub-build/.base-image/init-env.sh + source ${INIT_ENV} + echo $PATH + cd /home/V2X-Hub/src/ if [ -z "${CIRCLE_PULL_REQUEST}" ]; then echo "Non-PR Build Detected. Running analysis on ${CIRCLE_BRANCH}" - # cd /home/V2X-Hub-build - # sonar-scanner -X -Dproject.settings=.sonarqube/sonar-scanner.properties -Dsonar.login=${SONAR_SCANNER_TOKEN} + cd /home/V2X-Hub/ + sonar-scanner -X -Dproject.settings=.sonarqube/sonar-scanner.properties -Dsonar.login=${SONAR_SCANNER_TOKEN} exit 0; else echo "PR branch ${CIRCLE_BRANCH}" @@ -149,60 +113,107 @@ jobs: export BASE_BRANCH_URL="https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${PR_NUM}" export TARGET_BRANCH=$(curl "$BASE_BRANCH_URL" | jq '.base.ref' | tr -d '"') echo "Target Branch = ${TARGET_BRANCH}" - # git merge origin/${TARGET_BRANCH} - sonar-scanner -X -Dproject.settings=.sonarqube/sonar-scanner.properties -Dsonar.login=${SONAR_SCANNER_TOKEN} -Dsonar.pullrequest.base=${TARGET_BRANCH} -Dsonar.pullrequest.branch=${CIRCLE_BRANCH} -Dsonar.pullrequest.key=${PR_NUM} + cd /home/V2X-Hub/ + sonar-scanner -X -Dproject.settings=.sonarqube/sonar-scanner.properties -Dsonar.login=${SONAR_SCANNER_TOKEN} -Dsonar.pullrequest.base=${TARGET_BRANCH} -Dsonar.pullrequest.branch=${CIRCLE_BRANCH} -Dsonar.pullrequest.key=${PR_NUM} fi - docker_build&push : + docker_build_push : machine: image: ubuntu-1604:202004-01 steps: - checkout - run: name: Docker Build - # Run MYSQL image and build v2xhub docker image + # Build v2xhub and php docker branch images command: | - cd configuration/amd64/ - docker-compose up -d db - cd ../../ - docker build --network=host -t usdotfhwaops/v2xhubamd:${CIRCLE_BRANCH,,} . - + docker build -f docker/php.yml -t usdotfhwaops/php:${CIRCLE_BRANCH,,} . + docker build -t usdotfhwaops/v2xhubamd:${CIRCLE_BRANCH,,} . - run: name: Docker Push - # Push v2xhub docker image to usdotfhwaops dockerhub + # Push v2xhub and php docker images to usdotfhwaops dockerhub command: | echo "$DOCKERHUB_PASSWORD" | docker login --username $DOCKERHUB_USERNAME --password-stdin docker push usdotfhwaops/v2xhubamd:${CIRCLE_BRANCH,,} - docker_build&push_develop : + docker push usdotfhwaops/php:${CIRCLE_BRANCH,,} + docker_build_push_develop : machine: image: ubuntu-1604:202004-01 steps: - checkout - run: name: Docker Build - # Run MYSQL image and build v2xhub docker image develop image + # Build v2xhub and php docker images develop images command: | - cd configuration/amd64/ - docker-compose up -d db - cd ../../ - docker build --network=host -t usdotfhwaops/v2xhubamd:latest . + docker build -f docker/php.yml -t usdotfhwaops/php:latest . + docker build -t usdotfhwaops/v2xhubamd:latest . + - run: + name: Docker Push + # Push v2xhub and php docker images to usdotfhwaops dockerhub + command: | + echo "$DOCKERHUB_PASSWORD" | docker login --username $DOCKERHUB_USERNAME --password-stdin + docker push usdotfhwaops/v2xhubamd:latest + docker push usdotfhwaops/php:latest + + arm_build_push : + machine: + image: ubuntu-2004:202101-01 + resource_class: arm.medium + steps: + - checkout + - run: + name: Docker Build + # Run MYSQL image and build v2xhub docker image + command: | + docker build -f docker/Dockerfile-depl -t usdotfhwaops/v2xhubarm:${CIRCLE_BRANCH,,} . - run: name: Docker Push # Push v2xhub docker image to usdotfhwaops dockerhub command: | echo "$DOCKERHUB_PASSWORD" | docker login --username $DOCKERHUB_USERNAME --password-stdin - docker push usdotfhwaops/v2xhubamd:latest + docker push usdotfhwaops/v2xhubarm:${CIRCLE_BRANCH,,} + arm_build_push_develop : + machine: + image: ubuntu-2004:202101-01 + resource_class: arm.medium + steps: + - checkout + - run: + name: Docker Build + # Run MYSQL image and build v2xhub docker image develop image + command: | + docker build -f docker/Dockerfile-depl -t usdotfhwaops/v2xhubarm:latest . + + - run: + name: Docker Push + # Push v2xhub docker image to usdotfhwaops dockerhub + command: | + echo "$DOCKERHUB_PASSWORD" | docker login --username $DOCKERHUB_USERNAME --password-stdin + docker push usdotfhwaops/v2xhubarm:latest workflows: version: 2 build: jobs: - - docker_build&push_develop: + - docker_build_push_develop: filters: branches: only: develop - - docker_build&push: + - docker_build_push: filters: branches: ignore: develop - - build + - arm_build_push: + filters: + branches: + ignore: develop + - arm_build_push_develop : + filters: + branches: + only: develop + - sonar-scanner: + requires: + - docker_build_push + - sonar-scanner_develop: + requires: + - docker_build_push_develop + diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..4f9521841 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +# Files to be ignored by the Docker context +# Any files mentioned here will not trigger Docker to force an image reuild +# if they change +.circleci +.vscode +/configuration +/data +/docker +/docs +/examples +/tests +/tools +*/*/secrets +Dockerfile +docker-compose.yml +*.md diff --git a/.sonarqube/Dockerfile b/.sonarqube/Dockerfile deleted file mode 100644 index 48a75ddd6..000000000 --- a/.sonarqube/Dockerfile +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (C) 2018-2019 LEIDOS. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -# V2X-Hub CI Image Docker Configuration Script - - - -# Set environment variable for SonarQube Binaries -# Two binaries are will go in this repo. -# The Build Wrapper which executes a code build to capture C++ -# The Sonar Scanner which evaluates both C++ and Java then uploads the results to SonarCloud -ENV SONAR_DIR=/opt/sonarqube - -# Pull scanner from internet -RUN sudo apt-get -y install curl && \ - sudo mkdir $SONAR_DIR && \ - sudo curl -o $SONAR_DIR/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.3.0.1492-linux.zip && \ - sudo curl -o $SONAR_DIR/build-wrapper.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip && \ - # Install Dependancy of NodeJs 6+ - sudo curl -sL https://deb.nodesource.com/setup_10.x | sudo bash - && \ - sudo sudo apt-get install -y nodejs && \ - # Install JQ Json Parser Tool - sudo mkdir /opt/jq && \ - sudo curl -L "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64" -o /opt/jq/jq && \ - sudo chmod +x /opt/jq/jq - - -# Unzip scanner -RUN cd $SONAR_DIR && \ - sudo apt-get -y install unzip && \ - sudo unzip $SONAR_DIR/sonar-scanner.zip -d . && \ - sudo unzip $SONAR_DIR/build-wrapper.zip -d . && \ - # Remove zip files - sudo rm $SONAR_DIR/sonar-scanner.zip && \ - sudo rm $SONAR_DIR/build-wrapper.zip && \ - # Rename files - sudo mv $(ls $SONAR_DIR | grep "sonar-scanner-") $SONAR_DIR/sonar-scanner/ && \ - sudo mv $(ls $SONAR_DIR | grep "build-wrapper-") $SONAR_DIR/build-wrapper/ && \ - # Add scanner, wrapper, and jq to PATH - sudo echo 'export PATH=$PATH:/opt/jq/:$SONAR_DIR/sonar-scanner/bin/:$SONAR_DIR/build-wrapper/' >> /home/carma/.base-image/init-env.sh - -# Set metadata labels -LABEL org.label-schema.schema-version="1.0" -LABEL org.label-schema.name="V2X-Hub-SonarCloud" -LABEL org.label-schema.description="Base image for CARMA CI testing using SonarCloud" -LABEL org.label-schema.vendor="Leidos" -LABEL org.label-schema.version="${VERSION}" -LABEL org.label-schema.url="https://highways.dot.gov/research/research-programs/operations" -LABEL org.label-schema.vcs-url="https://github.com/usdot-fhwa-ops/V2X-HUB" -LABEL org.label-schema.vcs-ref=${VCS_REF} -LABEL org.label-schema.build-date=${BUILD_DATE} - -# Setup environment on login - diff --git a/.sonarqube/sonar-scanner.properties b/.sonarqube/sonar-scanner.properties index 8b0a71b52..334ba3ebb 100644 --- a/.sonarqube/sonar-scanner.properties +++ b/.sonarqube/sonar-scanner.properties @@ -16,9 +16,11 @@ sonar.projectKey=usdot-fhwa-ops_V2X-Hub sonar.organization=usdot-fhwa-ops -sonar.cfamily.build-wrapper-output=bw-output +sonar.cfamily.build-wrapper-output=/home/V2X-Hub/bw-output sonar.host.url=https://sonarcloud.io sonar.sourceEncoding=UTF-8 +sonar.cfamily.threads=1 +sonar.cfamily.cache.enabled=false # Set Git as SCM sensor @@ -27,86 +29,128 @@ sonar.scm.enabled=true sonar.scm.provider=git # Modules starting with Java packages then C++ packages -sonar.modules= MessageLoggerPlugin, \ - DsrcImmediateForwardPlugin, \ - MessageReceiverPlugin, \ - PedestrianPlugin, \ +sonar.modules= PedestrianPlugin, \ PreemptionPlugin, \ - TimPlugin - # LocationPlugin, \ - # MapPlugin, \ - # ODEPlugin, \ - # RtcmPlugin, \ - # SPaTLoggerPlugin, \ - # SpatPlugin, \ - # CswPlugin, \ - # DmsPlugin, \ - # TmxCore, \ - # TmxCtl, \ - # TmxTools, \ - # TmxUtils + TmxUtils, \ + CARMACloudPlugin, \ + TimPlugin, \ + LocationPlugin, \ + MapPlugin, \ + ODEPlugin, \ + RtcmPlugin, \ + SPaTLoggerPlugin, \ + SpatPlugin, \ + CswPlugin, \ + DmsPlugin, \ + TmxCore, \ + TmxCtl, \ + TmxTools, \ + MessageLoggerPlugin, \ + CommandPlugin, \ + MobilityOperationPlugin, \ + ODELoggerPlugin, \ + DsrcImmediateForwardPlugin, \ + MessageReceiverPlugin + -# TmxCore.sonar.projectBaseDir =/home/V2X-Hub-build/src/tmx/TmxCore -# TmxCtl.sonar.projectBaseDir =/home/V2X-Hub-build/src/tmx/TmxCtl -# TmxTools.sonar.projectBaseDir =/home/V2X-Hub-build/src/tmx/TmxTools -# TmxUtils.sonar.projectBaseDir =/home/V2X-Hub-build/src/tmx/TmxUtils -MessageLoggerPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/MessageLoggerPlugin -#CswPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/CswPlugin -#DmsPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/DmsPlugin -DsrcImmediateForwardPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/DsrcImmediateForwardPlugin -#LocationPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/LocationPlugin -# MapPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/MapPlugin -MessageReceiverPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/MessageReceiverPlugin -# ODEPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/ODEPlugin -PedestrianPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/PedestrianPlugin -PreemptionPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/PreemptionPlugin -# RtcmPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/RtcmPlugin -# SPaTLoggerPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/SPaTLoggerPlugin -# SpatPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/SpatPlugin -TimPlugin.sonar.projectBaseDir =/home/V2X-Hub-build/src/v2i-hub/TimPlugin +TmxCore.sonar.projectBaseDir =/home/V2X-Hub/src/tmx/TmxCore +TmxCtl.sonar.projectBaseDir =/home/V2X-Hub/src/tmx/TmxCtl +TmxTools.sonar.projectBaseDir =/home/V2X-Hub/src/tmx/TmxTools +TmxUtils.sonar.projectBaseDir =/home/V2X-Hub/src/tmx/TmxUtils +CARMACloudPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/CARMACloudPlugin +CommandPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/CommandPlugin +CswPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/CswPlugin +MobilityOperationPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/MobilityOperationPlugin +ODELoggerPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/ODELoggerPlugin +MessageLoggerPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/MessageLoggerPlugin +DmsPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/DmsPlugin +DsrcImmediateForwardPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/DsrcImmediateForwardPlugin +LocationPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/LocationPlugin +MapPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/MapPlugin +MessageReceiverPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/MessageReceiverPlugin +ODEPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/ODEPlugin +PedestrianPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/PedestrianPlugin +PreemptionPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/PreemptionPlugin +RtcmPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/RtcmPlugin +SPaTLoggerPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/SPaTLoggerPlugin +SpatPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/SpatPlugin +TimPlugin.sonar.projectBaseDir =/home/V2X-Hub/src/v2i-hub/TimPlugin # C++ Package differences # Sources -# TmxCore.sonar.sources =src -# TmxCtl.sonar.sources =src -# TmxTools.sonar.sources =src -# TmxUtils.sonar.sources =src +TmxCore.sonar.sources =src +TmxCtl.sonar.sources =src +TmxTools.sonar.sources =src +TmxUtils.sonar.sources =src MessageLoggerPlugin.sonar.sources =src -# CswPlugin.sonar.sources =src -# DmsPlugin.sonar.sources =src +CswPlugin.sonar.sources =src +DmsPlugin.sonar.sources =src DsrcImmediateForwardPlugin.sonar.sources =src -# LocationPlugin.sonar.sources =src -# MapPlugin.sonar.sources =src +LocationPlugin.sonar.sources =src +MapPlugin.sonar.sources =src MessageReceiverPlugin.sonar.sources =src -# ODEPlugin.sonar.sources =src +ODEPlugin.sonar.sources =src PedestrianPlugin.sonar.sources =src PreemptionPlugin.sonar.sources =src -# RtcmPlugin.sonar.sources =src -# SPaTLoggerPlugin.sonar.sources =src -# SpatPlugin.sonar.sources =src +RtcmPlugin.sonar.sources =src +SPaTLoggerPlugin.sonar.sources =src +SpatPlugin.sonar.sources =src TimPlugin.sonar.sources =src +CARMACloudPlugin.sonar.sources =src +CommandPlugin.sonar.sources =src +ODELoggerPlugin.sonar.sources =src +MobilityOperationPlugin.sonar.sources =src + + + + # Gcov reports path -# TmxCore.sonar.cfamily.gcov.reportsPath =coverage -# TmxCtl.sonar.cfamily.gcov.reportsPath =coverage -# TmxTools.sonar.cfamily.gcov.reportsPath =coverage -# TmxUtils.sonar.cfamily.gcov.reportsPath =coverage -MessageLoggerPlugin.sonar.cfamily.gcov.reportsPath =coverage -# CswPlugin.sonar.cfamily.gcov.reportsPath =coverage -# DmsPlugin.sonar.cfamily.gcov.reportsPath =coverage -DsrcImmediateForwardPlugin.sonar.cfamily.gcov.reportsPath =coverage -# LocationPlugin.sonar.cfamily.gcov.reportsPath =coverage -# MapPlugin.sonar.cfamily.gcov.reportsPath =coverage -MessageReceiverPlugin.sonar.cfamily.gcov.reportsPath =coverage -# ODEPlugin.sonar.cfamily.gcov.reportsPath =coverage +#TmxCore.sonar.cfamily.gcov.reportsPath =coverage +#TmxCtl.sonar.cfamily.gcov.reportsPath =coverage +#TmxTools.sonar.cfamily.gcov.reportsPath =coverage +TmxUtils.sonar.cfamily.gcov.reportsPath =coverage +#MessageLoggerPlugin.sonar.cfamily.gcov.reportsPath =coverage +#CswPlugin.sonar.cfamily.gcov.reportsPath =coverage +#DmsPlugin.sonar.cfamily.gcov.reportsPath =coverage +#DsrcImmediateForwardPlugin.sonar.cfamily.gcov.reportsPath =coverage +#LocationPlugin.sonar.cfamily.gcov.reportsPath =coverage +#MapPlugin.sonar.cfamily.gcov.reportsPath =coverage +#MessageReceiverPlugin.sonar.cfamily.gcov.reportsPath =coverage +#ODEPlugin.sonar.cfamily.gcov.reportsPath =coverage PedestrianPlugin.sonar.cfamily.gcov.reportsPath =coverage PreemptionPlugin.sonar.cfamily.gcov.reportsPath =coverage -# RtcmPlugin.sonar.cfamily.gcov.reportsPath =coverage -# SPaTLoggerPlugin.sonar.cfamily.gcov.reportsPath =coverage -# SpatPlugin.sonar.cfamily.gcov.reportsPath =coverage -TimPlugin.sonar.cfamily.gcov.reportsPath =coverage +#RtcmPlugin.sonar.cfamily.gcov.reportsPath =coverage +#SPaTLoggerPlugin.sonar.cfamily.gcov.reportsPath =coverage +#SpatPlugin.sonar.cfamily.gcov.reportsPath =coverage +#TimPlugin.sonar.cfamily.gcov.reportsPath =coverage +#CARMACloudPlugin.sonar.cfamily.gcov.reportsPath =coverage +#MobilityOperationPlugin.sonar.cfamily.gcov.reportsPath =coverage +#ODELoggerPlugin.sonar.cfamily.gcov.reportsPath =coverage +#CommandPlugin.cfamily.gcov.reportsPath =coverage # Tests # Note: For C++ setting this field does not cause test analysis to occur. It only allows the test source code to be evaluated. -# TmxUtils.sonar.tests=test +TmxUtils.sonar.tests=test +#TmxCore.sonar.tests=test +#TmxCtl.sonar.tests=test +#TmxTools.sonar.tests=test +#MessageLoggerPlugin.sonar.tests=test +#CswPlugin.sonar.tests=test +#DmsPlugin.sonar.tests=test +#DsrcImmediateForwardPlugin.sonar.tests=test +#LocationPlugin.sonar.tests=test +#MapPlugin.sonar.tests=test +#MessageReceiverPlugin.sonar.tests=test +#ODEPlugin.sonar.tests=test +PedestrianPlugin.sonar.tests=test +PreemptionPlugin.sonar.tests=test +#RtcmPlugin.sonar.tests=test +#SPaTLoggerPlugin.sonar.tests=test +#SpatPlugin.sonar.tests=test +#TimPlugin.sonar.tests=test +#CARMACloudPlugin.sonar.tests=test +#MobilityOperationPlugin.sonar.tests=test +#ODELoggerPlugin.sonar.tests=test +#CommandPlugin.sonar.tests=test diff --git a/Dockerfile b/Dockerfile index f0663ab15..0085b6fb2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,6 @@ RUN mkdir /usr/local/lib/googletest RUN ln -s /usr/lib/libgtest.a /usr/local/lib/googletest/libgtest.a RUN ln -s /usr/lib/libgtest_main.a /usr/local/lib/googletest/libgtest_main.a RUN ldconfig -ENV MYSQL_ROOT_PASSWORD ivp RUN mkdir ~/V2X-Hub COPY . /home/V2X-Hub @@ -121,7 +120,6 @@ RUN chmod +x /home/V2X-Hub/container/wait-for-it.sh WORKDIR /var/www/ RUN mkdir ~/plugins WORKDIR /home/V2X-Hub/src/v2i-hub/ -RUN tmxctl --plugin-install CommandPlugin.zip WORKDIR /var/www/plugins/ RUN mkdir /var/www/plugins/MAP RUN mkdir /var/www/plugins/.ssl @@ -132,23 +130,6 @@ RUN openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout tmxcmd.key -out tm RUN chown plugin * RUN chgrp www-data * WORKDIR /home/V2X-Hub/src/v2i-hub/ -RUN tmxctl --plugin-install CswPlugin.zip -RUN tmxctl --plugin-install DmsPlugin.zip -RUN tmxctl --plugin-install DsrcImmediateForwardPlugin.zip -RUN tmxctl --plugin-install LocationPlugin.zip -RUN tmxctl --plugin-install MapPlugin.zip -RUN tmxctl --plugin-install MessageReceiverPlugin.zip -RUN tmxctl --plugin-install ODEPlugin.zip -RUN tmxctl --plugin-install RtcmPlugin.zip -RUN tmxctl --plugin-install SpatPlugin.zip -RUN tmxctl --plugin-install PreemptionPlugin.zip -RUN tmxctl --plugin-install SPaTLoggerPlugin.zip -RUN tmxctl --plugin-install MessageLoggerPlugin.zip -RUN tmxctl --plugin-install PedestrianPlugin.zip -RUN tmxctl --plugin-install TimPlugin.zip -RUN tmxctl --plugin-install CARMACloudPlugin.zip -RUN tmxctl --plugin-install MobilityOperationPlugin.zip -RUN tmxctl --plugin-install ODELoggerPlugin.zip RUN sudo mkdir /home/V2X-Hub/.base-image @@ -156,7 +137,7 @@ ENV SONAR_DIR=/opt/sonarqube # Pull scanner from internet RUN sudo mkdir $SONAR_DIR && \ - sudo curl -o $SONAR_DIR/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.3.0.1492-linux.zip && \ + sudo curl -o $SONAR_DIR/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.4.0.2170-linux.zip && \ sudo curl -o $SONAR_DIR/build-wrapper.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip && \ # Install Dependancy of NodeJs 6+ sudo curl -sL https://deb.nodesource.com/setup_10.x | sudo bash - && \ @@ -176,7 +157,12 @@ RUN cd $SONAR_DIR && \ sudo mv $(ls $SONAR_DIR | grep "sonar-scanner-") $SONAR_DIR/sonar-scanner/ && \ sudo mv $(ls $SONAR_DIR | grep "build-wrapper-") $SONAR_DIR/build-wrapper/ && \ # Add scanner, wrapper, and jq to PATH - sudo echo "export PATH=$PATH:/opt/jq/:$SONAR_DIR/sonar-scanner/bin/:$SONAR_DIR/build-wrapper/" > /home/V2X-Hub/.base-image/init-env.sh + sudo echo 'export PATH=$PATH:/opt/jq/:$SONAR_DIR/sonar-scanner/bin/:$SONAR_DIR/build-wrapper/' >> /home/V2X-Hub/.base-image/init-env.sh + +# Install gcovr for code coverage tests and add code_coverage script folder to path +RUN sudo apt-get -y install gcovr && \ + sudo echo 'export PATH=$PATH:/home/V2X-Hub/.ci-image/engineering_tools/code_coverage/' >> /home/V2X-Hub/.base-image/init-env.sh + # Set metadata labels LABEL org.label-schema.schema-version="1.0" diff --git a/configuration/amd64/docker-compose.yml b/configuration/amd64/docker-compose.yml index 898c1dc80..da7f207f3 100755 --- a/configuration/amd64/docker-compose.yml +++ b/configuration/amd64/docker-compose.yml @@ -8,20 +8,18 @@ services: environment: - MYSQL_DATABASE=IVP - MYSQL_USER=IVP - - MYSQL_PASSWORD=ivp - - MYSQL_ROOT_PASSWORD=ivp - - username=${username} - - password=${password} + - MYSQL_PASSWORD_FILE=/run/secrets/mysql_password + - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password network_mode: host + secrets: + - mysql_password + - mysql_root_password volumes: - - ./mysql/script_credentials.sh:/docker-entrypoint-initdb.d/script_credentials.sh - ./mysql/localhost.sql:/docker-entrypoint-initdb.d/localhost.sql php: - image: php:7.2.2-apache + image: usdotfhwaops/php:latest container_name: php - volumes: - - ../../web/:/var/www/html/ network_mode: host depends_on: - db @@ -35,6 +33,15 @@ services: restart: always depends_on: - php + environment: + - MYSQL_PASSWORD=/run/secrets/mysql_password + secrets: + - mysql_password volumes: - ./logs:/var/log/tmx - ./MAP:/var/www/plugins/MAP +secrets: + mysql_password: + file: ./secrets/mysql_password.txt + mysql_root_password: + file: ./secrets/mysql_root_password.txt diff --git a/configuration/amd64/initialization.sh b/configuration/amd64/initialization.sh index a29f0515a..9a9f68e18 100755 --- a/configuration/amd64/initialization.sh +++ b/configuration/amd64/initialization.sh @@ -1,30 +1,4 @@ #!/bin/bash - -# takes user-provided username and password for docker-compose.yml and stores in .env file -echo "Please enter a username: " -read USER -echo "Password must be 8-12 charcters, and contain at least one of each of the following: uppercase letter, lowercase letter, number, and symbol." -echo "Please enter a password: " -read -s PASS - -PASS_LENGTH=`echo $PASS | wc -c` - -if [ $PASS_LENGTH -ge 8 ] && echo $PASS | grep -q [a-z] && echo $PASS | grep -q [A-Z] && echo $PASS | grep -q [0-9] && echo $PASS | grep -q [\$\!\.\+_-\*@\#\^%\?~]; then - sudo echo "username=$USER" > .env - sudo echo "password=$PASS" >> .env - echo "Confirm password: " - read -s CONF_PASS - while [ $CONF_PASS != $PASS ]; do - echo "Passwords do not match. Please re-enter password: " - read -s CONF_PASS - done - sudo echo "VALID PASSWORD" -else - sudo echo "INVALID PASSWORD" - sudo echo "Password must be 8-12 charcters, and contain at least one of each of the following: uppercase letter, lowercase letter, number, and symbol" - exit 1 -fi - sudo apt-get -y remove docker docker-engine docker.io containerd runc sudo apt-get update sudo apt-get -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common @@ -34,4 +8,5 @@ sudo apt-get update sudo apt-get -y install docker-ce docker-ce-cli containerd.io sudo apt -y install python3-pip sudo pip3 install docker-compose -sudo docker-compose up -d \ No newline at end of file +sudo docker-compose pull +sudo docker-compose up -d diff --git a/configuration/amd64/mysql/add_v2xhub_user.sh b/configuration/amd64/mysql/add_v2xhub_user.sh new file mode 100755 index 000000000..77672c300 --- /dev/null +++ b/configuration/amd64/mysql/add_v2xhub_user.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Fail when any command fails +#set -e +# Ensure mysql-client is installed +sudo apt-get update +sudo apt-get install mysql-client + +# Adds V2X-Hub user to mysql db +read -p "Please enter a username: " USER +echo "Password must be 8-12 charcters, and contain at least one of each of the following: uppercase letter, lowercase letter, number, and symbol." +read -s -p "Please enter a password: " PASS + +PASS_LENGTH=`echo $PASS | wc -c` + +if [ $PASS_LENGTH -ge 8 ] && echo $PASS | grep -q [a-z] && echo $PASS | grep -q [A-Z] && echo $PASS | grep -q [0-9] && echo $PASS | grep -q [\$\!\.\+_-\*@\#\^%\?~]; then + echo "Confirm password: " + read -s CONF_PASS + while [ $CONF_PASS != $PASS ]; do + echo "Passwords do not match. Please re-enter password: " + read -s CONF_PASS + done + echo "VALID PASSWORD" + echo "Enter MYSQL ROOT PASSWORD: " + mysql -uroot -p --silent -h127.0.0.1 -e "INSERT INTO IVP.user (IVP.user.username, IVP.user.password, IVP.user.accessLevel) VALUES('$USER', '$PASS', 3)" +else + echo "INVALID PASSWORD" + echo "Password must be 8-12 charcters, and contain at least one of each of the following: uppercase letter, lowercase letter, number, and symbol" + exit 1 +fi diff --git a/configuration/amd64/mysql/script_credentials.sh b/configuration/amd64/mysql/script_credentials.sh deleted file mode 100644 index 147ab360f..000000000 --- a/configuration/amd64/mysql/script_credentials.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -x -mysql -uroot -pivp --silent -e "INSERT INTO IVP.user (IVP.user.username, IVP.user.password, IVP.user.accessLevel) VALUES('$username', '$password', 3)" diff --git a/configuration/arm64/docker-compose.yml b/configuration/arm64/docker-compose.yml index 9478da218..cab2e4176 100644 --- a/configuration/arm64/docker-compose.yml +++ b/configuration/arm64/docker-compose.yml @@ -6,18 +6,44 @@ services: container_name: mysql restart: always environment: - MYSQL_DATABASE: IVP - MYSQL_USER: IVP - MYSQL_PASSWORD: ivp - MYSQL_ROOT_PASSWORD: ivp - username: ${username} - password: ${password} + - MYSQL_DATABASE=IVP + - MYSQL_USER=IVP + - MYSQL_PASSWORD_FILE=/run/secrets/mysql_password + - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password network_mode: host + secrets: + - mysql_password + - mysql_root_password volumes: - - "mysql_db:/var/lib/mysql" - - ./mysql/install_db.sh:/docker-entrypoint-initdb.d/install_db.sh - ./mysql/localhost.sql:/docker-entrypoint-initdb.d/localhost.sql - - ./mysql/script_credentials.sh:/docker-entrypoint-initdb.d/script_credentials.sh -volumes: - mysql_db: + php: + image: php:7.2.2-apache + container_name: php + volumes: + - ../../web/:/var/www/html/ + network_mode: host + depends_on: + - db + stdin_open: true + tty: true + + v2xhub: + image: usdotfhwaops/v2xhubarm:latest + container_name: v2xhub + network_mode: host + restart: always + depends_on: + - php + environment: + - MYSQL_PASSWORD=/run/secrets/mysql_password + secrets: + - mysql_password + volumes: + - ./logs:/var/log/tmx + - ./MAP:/var/www/plugins/MAP +secrets: + mysql_password: + file: ./secrets/mysql_password.txt + mysql_root_password: + file: ./secrets/mysql_root_password.txt diff --git a/configuration/arm64/initialization.sh b/configuration/arm64/initialization.sh index 371873a6e..f438f3ec1 100755 --- a/configuration/arm64/initialization.sh +++ b/configuration/arm64/initialization.sh @@ -1,85 +1,11 @@ #!/bin/bash - -set -e - -# takes user-provided username and password for docker-compose.yml and stores in .env file -echo "Please enter a username: " -read USER -echo "Password must be 8-12 charcters, and contain at least one of each of the following: uppercase letter, lowercase letter, number, and symbol." -echo "Please enter a password: " -read -s PASS - -PASS_LENGTH=`echo $PASS | wc -c` - -if [ $PASS_LENGTH -ge 8 ] && echo $PASS | grep -q [a-z] && echo $PASS | grep -q [A-Z] && echo $PASS | grep -q [0-9] && echo $PASS | grep -q [\$\!\.\+_-\*@\#\^%\?~]; then - sudo echo "username=$USER" > .env - sudo echo "password=$PASS" >> .env - echo "Confirm password: " - read -s CONF_PASS - while [ $CONF_PASS != $PASS ]; do - echo "Passwords do not match. Please re-enter password: " - read -s CONF_PASS - done - sudo echo "VALID PASSWORD" -else - sudo echo "INVALID PASSWORD" - sudo echo "Password must be 8-12 charcters, and contain at least one of each of the following: uppercase letter, lowercase letter, number, and symbol" - exit 1 -fi - -# Max query attempts before consider setup failed -MAX_TRIES=10 - -if - cat initializationLog.txt | grep "First Initialization Complete." -then - function postInitialization() { - sudo docker-compose up -d - } - - postInitialization "MariaDB" - -else - sudo apt-get -y remove docker docker-engine docker.io containerd runc - sudo apt-get update - sudo apt-get -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - sudo apt-get update - sudo apt-get -y install docker-ce docker-ce-cli containerd.io - sudo apt -y install python3-pip - sudo pip3 install docker-compose - sudo docker-compose up -d - # Return true-like values if and only if logs - # contain the expected "ready" line - function dbIsReady() { - sudo docker-compose logs db | grep "MySQL init process done. Ready for start up." - } - - function waitUntilServiceIsReady() { - attempt=1 - while [ $attempt -le $MAX_TRIES ]; do - if "$@"; then - echo "MariaDB container is up!" - echo "First Initialization Complete." >> initializationLog.txt - sleep 60 - sudo rm docker-compose.yml - sudo mv post-initialization.yml docker-compose.yml - sudo docker stop $(sudo docker ps -a -q) - sudo docker-compose up -d - sleep 5 - break - fi - echo "Waiting for MariaDB container... (attempt: $((attempt++)))" - sleep 60 - done - - if [ $attempt -gt $MAX_TRIES ]; then - echo "Error: MariaDB not responding, cancelling set up" - exit 1 - fi - } - - waitUntilServiceIsReady dbIsReady "MariaDB" - -fi +sudo apt-get -y remove docker docker-engine docker.io containerd runc +sudo apt-get update +sudo apt-get -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" +sudo apt-get update +sudo apt-get -y install docker-ce docker-ce-cli containerd.io +sudo apt -y install python3-pip +sudo pip3 install docker-compose +sudo docker-compose up -d diff --git a/configuration/arm64/mysql/add_v2xhub_user.sh b/configuration/arm64/mysql/add_v2xhub_user.sh new file mode 100755 index 000000000..77672c300 --- /dev/null +++ b/configuration/arm64/mysql/add_v2xhub_user.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Fail when any command fails +#set -e +# Ensure mysql-client is installed +sudo apt-get update +sudo apt-get install mysql-client + +# Adds V2X-Hub user to mysql db +read -p "Please enter a username: " USER +echo "Password must be 8-12 charcters, and contain at least one of each of the following: uppercase letter, lowercase letter, number, and symbol." +read -s -p "Please enter a password: " PASS + +PASS_LENGTH=`echo $PASS | wc -c` + +if [ $PASS_LENGTH -ge 8 ] && echo $PASS | grep -q [a-z] && echo $PASS | grep -q [A-Z] && echo $PASS | grep -q [0-9] && echo $PASS | grep -q [\$\!\.\+_-\*@\#\^%\?~]; then + echo "Confirm password: " + read -s CONF_PASS + while [ $CONF_PASS != $PASS ]; do + echo "Passwords do not match. Please re-enter password: " + read -s CONF_PASS + done + echo "VALID PASSWORD" + echo "Enter MYSQL ROOT PASSWORD: " + mysql -uroot -p --silent -h127.0.0.1 -e "INSERT INTO IVP.user (IVP.user.username, IVP.user.password, IVP.user.accessLevel) VALUES('$USER', '$PASS', 3)" +else + echo "INVALID PASSWORD" + echo "Password must be 8-12 charcters, and contain at least one of each of the following: uppercase letter, lowercase letter, number, and symbol" + exit 1 +fi diff --git a/configuration/arm64/mysql/install_db.sh b/configuration/arm64/mysql/install_db.sh deleted file mode 100644 index 4c69cff93..000000000 --- a/configuration/arm64/mysql/install_db.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -x - -mysql -uroot -pivp --silent -e "SHOW STATUS WHERE Variable_name = 'Uptime' and Value > 0;" -mysql -uroot -pivp -e "CREATE DATABASE IF NOT EXISTS IVP; GRANT ALL PRIVILEGES ON IVP.* To 'IVP'@'127.0.0.1' IDENTIFIED BY 'ivp';" -mysql -v -uIVP -pivp IVP < /docker-entrypoint-initdb.d/localhost.sql diff --git a/configuration/arm64/mysql/script_credentials.sh b/configuration/arm64/mysql/script_credentials.sh deleted file mode 100644 index 147ab360f..000000000 --- a/configuration/arm64/mysql/script_credentials.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -x -mysql -uroot -pivp --silent -e "INSERT INTO IVP.user (IVP.user.username, IVP.user.password, IVP.user.accessLevel) VALUES('$username', '$password', 3)" diff --git a/configuration/arm64/post-initialization.yml b/configuration/arm64/post-initialization.yml deleted file mode 100644 index 1d7dca5f7..000000000 --- a/configuration/arm64/post-initialization.yml +++ /dev/null @@ -1,46 +0,0 @@ -version: '3.7' - -services: - db: - image: mariadb:10.4 - container_name: mysql - restart: always - environment: - MYSQL_DATABASE: IVP - MYSQL_USER: IVP - MYSQL_PASSWORD: ivp - MYSQL_ROOT_PASSWORD: ivp - username: ${username} - password: ${password} - network_mode: host - volumes: - - "mysql_db:/var/lib/mysql" - - ./mysql/install_db.sh:/docker-entrypoint-initdb.d/install_db.sh - - ./mysql/localhost.sql:/docker-entrypoint-initdb.d/localhost.sql - - ./mysql/script_credentials.sh:/docker-entrypoint-initdb.d/script_credentials.sh - - php: - image: php:7.2.2-apache - container_name: php - volumes: - - ../../web/:/var/www/html/ - network_mode: host - restart: always - depends_on: - - db - stdin_open: true - tty: true - - v2xhub: - image: usdotfhwaops/v2xhubarm:latest - container_name: v2xhub - network_mode: host - restart: always - depends_on: - - php - volumes: - - ./logs:/var/log/tmx - - ./MAP:/var/www/plugins/MAP - -volumes: - mysql_db: diff --git a/container/database.sh b/container/database.sh old mode 100644 new mode 100755 index 3ad021f91..8253f2110 --- a/container/database.sh +++ b/container/database.sh @@ -1,7 +1,4 @@ #!/bin/sh -x - -mysql -uroot -pivp -h127.0.0.1 -e "INSERT INTO IVP.user (IVP.user.username, IVP.user.password, IVP.user.accessLevel) VALUES('v2xadmin', 'V2xHub#321', 3)" - set +e id plugin >/dev/null 2>&1 if [ $? -ne 0 ]; then diff --git a/container/library.sh b/container/library.sh old mode 100644 new mode 100755 diff --git a/container/service.sh b/container/service.sh old mode 100644 new mode 100755 index f29970b79..808754dad --- a/container/service.sh +++ b/container/service.sh @@ -2,5 +2,25 @@ chmod +x /home/V2X-Hub/container/wait-for-it.sh /home/V2X-Hub/container/wait-for-it.sh 127.0.0.1:3306 chmod 777 /var/log/tmx +echo ${MYSQL_ROOT_PASSWORD} +tmxctl --plugin-install CommandPlugin.zip +tmxctl --plugin-install CswPlugin.zip +tmxctl --plugin-install DmsPlugin.zip +tmxctl --plugin-install DsrcImmediateForwardPlugin.zip +tmxctl --plugin-install LocationPlugin.zip +tmxctl --plugin-install MapPlugin.zip +tmxctl --plugin-install MessageReceiverPlugin.zip +tmxctl --plugin-install ODEPlugin.zip +tmxctl --plugin-install RtcmPlugin.zip +tmxctl --plugin-install SpatPlugin.zip +tmxctl --plugin-install PreemptionPlugin.zip +tmxctl --plugin-install SPaTLoggerPlugin.zip +tmxctl --plugin-install MessageLoggerPlugin.zip +tmxctl --plugin-install PedestrianPlugin.zip +tmxctl --plugin-install TimPlugin.zip +tmxctl --plugin-install CARMACloudPlugin.zip +tmxctl --plugin-install MobilityOperationPlugin.zip +tmxctl --plugin-install ODELoggerPlugin.zip + tmxctl --plugin CommandPlugin --enable /usr/local/bin/tmxcore diff --git a/container/wait-for-it.sh b/container/wait-for-it.sh old mode 100644 new mode 100755 diff --git a/data/DatabaseSetup/install_db.sh b/data/DatabaseSetup/install_db.sh deleted file mode 100755 index efe9e0d10..000000000 --- a/data/DatabaseSetup/install_db.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -x - - -DBROOTUSER="root" - -DBROOTPASS=$MYSQL_ROOT_PASSWORD - -# Test out the connection to the server -mysql -u$DBROOTUSER -p$DBROOTPASS --silent -e "SHOW STATUS WHERE Variable_name = 'Uptime' and Value > 0;" - -# Install the database -DBUSER="IVP" -DBPASS=$MYSQL_ROOT_PASSWORD -mysql -u$DBROOTUSER -p$DBROOTPASS -e "CREATE DATABASE IF NOT EXISTS $DBUSER; GRANT ALL PRIVILEGES ON $DBUSER.* To '$DBUSER'@'localhost' IDENTIFIED BY '$DBPASS';" -if [ -f ./localhost.sql ]; then - mysql -v -u$DBUSER -p$DBPASS < ./localhost.sql -fi - -mysql -u$DBROOTUSER -p$DBROOTPASS -e "INSERT INTO IVP.user (IVP.user.username, IVP.user.password, IVP.user.accessLevel) VALUES('_battelle', 'B@ttelle', 3)" - -mysql -u$DBROOTUSER -p$DBROOTPASS -e "INSERT INTO IVP.user (IVP.user.username, IVP.user.password, IVP.user.accessLevel) VALUES('v2iadmin', 'V2iHub#321', 3)" - -set +e -id plugin >/dev/null 2>&1 -if [ $? -ne 0 ]; then - adduser --system --disabled-login --disabled-password --gecos --no-create-home plugin -fi - -usermod -a -G dialout plugin - -mkdir -p /var/log/tmx -chmod 755 /var/log/tmx - -mkdir -p /var/www/plugins -chown plugin:adm /var/www /var/www/plugins -chmod 755 /var/www/plugins diff --git a/docker/Dockerfile-depl b/docker/Dockerfile-depl new file mode 100644 index 000000000..caeae84a1 --- /dev/null +++ b/docker/Dockerfile-depl @@ -0,0 +1,147 @@ +FROM ubuntu:bionic-20190807 AS install_dependencies + +RUN apt-get update && apt-get install -y cmake git build-essential libgtest-dev libssl-dev qtbase5-dev \ + zip libmysqlcppconn-dev libboost1.65-all-dev libmysqlclient-dev uuid-dev libxerces-c-dev qtbase5-dev \ + libcurl4-openssl-dev libgps-dev libsnmp-dev librdkafka-dev libev-dev libuv-dev libcpprest-dev +# Build and install GTest +WORKDIR cd /usr/src/googletest/googletest +RUN mkdir ~/build +WORKDIR /usr/src/googletest/googletest/build +RUN cmake .. +RUN make +RUN cp libgtest* /usr/lib/ +WORKDIR cd /usr/src/googletest/googletest +RUN rm -rf build +RUN mkdir /usr/local/lib/googletest +RUN ln -s /usr/lib/libgtest.a /usr/local/lib/googletest/libgtest.a +RUN ln -s /usr/lib/libgtest_main.a /usr/local/lib/googletest/libgtest_main.a +RUN ldconfig + +# Build and install tmx +RUN mkdir ~/V2X-Hub +COPY ./src /home/V2X-Hub/src/ +WORKDIR /home/V2X-Hub/src/tmx/ +RUN cmake . +RUN make +RUN make install + +# Scripts +COPY ./ext /home/V2X-Hub/ext +COPY ./container /home/V2X-Hub/container +WORKDIR /home/V2X-Hub/container/ +RUN /home/V2X-Hub/container/database.sh +RUN /home/V2X-Hub/container/library.sh +RUN ldconfig + +WORKDIR /home/V2X-Hub/ +RUN mkdir -p /home/V2X-Hub/ext +WORKDIR /home/V2X-Hub/ext/ +RUN git clone https://github.com/usdot-fhwa-OPS/libwebsockets.git +WORKDIR /home/V2X-Hub/ext/libwebsockets/ +RUN cmake -DLWS_WITH_SHARED=OFF . +RUN make +RUN make install + +WORKDIR /home/V2X-Hub/ext +RUN git clone https://github.com/usdot-fhwa-OPS/qhttpengine.git +WORKDIR /home/V2X-Hub/ext/qhttpengine +RUN cmake . +RUN make +RUN make install + +WORKDIR /home/V2X-Hub/ext/ +RUN git clone https://github.com/HowardHinnant/date.git +WORKDIR /home/V2X-Hub/ext/date +RUN cmake . +RUN make +RUN make install +RUN ldconfig + + + +COPY ext/ /home/V2X-Hub/ext +WORKDIR /home/V2X-Hub/ext/server +RUN cmake . +RUN make +RUN make install + +WORKDIR /home/V2X-Hub/ext/ccserver +RUN cmake . +RUN make +RUN make install +WORKDIR /home/V2X-Hub/ext/ccserver +RUN rm -rf /home/V2X-Hub/ext/ + + + +WORKDIR /home/V2X-Hub/src/v2i-hub/ +RUN cmake . -DqserverPedestrian_DIR=/usr/local/share/qserverPedestrian/cmake -Dv2xhubWebAPI_DIR=/usr/local/share/v2xhubWebAPI/cmake/ +RUN make + +RUN ln -s ../bin CommandPlugin/bin +RUN zip CommandPlugin.zip CommandPlugin/bin/CommandPlugin CommandPlugin/manifest.json +RUN ln -s ../bin CswPlugin/bin +RUN zip CswPlugin.zip CswPlugin/bin/CswPlugin CswPlugin/manifest.json +RUN ln -s ../bin DmsPlugin/bin +RUN zip DmsPlugin.zip DmsPlugin/bin/DmsPlugin DmsPlugin/manifest.json +RUN ln -s ../bin DsrcImmediateForwardPlugin/bin +RUN zip DsrcImmediateForwardPlugin.zip DsrcImmediateForwardPlugin/bin/DsrcImmediateForwardPlugin DsrcImmediateForwardPlugin/manifest.json +RUN ln -s ../bin LocationPlugin/bin +RUN zip LocationPlugin.zip LocationPlugin/bin/LocationPlugin LocationPlugin/manifest.json +RUN ln -s ../bin MapPlugin/bin +RUN zip MapPlugin.zip MapPlugin/bin/MapPlugin MapPlugin/manifest.json +RUN ln -s ../bin MessageReceiverPlugin/bin +RUN zip MessageReceiverPlugin.zip MessageReceiverPlugin/bin/MessageReceiverPlugin MessageReceiverPlugin/manifest.json +RUN ln -s ../bin ODEPlugin/bin +RUN zip ODEPlugin.zip ODEPlugin/bin/ODEPlugin ODEPlugin/manifest.json +RUN ln -s ../bin RtcmPlugin/bin +RUN zip RtcmPlugin.zip RtcmPlugin/bin/RtcmPlugin RtcmPlugin/manifest.json +RUN ln -s ../bin SpatPlugin/bin +RUN zip SpatPlugin.zip SpatPlugin/bin/SpatPlugin SpatPlugin/manifest.json +RUN ln -s ../bin PreemptionPlugin/bin +RUN zip PreemptionPlugin.zip PreemptionPlugin/bin/PreemptionPlugin PreemptionPlugin/manifest.json +RUN ln -s ../bin SPaTLoggerPlugin/bin +RUN zip SPaTLoggerPlugin.zip SPaTLoggerPlugin/bin/SPaTLoggerPlugin SPaTLoggerPlugin/manifest.json +RUN ln -s ../bin MessageLoggerPlugin/bin +RUN zip MessageLoggerPlugin.zip MessageLoggerPlugin/bin/MessageLoggerPlugin MessageLoggerPlugin/manifest.json +RUN ln -s ../bin PedestrianPlugin/bin +RUN zip PedestrianPlugin.zip PedestrianPlugin/bin/PedestrianPlugin PedestrianPlugin/manifest.json +RUN ln -s ../bin TimPlugin/bin +RUN zip TimPlugin.zip TimPlugin/bin/TimPlugin TimPlugin/manifest.json +RUN ln -s ../bin CARMACloudPlugin/bin +RUN zip CARMACloudPlugin.zip CARMACloudPlugin/bin/CARMACloudPlugin CARMACloudPlugin/manifest.json +RUN ln -s ../bin MobilityOperationPlugin/bin +RUN zip MobilityOperationPlugin.zip MobilityOperationPlugin/bin/MobilityOperationPlugin MobilityOperationPlugin/manifest.json +RUN ln -s ../bin ODELoggerPlugin/bin +RUN zip ODELoggerPlugin.zip ODELoggerPlugin/bin/ODELoggerPlugin ODELoggerPlugin/manifest.json + +WORKDIR /home/V2X-Hub/src/tmx/TmxCore/ +RUN cp tmxcore.service /lib/systemd/system/ && cp tmxcore.service /usr/sbin/ +WORKDIR /home/V2X-Hub/container/ +RUN chmod +x /home/V2X-Hub/container/service.sh && chmod +x /home/V2X-Hub/container/wait-for-it.sh +WORKDIR /var/www/ +RUN mkdir ~/plugins +WORKDIR /home/V2X-Hub/src/v2i-hub/ +WORKDIR /var/www/plugins/ +RUN mkdir /var/www/plugins/MAP +RUN mkdir /var/www/plugins/.ssl +RUN chown plugin .ssl +RUN chgrp www-data .ssl +WORKDIR /var/www/plugins/.ssl/ +RUN openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout tmxcmd.key -out tmxcmd.crt -subj "/CN= <127.0.0.1> " -days 3650 +RUN chown plugin * +RUN chgrp www-data * +WORKDIR /home/V2X-Hub/src/v2i-hub/ + +# Set metadata labels +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.name="V2X-Hub-Deployment" +LABEL org.label-schema.description="Image V2X-Hub Deployment" +LABEL org.label-schema.vendor="Leidos" +LABEL org.label-schema.version="${VERSION}" +LABEL org.label-schema.url="https://highways.dot.gov/research/research-programs/operations" +LABEL org.label-schema.vcs-url="https://github.com/usdot-fhwa-ops/V2X-HUB" +LABEL org.label-schema.vcs-ref=${VCS_REF} +LABEL org.label-schema.build-date=${BUILD_DATE} + +ENTRYPOINT ["/home/V2X-Hub/container/service.sh"] diff --git a/docker/php.yml b/docker/php.yml new file mode 100644 index 000000000..7e4846469 --- /dev/null +++ b/docker/php.yml @@ -0,0 +1,2 @@ +FROM php:7.2.2-apache +COPY web/ /var/www/html/ diff --git a/docs/Release_notes.md b/docs/Release_notes.md index 8de9e31d4..b152d4861 100644 --- a/docs/Release_notes.md +++ b/docs/Release_notes.md @@ -1,6 +1,20 @@ V2X-Hub Release Notes ---------------------------- +Version 6.1, released Oct 15th, 2021 +-------------------------------------------------------- + +**Summary:** +V2X Hub release version 6.1 is a hotfix release for 6.0. + +Fixes in this release: +- Issue 233: Fixed SPaT message to report green status as "permissive" vs "protected" correctly. +- Issue 124: Fixed issue with interpreting when the signal controller is in flash state. +- Issue 245: Added configurable parameter for Carma cloud plugin to use for the “oldest” parameter in the TCR request to get controls created within the time period specified by this field in days. +- Issue 247: Added TCM PSID to messages forwarded to RSU for broadcast. +- Issue 186: Fixed sonar-scanner settings with code coverage to generate the coverage metrics in sonar cloud. +- Issue 201: Update docker-compose to manage sensitive data like mysql username and password with Docker secrets. + Version 6.0, released July 30th, 2021 -------------------------------------------------------- diff --git a/src/coverage.sh b/src/coverage.sh index 59f64528d..b3cd2ebec 100755 --- a/src/coverage.sh +++ b/src/coverage.sh @@ -27,10 +27,9 @@ do echo "$TESTS built" cd $d $TESTS - gcovr -k . mkdir coverage - PLUGIN=`echo $d | cut -d "/" -f 2` - mv $(ls | grep [a-zA-Z0-9#-]*$PLUGIN | grep -v test# | grep gcov) coverage + gcovr -k -r . + mv *.gcov coverage cd ../.. else echo "no tests built" @@ -47,13 +46,12 @@ do echo "$TESTS built" cd $d $TESTS - gcovr -k . mkdir coverage - TMX=`echo $d | cut -d "/" -f 2` - mv $(ls | grep [a-zA-Z0-9#-]*$TMX | grep -v test# | grep gcov) coverage + gcovr -k -r . + mv *.gcov coverage cd ../.. else echo "no tests built" fi fi -done \ No newline at end of file +done diff --git a/src/tmx/TmxApi/tmx/j2735_messages/J2735MessageFactory.hpp b/src/tmx/TmxApi/tmx/j2735_messages/J2735MessageFactory.hpp index 38227ec52..cc75299a6 100644 --- a/src/tmx/TmxApi/tmx/j2735_messages/J2735MessageFactory.hpp +++ b/src/tmx/TmxApi/tmx/j2735_messages/J2735MessageFactory.hpp @@ -385,7 +385,6 @@ class J2735MessageFactory if(msgidindex = TmxJ2735ExtendedBytes(bytes)) { std::string byteStr(bytes.begin(),bytes.end()); - std::cout<<" Return = "<< msgidindex<< ", Extended bytes found, sanitized::"; } @@ -424,7 +423,6 @@ class J2735MessageFactory #endif int id = Codec.decode_contentId(bytes); - std::cout<<" Codec ID = "<< id < lock(_cfgLock); GetConfigValue("WebServiceIP",webip); GetConfigValue("WebServicePort",webport); + GetConfigValue("fetchTime",fetchtime); AddMessageFilter < tsm4Message > (this, &CARMACloudPlugin::HandleCARMARequest); // Subscribe to all messages specified by the filters above. @@ -64,7 +65,7 @@ void CARMACloudPlugin::HandleCARMARequest(tsm4Message &msg, routeable_message &r strcpy(bounds_str,""); // get current time - std::time_t tm = std::time(0)/60-1*24*60; // T minus 24 hours in min + std::time_t tm = std::time(0)/60-fetchtime*24*60; // T minus 24 hours in min while(cnt lock(_cfgLock); GetConfigValue("WebServiceIP",webip); GetConfigValue("WebServicePort",webport); + GetConfigValue("fetchTime",fetchtime); } diff --git a/src/v2i-hub/CARMACloudPlugin/src/CARMACloudPlugin.h b/src/v2i-hub/CARMACloudPlugin/src/CARMACloudPlugin.h index 3c2061463..629669a5c 100644 --- a/src/v2i-hub/CARMACloudPlugin/src/CARMACloudPlugin.h +++ b/src/v2i-hub/CARMACloudPlugin/src/CARMACloudPlugin.h @@ -92,6 +92,7 @@ class CARMACloudPlugin: public PluginClient { int Main(); uint16_t webport; std::string webip; + uint16_t fetchtime; protected: void UpdateConfigSettings(); diff --git a/src/v2i-hub/SpatPlugin/src/NTCIP1202.cpp b/src/v2i-hub/SpatPlugin/src/NTCIP1202.cpp index 3151874d0..21c90244d 100644 --- a/src/v2i-hub/SpatPlugin/src/NTCIP1202.cpp +++ b/src/v2i-hub/SpatPlugin/src/NTCIP1202.cpp @@ -332,11 +332,15 @@ void Ntcip1202::populateVehicleSignalGroup(MovementState *movement, int phase) MovementEvent *stateTimeSpeed = (MovementEvent *) calloc(1, sizeof(MovementEvent)); bool isFlashing = getPhaseFlashingStatus(phase); - bool forceFlashing = isFlashingStatus() && !isPhaseFlashing(); + bool forceFlashing = isFlashingStatus(); if(getPhaseRedStatus(phase)) { - if(forceFlashing || isFlashing) + PLOG(logDEBUG3) << "Phase " << phase << + " Red " << getPhaseRedStatus(phase) << + ", isFlashing " << isFlashing << + ", forceFlashing " << forceFlashing ; + if(isFlashing) stateTimeSpeed->eventState = MovementPhaseState_stop_Then_Proceed; else stateTimeSpeed->eventState = MovementPhaseState_stop_And_Remain; @@ -353,8 +357,8 @@ void Ntcip1202::populateVehicleSignalGroup(MovementState *movement, int phase) } else if(getPhaseGreensStatus(phase)) { - //TODO Add protected and permissive - stateTimeSpeed->eventState = MovementPhaseState_permissive_Movement_Allowed; + //TODO Add logic for permissive which I am not sure we can figure out based on what's in the Spat status being provide by the controller. + stateTimeSpeed->eventState = MovementPhaseState_protected_Movement_Allowed; } else {