From c04abcac21c7b472aff425f43e4f7c2321ad6a6b Mon Sep 17 00:00:00 2001 From: rohithrajneesh Date: Thu, 24 Aug 2023 16:06:37 +0100 Subject: [PATCH] Resolving GO based verify Job's issues in NORDIX Resolving NONRTRIC veriy job in NORDIX Change-Id: Ib17f9c8ede0daab867a8ce9cbb5f77990a1b865c Signed-off-by: rohithrajneesh --- jjb/oransc/global-templates-oran-go.yaml | 5 ++ .../global-templates-oran-nonrtric.yaml | 41 +++++++++++++++++ .../nonrtric-plt-sme-verify-jobs.yaml | 8 ++-- ...nrtric-rapp-orufhrecovery-verify-jobs.yaml | 5 +- ...ic-rapp-ransliceassurance-verify-jobs.yaml | 13 +++++- jjb/oransc/nonrtric/nonrtric-verify-jobs.yaml | 7 ++- jjb/oransc/verify-jobs-go.sh | 33 +++++++++---- jjb/oransc/verify-jobs-nonrtric.sh | 46 +++++++++++++++++++ jjb/oransc/verify-jobs.sh | 0 9 files changed, 138 insertions(+), 20 deletions(-) create mode 100644 jjb/oransc/global-templates-oran-nonrtric.yaml create mode 100644 jjb/oransc/verify-jobs-nonrtric.sh mode change 100755 => 100644 jjb/oransc/verify-jobs.sh diff --git a/jjb/oransc/global-templates-oran-go.yaml b/jjb/oransc/global-templates-oran-go.yaml index 5826cebb9..478993cfc 100644 --- a/jjb/oransc/global-templates-oran-go.yaml +++ b/jjb/oransc/global-templates-oran-go.yaml @@ -7,6 +7,7 @@ properties: - logrotate + parameters: - nordix-gerrit-parameters - string: @@ -16,6 +17,10 @@ - string: name: GERRIT_REFSPEC default: '' + - string: + name: DIRECTORY + default: "" + description: Current Project Directory scm: - git-scm-gerrit: diff --git a/jjb/oransc/global-templates-oran-nonrtric.yaml b/jjb/oransc/global-templates-oran-nonrtric.yaml new file mode 100644 index 000000000..d084dc9b3 --- /dev/null +++ b/jjb/oransc/global-templates-oran-nonrtric.yaml @@ -0,0 +1,41 @@ +- job-template: + name: 'oransc-{project-name}-verify' + node: oransc-ubuntu2004 + disabled: false + concurrent: true + + properties: + - logrotate + + + parameters: + - nordix-gerrit-parameters + - string: + name: PROJECT + default: 'oransc/{project}' + description: JJB configured PROJECT parameter to identify a Nordix Gerrit project + - string: + name: GERRIT_REFSPEC + default: '' + + scm: + - git-scm-gerrit: + ssh-credentials-id: nordixinfra-nordix-gerrit-ssh + branch: $GERRIT_BRANCH + refspec: $GERRIT_REFSPEC + wipe_workspace: true + clean_before: false + + triggers: + - nordix-gerrit-trigger-patchset-created: + project: 'oransc/{project}' + branch: '**' + files: '**' + + wrappers: + - build-timeout: + timeout: 45 + + builders: + - shell: + !include-raw-escape: ./verify-jobs-nonrtric.sh diff --git a/jjb/oransc/nonrtric-plt-sme/nonrtric-plt-sme-verify-jobs.yaml b/jjb/oransc/nonrtric-plt-sme/nonrtric-plt-sme-verify-jobs.yaml index 5aa0b5087..3c3902699 100644 --- a/jjb/oransc/nonrtric-plt-sme/nonrtric-plt-sme-verify-jobs.yaml +++ b/jjb/oransc/nonrtric-plt-sme/nonrtric-plt-sme-verify-jobs.yaml @@ -1,6 +1,6 @@ --- # ============LICENSE_START======================================================= -# Copyright (C) 2022 Nordix Foundation. +# Copyright (C) 2023 Nordix Foundation. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,10 +21,10 @@ # nonrtric/plt/sme project on Nordix Gerrit. - project: - name: nonrtric-plt-sme-verify + name: nonrtric-plt-sme-verify-go project: nonrtric/plt/sme project-name: nonrtric-plt-sme - jdk-version: java-11 + directory: capifcore jobs: - - 'oransc-{project-name}-verify-java' + - 'oransc-{project-name}-verify-go' diff --git a/jjb/oransc/nonrtric-rapp-orufhrecovery/nonrtric-rapp-orufhrecovery-verify-jobs.yaml b/jjb/oransc/nonrtric-rapp-orufhrecovery/nonrtric-rapp-orufhrecovery-verify-jobs.yaml index 9b8a9c738..5582fe016 100644 --- a/jjb/oransc/nonrtric-rapp-orufhrecovery/nonrtric-rapp-orufhrecovery-verify-jobs.yaml +++ b/jjb/oransc/nonrtric-rapp-orufhrecovery/nonrtric-rapp-orufhrecovery-verify-jobs.yaml @@ -1,6 +1,6 @@ --- # ============LICENSE_START======================================================= -# Copyright (C) 2022 Nordix Foundation. +# Copyright (C) 2023 Nordix Foundation. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,9 +21,10 @@ # nonrtric/rapp/orufhrecovery project on Nordix Gerrit. - project: - name: nonrtric-rapp-orufhrecovery-verify + name: nonrtric-rapp-orufhrecovery-verify-go project: nonrtric/rapp/orufhrecovery project-name: nonrtric-rapp-orufhrecovery + directory: goversion jobs: - 'oransc-{project-name}-verify-go' \ No newline at end of file diff --git a/jjb/oransc/nonrtric-rapp-ransliceassurance/nonrtric-rapp-ransliceassurance-verify-jobs.yaml b/jjb/oransc/nonrtric-rapp-ransliceassurance/nonrtric-rapp-ransliceassurance-verify-jobs.yaml index 0bc50b667..1d1408137 100644 --- a/jjb/oransc/nonrtric-rapp-ransliceassurance/nonrtric-rapp-ransliceassurance-verify-jobs.yaml +++ b/jjb/oransc/nonrtric-rapp-ransliceassurance/nonrtric-rapp-ransliceassurance-verify-jobs.yaml @@ -21,9 +21,18 @@ # nonrtric/rapp/ransliceassurance project on Nordix Gerrit. - project: - name: nonrtric-rapp-ransliceassurance-verify + name: nonrtric-rapp-ransliceassurance-ics-verify-go project: nonrtric/rapp/ransliceassurance - project-name: nonrtric-rapp-ransliceassurance + project-name: nonrtric-rapp-ransliceassurance-ics + directory: icsversion + + jobs: + - 'oransc-{project-name}-verify-go' +- project: + name: nonrtric-rapp-ransliceassurance-smo-verify-go + project: nonrtric/rapp/ransliceassurance + project-name: nonrtric-rapp-ransliceassurance-smo + directory: smoversion jobs: - 'oransc-{project-name}-verify-go' \ No newline at end of file diff --git a/jjb/oransc/nonrtric/nonrtric-verify-jobs.yaml b/jjb/oransc/nonrtric/nonrtric-verify-jobs.yaml index 1541696ea..cd0df2349 100644 --- a/jjb/oransc/nonrtric/nonrtric-verify-jobs.yaml +++ b/jjb/oransc/nonrtric/nonrtric-verify-jobs.yaml @@ -1,6 +1,6 @@ --- # ============LICENSE_START==================================================== -# Copyright (C) 2019 Nordix Foundation. +# Copyright (C) 2023 Nordix Foundation. # ============================================================================= # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,10 +18,9 @@ # ============LICENSE_END====================================================== - project: - name: nonrtric-rebase-verify + name: nonrtric-verify project: nonrtric project-name: nonrtric - jdk-version: java-17 jobs: - - 'oransc-{project-name}-verify-java' + - 'oransc-{project-name}-verify' diff --git a/jjb/oransc/verify-jobs-go.sh b/jjb/oransc/verify-jobs-go.sh index 6d9473435..10f809cb5 100644 --- a/jjb/oransc/verify-jobs-go.sh +++ b/jjb/oransc/verify-jobs-go.sh @@ -1,19 +1,36 @@ -#!/bin/bash +#!/bin/bash -x set -euo pipefail -cd $WORKSPACE +DIRECTORY = $WORKSPACE"/"$DIRECTORY +cd $DIRECTORY -# read go version from go.mod file -version=$(grep '^go' go.mod | grep -Eo '[0-9]\.[0-9]+') +# Read desired Go version from go.mod file +desired_version=$(grep '^go' go.mod | grep -Eo '[0-9]\.[0-9]+') -echo "Download go $version" -curl -L "https://go.dev/dl/go$version.linux-amd64.tar.gz" | sudo tar -C /usr/local -zxf - +# Check installed Go version +installed_version=$(go version | awk '{print $3}' | sed 's/go//') -export PATH=$PATH:/usr/local/go/bin +if [ "$desired_version" != "$installed_version" ]; then + echo "Desired Go version: $desired_version" + echo "Installed Go version: $installed_version" + + # Remove existing Go installation + sudo rm -fr /usr/local/go + + echo "Download go $desired_version" + curl -L "https://go.dev/dl/go$desired_version.linux-amd64.tar.gz" | sudo tar -C /usr/local -zxf - + + export PATH=$PATH:/usr/local/go/bin +else + echo "Go version is up to date: $desired_version" +fi echo "Download project deps" go mod tidy +echo "Force build" +go build -a -v + echo "Run tests" -go test ./... +go test ./... -json diff --git a/jjb/oransc/verify-jobs-nonrtric.sh b/jjb/oransc/verify-jobs-nonrtric.sh new file mode 100644 index 000000000..d0ad54a6d --- /dev/null +++ b/jjb/oransc/verify-jobs-nonrtric.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +TEST_DIRECTORY="test/auto-test" +TEST_SCRIPT="./Suite-Verify-jobs.sh" +DOCKER_COMPOSE_VERSION="v2.21.0" + +# Check if jq is installed, and install it if not +if ! command -v jq &> /dev/null; then + echo "Installing jq..." + sudo apt-get update + sudo apt-get install -y jq +fi + +# Function to install Docker Compose version 2 +install_docker_compose() { + echo "Installing Docker Compose version 2..." + sudo curl -L "https://github.com/docker/compose/releases/download/"$DOCKER_COMPOSE_VERSION"/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + sudo ln -s /usr/local/bin/docker-compose /usr/libexec/docker/cli-plugins/docker-compose +} + +# Function to remove Docker Compose +remove_docker_compose() { + echo "Removing Docker Compose..." + sudo rm /usr/local/bin/docker-compose +} + +# Check if docker-compose is installed, and install it if not +if ! command -v docker-compose &> /dev/null; then + install_docker_compose +fi + +cd "$TEST_DIRECTORY" +sudo chmod 775 "$TEST_SCRIPT" +"$TEST_SCRIPT" remote-remove docker release --env-file ../common/test_env-oran-h-release.sh + +# Remove docker-compose after tests are done +if command -v docker-compose &> /dev/null; then + remove_docker_compose +fi + +# Remove jq after tests are done +if command -v jq &> /dev/null; then + echo "Removing jq..." + sudo apt-get remove -y jq +fi diff --git a/jjb/oransc/verify-jobs.sh b/jjb/oransc/verify-jobs.sh old mode 100755 new mode 100644 -- 2.25.1