Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
test: updated files to make it in sync with common template
Browse files Browse the repository at this point in the history
  • Loading branch information
zahrasidhpuri-crest committed Jan 19, 2021
1 parent d604310 commit d727ca4
Show file tree
Hide file tree
Showing 11 changed files with 400 additions and 22 deletions.
141 changes: 134 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ jobs:
[ "${VERSION}" == "<< pipeline.git.tag >>" ] && export RELEASE=<< pipeline.git.tag >> || export RELEASE=${VERSION}-post
cat test-results/$CIRCLE_PROJECT_REPONAME-appinspect-mode-<<parameters.label>>.xml | sed 's/<skipped\/>//g' | sed 's/skipped[^ ]*/skipped=\"0\"/g' >/tmp/$CIRCLE_PROJECT_REPONAME-appinspect-mode-<<parameters.label>>.xml
zip -j /tmp/$CIRCLE_PROJECT_REPONAME-appinspect-mode-<<parameters.label>>.zip /tmp/$CIRCLE_PROJECT_REPONAME-appinspect-mode-<<parameters.label>>.xml
LUUID=$(curl -X POST "$RP_ENDPOINT/api/v1/addonfactory/launch/import" -H "accept: */*" -H "Content-Type: multipart/form-data" -H "Authorization: bearer $RP_UUID" -F "file=@/tmp/$CIRCLE_PROJECT_REPONAME-appinspect-mode-<<parameters.label>>.zip;type=application/zip" 2>/dev/null | sed 's/\(.*id = \)\([^ ]*\)\(.*\)/\2/')
echo LUUID=$LUUID
LID=$(curl -X GET "$RP_ENDPOINT/api/v1/addonfactory/launch/uuid/$LUUID" -H "accept: */*" -H "Authorization: bearer $RP_UUID" 2>/dev/null| jq .id)
Expand Down Expand Up @@ -209,6 +210,10 @@ jobs:
description: Test Set
type: string
default: knowledge
sc4s_version:
description: sc4s version
type: string
default: latest
docker:
- image: circleci/python:3.7
resource_class: xlarge
Expand All @@ -226,10 +231,8 @@ jobs:
pip install git+https://github.com/pixelb/crudini
mkdir test-results
cp -rf /tmp/workspace/* .
mkdir -p deps/apps/splunk-add-on-for-modinput-test
cd deps/apps/splunk-add-on-for-modinput-test
mkdir output
cd output
mkdir -p deps/apps/splunk-add-on-for-modinput-test/output
cd deps/apps/splunk-add-on-for-modinput-test/output
curl -s https://api.github.com/repos/splunk/splunk-add-on-for-modinput-test/releases/latest | grep "Splunk_TA.*tar.gz" | grep -v search_head | grep -v indexer | grep -v forwarder | cut -d : -f 2,3 | tr -d \" | wget -qi - || true
ls
tar -xzf *.tar.gz
Expand All @@ -244,32 +247,40 @@ jobs:
TEST_TYPE=$(echo "<<parameters.test_set>>" | awk -F- '{print $1}' )
BROWSER=$(echo "<<parameters.test_set>>" | awk -F- '{print $2}' )
export IMAGE_TAG="3.7-browsers"
[ ! -d "tests/$TEST_TYPE" ] && exit 0
[ "$BROWSER" = "safari" ] && [ "$UI_TEST_HEADLESS" = "true" ] && exit 0
export SPLUNK_VERSION=$(crudini --get deps/build/addonfactory_test_matrix_splunk/splunk_matrix.conf "<<parameters.splunk_version>>" VERSION)
export SC4S_VERSION=$(crudini --get deps/build/addonfactory_test_matrix_splunk/SC4S_matrix.conf "<<parameters.sc4s_version>>" VERSION)
export SPLUNK_APP_ID=$(crudini --get package/default/app.conf id name)
export SPLUNK_APP_PACKAGE=output/$(ls output/)
export TEST_SET=tests/$TEST_TYPE
export TEST_TYPE=$TEST_TYPE
export TEST_BROWSER=$BROWSER
# JOB_NAME: For Saucelabs integration. Used as a build-name.
export JOB_NAME="CircleCI::$CIRCLE_PROJECT_REPONAME[$CIRCLE_BRANCH][$TEST_BROWSER][$PYTHON_VERSION] #$CIRCLE_BUILD_NUM"
export JOB_NAME="CircleCI::$CIRCLE_PROJECT_REPONAME[$CIRCLE_BRANCH][$TEST_BROWSER] #$CIRCLE_BUILD_NUM"
export SAUCE_IDENTIFIER=$SAUCE_IDENTIFIER-$(cat /proc/sys/kernel/random/uuid)
#export env credentials
if [ -f ".circleci/testcredentials.sh" ]; then
bash ./.circleci/testcredentials.sh
fi
#Report portal integration
export RP_LAUNCH_ATTRIBUTES="'job:${CIRCLE_JOB}' 'deployment:byoe' 'splunkmajor:<< parameters.splunk_version >>' 'splunk:${SPLUNK_VERSION}' 'branch:<< pipeline.git.branch >>' 'commit:${CIRCLE_SHA1}' 'release:${RELEASE}' 'version:$(./semtag getcurrent)' 'test_set:<<parameters.test_set>>' 'repo:${CIRCLE_PROJECT_REPONAME}'"
export RP_PROJECT=addonfactory
export RP_LAUNCH="$CIRCLE_PROJECT_REPONAME-$(echo <<parameters.test_set>> | sed 's/\(.*\)\(-.*\)/\1/')"
export RP_LAUNCH_DESC="ci run"
# Build
docker-compose -f docker-compose-ci.yml build
# Saucelab connection
[ -z $BROWSER ] || [ "$UI_TEST_HEADLESS" = "true" ] || docker-compose -f docker-compose-ci.yml up -d sauceconnect
[ -z $BROWSER ] || [ "$UI_TEST_HEADLESS" = "true" ] || docker-compose -f docker-compose-ci.yml up -d sauceconnect
# Start Splunk
docker-compose -f docker-compose-ci.yml up -d splunk
docker-compose -f docker-compose-ci.yml up -d splunk
until docker-compose -f docker-compose-ci.yml logs splunk | grep "Ansible playbook complete" ; do sleep 1; done
# Run a Splunk Diag
mkdir /tmp/diag
Expand All @@ -280,12 +291,15 @@ jobs:
docker-compose -f docker-compose-ci.yml exec splunk sudo /opt/splunk/bin/splunk cmd btool check
docker-compose -f docker-compose-ci.yml up -d splunk
until docker-compose -f docker-compose-ci.yml logs splunk | grep "Ansible playbook complete" ; do sleep 1; done
# Normal Inspecting
[ -z $BROWSER ] || [ "$UI_TEST_HEADLESS" = "true" ] || docker-compose -f docker-compose-ci.yml logs sauceconnect
docker ps -a
# Run the tests
test_exit_code=0
docker-compose -f docker-compose-ci.yml up --abort-on-container-exit test || test_exit_code=$?
# Collect Results
docker container create --name dummy \
Expand All @@ -306,6 +320,87 @@ jobs:
- store_test_results:
path: test-results

splunk-app-backend-test:
parameters:
splunk_version:
description: Image version
type: string
default: latest
test_set:
description: Test Set
type: string
default: knowledge
docker:
- image: circleci/python:3.7
resource_class: xlarge
steps:
- checkout
- run: git submodule sync
- run: git submodule update --init
- setup_remote_docker:
docker_layer_caching: true
- attach_workspace:
at: /tmp/workspace
- run:
name: Setup for testing
command: |
pip install git+https://github.com/pixelb/crudini
mkdir test-results
cp -rf /tmp/workspace/* .
mkdir -p deps/apps/splunk-add-on-for-modinput-test/output
cd deps/apps/splunk-add-on-for-modinput-test/output
curl -s https://api.github.com/repos/splunk/splunk-add-on-for-modinput-test/releases/latest | grep "Splunk_TA.*tar.gz" | grep -v search_head | grep -v indexer | grep -v forwarder | cut -d : -f 2,3 | tr -d \" | wget -qi - || true
ls
tar -xzf *.tar.gz
ls
rm *.tar.gz
ls
- run:
name: Splunk Testing
no_output_timeout: 2h
command: |
# Start Splunk
TEST_TYPE=$(echo "<<parameters.test_set>>" | awk -F- '{print $1}' )
export IMAGE_TAG="3.7-browsers"
[ ! -d "tests/$TEST_TYPE" ] && exit 0
export SPLUNK_VERSION=$(crudini --get deps/build/addonfactory_test_matrix_splunk/splunk_matrix.conf "<<parameters.splunk_version>>" VERSION)
export SPLUNK_APP_ID=$(crudini --get package/default/app.conf id name)
export SPLUNK_APP_PACKAGE=output/$(ls output/)
export TEST_SET=tests/$TEST_TYPE
export TEST_TYPE=$TEST_TYPE
#export env credentials
if [ -f ".circleci/testcredentials.sh" ]; then
bash ./.circleci/testcredentials.sh
fi
#Report portal integration
export RP_LAUNCH_ATTRIBUTES="'job:${CIRCLE_JOB}' 'deployment:byoe' 'splunkmajor:<< parameters.splunk_version >>' 'splunk:${SPLUNK_VERSION}' 'branch:<< pipeline.git.branch >>' 'commit:${CIRCLE_SHA1}' 'release:${RELEASE}' 'version:$(./semtag getcurrent)' 'test_set:<<parameters.test_set>>' 'repo:${CIRCLE_PROJECT_REPONAME}'"
export RP_PROJECT=addonfactory
export RP_LAUNCH="$CIRCLE_PROJECT_REPONAME-$(echo <<parameters.test_set>> | sed 's/\(.*\)\(-.*\)/\1/')"
export RP_LAUNCH_DESC="ci run"
# Build
docker-compose -f docker-compose-ci.yml build
docker-compose -f docker-compose-ci.yml up -d splunk
until docker-compose -f docker-compose-ci.yml logs splunk | grep "Ansible playbook complete" ; do sleep 1; done
# Run the tests
test_exit_code=0
docker-compose -f docker-compose-ci.yml exec --user root splunk bash /home/circleci/work_backend/tests/backend_entrypoint.sh || test_exit_code=$?
# Collect Results
docker container create --name dummy \
-v project_backend_results:/home/circleci/work_backend \
registry.access.redhat.com/ubi7/ubi
docker cp dummy:/home/circleci/work_backend/test-results/test_py2.xml test-results/ || echo "ignoring..."
docker cp dummy:/home/circleci/work_backend/test-results/test_py3.xml test-results/ || echo "ignoring..."
docker-compose -f docker-compose-ci.yml down || echo "ignoring..."
exit "$test_exit_code"
- store_artifacts:
path: /tmp/diag
destination: test-diag
- store_artifacts:
path: test-results
destination: test-results
- store_test_results:
path: test-results

splunk-app-unit-test:
parameters:
test_set:
Expand All @@ -329,33 +424,49 @@ jobs:
pip install git+https://github.com/pixelb/crudini
mkdir test-results
cp -rf /tmp/workspace/* .
mkdir -p deps/apps/splunk-add-on-for-modinput-test/output
cd deps/apps/splunk-add-on-for-modinput-test/output
curl -s https://api.github.com/repos/splunk/splunk-add-on-for-modinput-test/releases/latest | grep "Splunk_TA.*tar.gz" | grep -v search_head | grep -v indexer | grep -v forwarder | cut -d : -f 2,3 | tr -d \" | wget -qi - || true
ls
tar -xzf *.tar.gz
ls
rm *.tar.gz
ls
- run:
name: Splunk Testing
no_output_timeout: 2h
command: |
PYTHON_VERSION=$(echo "<<parameters.test_set>>" | awk -F- '{print $1}' )
export IMAGE_TAG=$(echo "<<parameters.test_set>>" | awk -F- '{print $2}' )
[ ! -d "tests/unit" ] && exit 0
export SPLUNK_VERSION=latest
export SC4S_VERSION=latest
export SPLUNK_APP_ID=$(crudini --get package/default/app.conf id name)
export SPLUNK_APP_PACKAGE=output/$(ls output/)
export TEST_SET=tests/unit
export TEST_TYPE=unit
#export env credentials
if [ -f ".circleci/testcredentials.sh" ]; then
bash ./.circleci/testcredentials.sh
fi
#Report portal integration
export RP_LAUNCH_ATTRIBUTES="'job:${CIRCLE_JOB}' 'deployment:byoe' 'branch:<< pipeline.git.branch >>' 'commit:${CIRCLE_SHA1}' 'release:${RELEASE}' 'version:$(./semtag getcurrent)' 'test_set:<<parameters.test_set>>' 'repo:${CIRCLE_PROJECT_REPONAME}'"
export RP_PROJECT=addonfactory
export RP_LAUNCH="$CIRCLE_PROJECT_REPONAME-$(echo <<parameters.test_set>> | sed 's/\(.*\)\(-.*\)/\1/')"
export RP_LAUNCH_DESC="ci run"
# Build
docker-compose -f docker-compose-ci.yml build test
docker ps -a
# Run the tests
test_exit_code=0
docker-compose -f docker-compose-ci.yml up --abort-on-container-exit test || test_exit_code=$?
# Collect Results
docker container create --name dummy \
Expand All @@ -364,6 +475,7 @@ jobs:
docker cp dummy:/home/circleci/work/test-results/test.xml test-results/ || echo "ignoring..."
docker-compose -f docker-compose-ci.yml down || echo "ignoring..."
exit "$test_exit_code"
- store_artifacts:
path: test-results
destination: test-results
Expand Down Expand Up @@ -458,6 +570,7 @@ workflows:
matrix:
parameters:
splunk_version: ["7.2","7.3","8.0","8.1"]
sc4s_version: ["1"]
test_set: ["knowledge"]
filters:
branches:
Expand All @@ -471,6 +584,7 @@ workflows:
matrix:
parameters:
splunk_version: ["7.3","8.0","8.1"]
sc4s_version: ["1"]
test_set: ["ui-firefox", "ui-chrome", "ui-safari", "ui-edge"]
filters:
branches:
Expand All @@ -483,6 +597,7 @@ workflows:
matrix:
parameters:
splunk_version: ["7.3","8.0","8.1"]
sc4s_version: ["1"]
test_set: ["modinput_functional", "modinput_others"]
filters:
branches:
Expand All @@ -499,6 +614,18 @@ workflows:
filters:
branches:
only: /.*/
- splunk-app-backend-test:
context:
- gdi-reportportal
requires:
- package
matrix:
parameters:
splunk_version: ["7.3", "8.0", "8.1"]
test_set: ["backend"]
filters:
branches:
only: /.*/
- approval-release:
requires:
- package
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/cla.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "CLA Assistant"
on:
issue_comment:
types: [created]
pull_request_target:
types: [opened, closed, synchronize]

jobs:
CLAssistant:
runs-on: ubuntu-latest
steps:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
# Alpha Release
uses: cla-assistant/github-action@v2.0.2-alpha
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
PERSONAL_ACCESS_TOKEN: ${{ secrets.PAT_CLATOOL }}
with:
path-to-signatures: ".github/signatures/version1/cla.json"
path-to-document: "https://github.com/splunk/addonfactory-test-releaseci/blob/main/CLA.md" # e.g. a CLA or a DCO document
# branch should not be protected
branch: "master"
allowlist: dependabot
#below are the optional inputs - If the optional inputs are not given, then default values will be taken
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
#remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository)
#create-file-commit-message: 'For example: Creating file for storing CLA Signatures'
#signed-commit-messag e: 'For example: $contributorName has signed the CLA in #$pullRequestNo'
#custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign'
#custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA'
#custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.'
23 changes: 23 additions & 0 deletions Dockerfile-http_proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM sameersbn/squid:3.5.27-2
ARG PROXY_USERNAME=user1
ARG PROXY_PASSWORD=123456
RUN apt-get update
RUN apt-get install -y apache2-utils
RUN touch /etc/squid/passwords
RUN chmod 777 /etc/squid/passwords
RUN htpasswd -b /etc/squid/passwords $PROXY_USERNAME $PROXY_PASSWORD
RUN mv /etc/squid/squid.conf /etc/squid/squid.conf.original
RUN echo "auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords\n"\
"auth_param basic realm Squid proxy-caching web server\n"\
"auth_param basic credentialsttl 24 hours\n"\
"auth_param basic casesensitive off\n"\
"acl authenticated proxy_auth REQUIRED\n"\
"http_access allow authenticated\n"\
"http_access deny all\n"\
"dns_v4_first on\n"\
"forwarded_for delete\n"\
"via off\n"\
"http_port 3128\n" > /etc/squid/squid.conf
RUN cat /etc/squid/squid.conf
RUN service squid start
RUN service squid restart
7 changes: 5 additions & 2 deletions Dockerfile-splunk
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

ARG SPLUNK_VERSION=latest
FROM splunk/splunk:$SPLUNK_VERSION
ARG SPLUNK_VERSION=latest
Expand All @@ -7,7 +6,11 @@ ARG SPLUNK_APP_PACKAGE=$SPLUNK_APP_PACKAGE
RUN echo Splunk VERSION=$SPLUNK_VERSION

COPY deps/apps /opt/splunk/etc/apps/
COPY deps/apps/splunk-add-on-for-modinput-test/output /opt/splunk/etc/apps/
COPY deps/build/addonfactory_test_matrix_splunk/packages/all/common /opt/splunk/etc/apps/
COPY deps/build/addonfactory_test_matrix_splunk/packages/all/sh /opt/splunk/etc/apps/
COPY deps/build/addonfactory_test_matrix_splunk/packages/all/addon_factory_web /opt/splunk/etc/system/local
COPY $SPLUNK_APP_PACKAGE /opt/splunk/etc/apps/$SPLUNK_APP_ID
COPY $SPLUNK_APP_PACKAGE /opt/splunk/etc/apps/$SPLUNK_APP_ID

COPY .pytest.expect /home/circleci/work_backend/.pytest.expect
COPY tests /home/circleci/work_backend/tests
13 changes: 11 additions & 2 deletions Dockerfile-tests
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,29 @@
#
#You should have received a copy of the CC0 legalcode along with this
#work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
FROM circleci/python:3.7-browsers
ARG IMAGE_TAG=3.7-browsers
FROM circleci/python:$IMAGE_TAG
RUN mkdir -p /home/circleci/work/tests
RUN mkdir -p /home/circleci/work/test-results/functional

COPY tests/entrypoint.sh /
COPY .pytest.expect /home/circleci/work/.pytest.expect
COPY requirements_dev.txt /home/circleci/work/
COPY requirements_py2_dev.txt /home/circleci/work/
COPY requirements_addon_specific.txt /home/circleci/work/
COPY tests /home/circleci/work/tests
RUN cd /home/circleci/work/tests && ls

RUN cd ../..
COPY package /home/circleci/work/package
COPY output /home/circleci/work/output
RUN sudo chown -R circleci /home/circleci/

# Below three lines are added to create specific path required by splunktalib to create log file.
# Once fix is avalible(ADDON-32060) in splunktalib, remove these lines.
USER root
RUN mkdir -p /opt/splunk/var/log/splunk
RUN chmod -R 777 /opt/splunk/var/log/splunk

USER circleci
ENTRYPOINT /entrypoint.sh

Loading

0 comments on commit d727ca4

Please sign in to comment.