Skip to content

Commit

Permalink
Major refactor (#42)
Browse files Browse the repository at this point in the history
* Updated .gitignore

* Major refactor

* Fixed tests pipeline

* Updated pipelines

* Fix for appinspect pipeline

* Fix for appinspect pipeline

* Updated tests pipeline

* Updated tests pipeline

* Updates for troubleshooting

* Updates for troubleshooting 2

* Launching Splunk via docker compose in the pipeline

* Fixed env issue

* Removed troubleshooting

* Adding troubleshooting for tests

* Changed url to fix pipeline

* Restored service w/ fixes

* Fixes for pipeline

* Fix options in pipeline

* Restore version

* Fixes for pipeline

* Fixes for pipeline 2

* Fixes for pipeline 3

* Massive changes for pipeline

* Added specific container image

* Adding curl to container

* Reverting pipeline

* Troubleshooting

* Troubleshooting

* Fixed ip issue

* Fixing tests

* Fixing tests

* Fixing tests

* Removing package-lock for testing

* Testing gh action for cypress

* Testing gh action for cypress

* Testing gh action for cypress

* Edited SPL safeguards settings

* npm versions

* Fix for npm versions

* Fix for npm versions

* Testing with different browser

* Testing with no gpu

* Testing with chrome

* Testing with chrome

* Fixed bug with commands

* Updated cypress config

* Edited waiting times in tests

* Fixes for tests in pipeline

* Updated upload artifact version in pipeline

* Fixes for tests pipeline

* Fixes

* Tests fixes

* Fixed reports

* Fixed tests

* Testing with Electron

* Testing with Electron

* Testing with Electron

* Testing with Electron

* Fixes for junit report

* Executing tests w/ chrome

* Electron

* Added permissions to fix test-reporter

* Testing with Chrome

* Testing with Chrome

* Testing with Chrome. Latest node and actions

* Testing with Chrome. Latest cypress

* Testing with electron, added timeout

* Replaced splunklogout command in tests

* More fixes

* More fixes

* More fixes

* More fixes

* More fixes

* More fixes

* Tests fixes and more

* Tests fixes

* Tests fixes

* Run Electron w. video

* Run Electron w. video

* Videos done. Overall cleanup

* Fixed junit report

* Enhanced test graph_analysis

* Changed runner

* Reconfigured self-hosted runner

* Updated self-hosted runner

* Changed self-hosted runner

* ping splunk version

* removed mem management for chrome

* added debug

* Updated tests for graph_analysis page

* Fixed graph_analysis tests

* Fixed graph_analysis tests

* Fixed graph_analysis tests

* Installing older version of python-for-scientific app

* Added 3 retries at failures

* Fixed graph_analysis tests

* Changed to en-US

* Fixed tests

* Testing CodeBuild

* Troubleshooting action

* Troubleshooting action

* Troubleshooting action

* Troubleshooting action

* Troubleshooting action

* Troubleshooting action

* Troubleshooting action

* Troubleshooting action

* Troubleshooting action

* Troubleshooting action

* Troubleshooting action

* Troubleshooting action

* increased timeout in pipeline

* removed tests retries

* added py4scientific app for testing

* introduced splunk matrix in automated tests

* introduced splunk matrix in automated tests

* modified matrix in test pipeline

* extended matrix in test pipeline

* added strategy flag

* edited docker-compose to support different platform

* edited tests to run in splunk 9.2+

* edited package-lock for npm upgrade

* edited test to get splunk 9.2+ compatibility

* edited pipeline to test in 2 specific splunk versions

* fixes for testing in pipeline

* fixes for testing in pipeline

* fixes for testing in pipeline

* reverted tests for analysis tab

* skipping tests for analysis tab till finalised

* edited test pipeline

* updated README

---------

Co-authored-by: Erica Pescio <[email protected]>
  • Loading branch information
edro15 and edro15 authored Aug 22, 2024
1 parent 169a9c1 commit ef9609b
Show file tree
Hide file tree
Showing 72 changed files with 2,723 additions and 130 deletions.
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPLUNKBASE_USERNAME=<splunkbase-username>
SPLUNKBASE_PASSWORD=<splunkbase-password>
SPLUNK_PASSWORD=<splunk-password>
53 changes: 53 additions & 0 deletions .github/workflows/appinspect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: AppInspect

on:
push:
paths-ignore:
- '.github/workflows/manual-release.yml'
- '.github/workflows/tests.yml'

jobs:
appinspect-cli:
name: AppInspect CLI Validation
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install splunk-appinspect
- name: Run AppInspect
run: |
ls .
app_id=$(cat splunk-*/app.manifest | jq -r '.info.id.name')
cp ../README.md ${app_id}
splunk-appinspect inspect ${app_id} --output-file appinspect.json
exit `cat appinspect.json | jq '.summary.failure'`
working-directory: ./packages

appinspect-api:
name: AppInspect API Validation
needs:
- appinspect-cli
runs-on: ubuntu-latest
# Job not executed if branch is not master
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run AppInspect
uses: splunk/[email protected]
with:
username: ${{ secrets.SPLUNKBASE_USERNAME }}
password: ${{ secrets.SPLUNKBASE_PASSWORD }}
app_path: packages/
includedTags: cloud
123 changes: 0 additions & 123 deletions .github/workflows/ci.yml

This file was deleted.

156 changes: 156 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: tests

on:
pull_request:
branches:
- master
- develop

permissions:
contents: read
actions: read
checks: write

jobs:
slim-validate:
name: SLIM Validation
runs-on: ubuntu-latest
outputs:
app_name: ${{ steps.appinfo.outputs.app_name }}
app_id: ${{ steps.appinfo.outputs.app_id }}
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Checkout code
uses: actions/checkout@v4

- name: Fetch and set app info
id: appinfo
run: |
APP_ID=$(cat packages/splunk-*/app.manifest | jq -r '.info.id.name')
echo "app_id=${APP_ID}" >> $GITHUB_OUTPUT
APP_NAME=$(echo "$APP_ID" | tr _ - )
echo "app_name=${APP_NAME}" >> $GITHUB_OUTPUT
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install splunk-packaging-toolkit
- name: Slim Validate
run: |
cp README.md packages/${{ steps.appinfo.outputs.app_id }}
slim validate packages/${{ steps.appinfo.outputs.app_id }}
splunk-test:
name: Deploy and test the Viz
runs-on: ubuntu-latest
needs: slim-validate
strategy:
fail-fast: false
matrix:
version: [9.3.0, 9.2.2, 9.1.3, 8.2.0]
services:
splunk:
image: splunk/splunk:${{ matrix.version }}
env:
SPLUNK_START_ARGS: --answer-yes --no-prompt --accept-license
SPLUNK_PASSWORD: password
SPLUNK_APPS_URL: https://splunkbase.splunk.com/app/2890/release/5.4.1/download,https://splunkbase.splunk.com/app/2882/release/4.1.2/download
SPLUNKBASE_USERNAME: ${{ secrets.SPLUNKBASE_USERNAME }}
SPLUNKBASE_PASSWORD: ${{ secrets.SPLUNKBASE_PASSWORD }}
DEBUG: true
options: >-
--health-interval 30s
--health-timeout 5s
--health-retries 5
--name splunk
ports:
- 8000:8000
- 8089:8089
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.11.1

- name: Copy app to service container and validate
# NOTE using volume mapping to add the app to the container will NOT work since checkout hasn't happened yet
run: |
docker cp packages/${{ needs.slim-validate.outputs.app_id }} ${{ job.services.splunk.id }}:/opt/splunk/etc/apps/${{ needs.slim-validate.outputs.app_id }}
docker exec -i ${{ job.services.splunk.id }} ls -a /opt/splunk/etc/apps
docker exec -i ${{ job.services.splunk.id }} ls -a /opt/splunk/etc/apps/${{ needs.slim-validate.outputs.app_id }}
- name: Disable SPL safeguards for all commands
run: |
docker cp assets/cicd/config/web.conf ${{ job.services.splunk.id }}:/opt/splunk/etc/system/local/web.conf
echo "Validating 'web.conf' file creation"
docker exec -i ${{ job.services.splunk.id }} ls -a /opt/splunk/etc/system/local/
- name: Set container IP as env variable
run: |
echo "SPLUNK_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${{ job.services.splunk.id }})" >> $GITHUB_ENV
- name: Restart instance
run: |
curl -k -u admin:password https://$SPLUNK_IP:8089/services/server/control/restart -X POST
sleep 30
- name: Configure MLTK permissions
run: |
curl --retry-delay 5 --retry 5 -f -k -u admin:password https://$SPLUNK_IP:8089/services/apps/local/Splunk_ML_Toolkit/acl -d sharing=global -d owner=nobody -X POST
echo "Check MLTK permissions"
curl -k -u admin:password https://$SPLUNK_IP:8089/services/apps/local/Splunk_ML_Toolkit/acl?output_mode=json | jq -r '.entry | .[].acl.sharing'
- name: Tests execution prep
run: |
echo "Removing package-lock to avoid issues with splunk artifactory"
cd test
rm -rf package-lock.json
npm install
- name: Cypress run
uses: cypress-io/github-action@v6
# Set timeout to prevent hanging tasks
# NOTE: Careful! Tests timeouts can be impacted
timeout-minutes: 20
env:
DEBUG: '@cypress/github-action'
ELECTRON_EXTRA_LAUNCH_ARGS: --disable-gpu
with:
start: npm run test
wait-on: 'http://localhost:8000'
# No videos can be recorded w/ ff as per https://github.com/cypress-io/cypress/issues/18415
# browser: firefox
working-directory: test

# - name: Verify results availability
# run: |
# ls -la test/cypress/results

- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: splunk${{ matrix.version }}-results
path: |
test/cypress/videos
test/cypress/screenshots
# Add a job in the page to visualize test result reports
- name: JUnit Report
uses: dorny/test-reporter@v1
if: always()
with:
name: Cypress Tests
path: cypress/results/results-*.xml
reporter: java-junit
working-directory: test
fail-on-error: false
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
**/node_modules/
.vscode
.env
*.pyc
local.meta
fiddle/
**/local.meta
fiddle/
assets/apps/*.tgz
test/cypress/videos/
test/cypress/screenshots/
test/cypress/downloads/
test/cypress/results/
33 changes: 32 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,35 @@ This action can be **manually triggered** by clicking on _Actions / Manual Relea
* **Bump part** - Either major, minor or patch
* (Optional) **Changelog notes** - By default all commit messages beginning from the last release are included

> **NOTE** Action available to all users with `Write` role at least
> **NOTE** Action available to all users with `Write` role at least
## Development Environment
The recommended local development environment is based on Docker. After the setup, the local Splunk Web will be available on http://localhost:8000 with Splunk Machine Learning Toolkit (MLTK) and the Python for Scientific Computing for Linux installed.

### Prerequisites
* Docker

### Setup
Create a `.env` file in the root of the repository. Don't worry, it is part of `.gitignore`.

`cp .env.sample .env`

Enter your Splunkbase Username and Password there to install dependencies such as the Splunk MLTK via URL.

Manually download the Python for Scientific Computing for Linux from [Splunkbase](https://splunkbase.splunk.com/app/2882/release/4.2.0/download) and save the `.tgz` in `assets/apps`.
> Note that this should be done automatically but the app is too big for installation via REST by splunk-ansible.
To setup your development environment, run

`make setup`

This will:

* Install App dependencies
* Configure them in your local environment
* Run docker-compose up to start the local environment

## Tests
To execute tests locally, run

`make tests`
Loading

0 comments on commit ef9609b

Please sign in to comment.