Skip to content

Commit

Permalink
Remove unused code and minor refactoring to regular tests
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmesamster committed Sep 9, 2024
1 parent ba94a92 commit f107582
Show file tree
Hide file tree
Showing 21 changed files with 2,619 additions and 4,064 deletions.
126 changes: 50 additions & 76 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,65 +11,63 @@ on:
workflows: ["BuildAndReleaseMaster"]
types:
- completed

jobs:
invoke_jasmine_tests:
name: Invoke Jasmine performance tests
runs-on: self-hosted-runner-ubuntu
steps:
- name: 'Cleanup build folder'
- name: Cleanup build folder
run: |
ls -la ./
rm -rf ./* || true
rm -rf ./.??* || true
rm -rf ./* ./.??* || true
ls -la ./
- name: Checkout
uses: actions/checkout@v3
- name: Install pre-requisite dependencies

- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y gconf-service libgbm-dev libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libnss3 lsb-release xdg-utils wget ca-certificates
sudo apt-get install -y libudev-dev cargo npm imagemagick libmagickwand-dev cmake jq
- name: install node
sudo apt-get update
sudo apt-get install -y gconf-service libgbm-dev libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \
libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 \
libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 \
libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libnss3 lsb-release xdg-utils wget \
libudev-dev cargo npm imagemagick libmagickwand-dev cmake jq
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22.4.0
- name: Install ruby and other related tools

- name: Install Ruby and related tools
run: |
whoami
npm install -g corepack
corepack enable
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
apt-get update
sudo apt-get install -y yarn
yarn --version
apt update
apt-get install -y software-properties-common
sudo apt-get update && sudo apt-get install -y yarn software-properties-common
apt-add-repository -y ppa:rael-gc/rvm
apt-get update
apt-get install -y rvm
sudo apt-get update && sudo apt-get install -y rvm
echo 'source "/etc/profile.d/rvm.sh"' >> ~/.bashrc
source /etc/profile.d/rvm.sh
which rvm
rvm install ruby-3.1.2
ruby --version
sudo chown -R $(whoami) /usr/local
rvm use 3.1.2 --default
rvm --version
rvm info
which rvm
ruby --version
- name: cargo install nj-cli
- name: Install cargo tools
run: |
cargo install nj-cli --locked
cargo install wasm-pack --locked
cargo install nj-cli wasm-pack --locked
- name: Prepare environment
run: |
npm i -g tslib
npm install -g tslib
export PATH="/usr/share/rvm:$PATH"
which ruby
ruby --version
pwd
gem install dotenv json octokit tmpdir fileutils
- name: Get PR details
if: github.event_name == 'workflow_dispatch'
uses: actions/github-script@v7
Expand All @@ -83,43 +81,26 @@ jobs:
repo: 'chipmunk',
pull_number: ${{ github.event.inputs.pr_id }}
});
const PR_OWNER = pr.data.user.login;
const PR_REPO = pr.data.base.repo.name;
console.log(`owner is ${PR_OWNER}`);
console.log(`repo is ${PR_REPO}`);
// Setting environment variables
fs.appendFileSync(process.env.GITHUB_ENV, `PR_OWNER=${PR_OWNER}\n`);
fs.appendFileSync(process.env.GITHUB_ENV, `PR_REPO=${PR_REPO}\n`);
- name: Run Jasmine performance tests for the latest release
if: github.event_name != 'workflow_dispatch'
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
export PATH="/root/.cargo/bin:$PATH"
. "/root/.cargo/env"
source ~/.bashrc
ruby scripts/tools/run_benchmarks.rb 1
env:
REPO_OWNER: 'esrlabs'
REPO_NAME: 'chipmunk'
- name: Run Jasmine performance tests for the latest pull request
if: github.event_name == 'workflow_dispatch'
fs.appendFileSync(process.env.GITHUB_ENV, `REPO_OWNER=${pr.data.user.login}\n`);
fs.appendFileSync(process.env.GITHUB_ENV, `REPO_NAME=${pr.data.base.repo.name}\n`);
- name: Run Jasmine performance tests
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
export PATH="/root/.cargo/bin:$PATH"
. "/root/.cargo/env"
source ~/.bashrc
echo "PR head repo: ${{ env.PR_OWNER }}"
echo "PR head owner: ${{ env.PR_REPO }}"
pwd
ls -la
ruby scripts/tools/run_benchmarks.rb PR~${{ github.event.inputs.pr_id }}
env:
REPO_NAME: ${{ env.PR_REPO }}
REPO_OWNER: ${{ env.PR_OWNER }}
if [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then
ruby scripts/tools/run_benchmarks.rb PR~${{ github.event.inputs.pr_id }}
else
export REPO_OWNER='esrlabs'
export REPO_NAME='chipmunk'
ruby scripts/tools/run_benchmarks.rb 1
fi
- name: List files in the results folder
run: |
echo "Event is: ${{ github.event_name }}"
ls -la /chipmunk/chipmunk_performance_results
push_data_to_chipmunk_docs:
name: Move benchmark data to chipmunk-docs repository
needs: invoke_jasmine_tests
Expand All @@ -130,28 +111,21 @@ jobs:
with:
repository: esrlabs/chipmunk-docs
path: './chipmunk-docs'
token: ${{secrets.DOCS_PUSH_TOKEN}}
- name: Push tag for release
working-directory: ./chipmunk-docs
if: github.event_name != 'workflow_dispatch'
run: |
ls -la
cp /chipmunk/chipmunk_performance_results/data.json ./jekyll/benchmarks/data/data.json
git config user.name "esrlabs"
git config user.email "esrlabs@gmail.com"
git remote set-url origin "https://esrlabs:${{secrets.DOCS_PUSH_TOKEN}}@github.com/esrlabs/chipmunk-docs"
git add ./jekyll/benchmarks/data/data.json
git commit -m "Updating data.json for latest tag"
git push origin master
- name: Push PR data to chipmunk-docs
token: ${{ secrets.DOCS_PUSH_TOKEN }}

- name: Push benchmark data
working-directory: ./chipmunk-docs
if: github.event_name == 'workflow_dispatch'
run: |
ls -la
cp /chipmunk/chipmunk_performance_results/Benchmark_PR_${{ github.event.inputs.pr_id }}.json ./jekyll/benchmarks/data/pull_request/Benchmark_PR_${{ github.event.inputs.pr_id }}.json
git config user.name "esrlabs"
git config user.email "esrlabs@gmail.com"
git remote set-url origin "https://esrlabs:${{secrets.DOCS_PUSH_TOKEN}}@github.com/esrlabs/chipmunk-docs"
git add ./jekyll/benchmarks/data/pull_request/Benchmark_PR_${{ github.event.inputs.pr_id }}.json
git commit -m "Adding PR benchmark results for chipmunk PR # ${{ github.event.inputs.pr_id }}"
if [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then
cp /chipmunk/chipmunk_performance_results/Benchmark_PR_${{ github.event.inputs.pr_id }}.json ./jekyll/benchmarks/data/pull_request/
git add ./jekyll/benchmarks/data/pull_request/Benchmark_PR_${{ github.event.inputs.pr_id }}.json
git commit -m "Adding PR benchmark results for chipmunk PR #${{ github.event.inputs.pr_id }}"
else
cp /chipmunk/chipmunk_performance_results/data.json ./jekyll/benchmarks/data/data.json
git add ./jekyll/benchmarks/data/data.json
git commit -m "Updating data.json for latest tag"
fi
git push origin master
95 changes: 44 additions & 51 deletions application/apps/rustcore/ts-bindings/spec/benchmarks.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,51 @@
/* NOTE: in this JSON can be used comments placed between stars */
{
"log_level": 1,
"tests": {
"benchmark": {
"performance": {
/* In false will prevent running performance tests */
"run": true,
"tests": {
"test1": {
"alias": "Observe - grab content (text)",
"file": "test_files/temp_readings3.txt",
"expectation_ms": 10000
},
"test2": {
"alias": "Observe - grab content (dlt)",
"file": "test_files/FzgProg_SP21.dlt",
"expectation_ms": 60000
},
"test3": {
"alias": "Observe - grab content (pcapng)",
"file": "test_files/someip.pcapng",
"expectation_ms": 1000
},
"test4": {
"alias": "Stream - startup measurement",
"file": "",
"expectation_ms": 1000
},
"test5": {
"alias": "Stream - shutdown measurement",
"file": "",
"expectation_ms": 10000
},
"test6": {
"alias": "Stream - Open 50 sessions",
"file": "",
"expectation_ms": 10000
},
"test7": {
"alias": "Indexes - Switch to breadcrumb mode",
"file": "test_files/indexing_access_huge.log",
"expectation_ms": 15000
},
"test8": {
"alias": "Assign & single search",
"file": "test_files/indexing_access_huge.log",
"expectation_ms": 1000
},
"test9": {
"alias": "Assign & multiple search",
"file": "test_files/indexing_access_huge.log",
"expectation_ms": 10000
}
}
"test1": {
"alias": "Observe - grab content (text)",
"file": "test_files/temp_readings3.txt",
"expectation_ms": 10000
},
"test2": {
"alias": "Observe - grab content (dlt)",
"file": "test_files/FzgProg_SP21.dlt",
"expectation_ms": 60000
},
"test3": {
"alias": "Observe - grab content (pcapng)",
"file": "test_files/someip.pcapng",
"expectation_ms": 1000
},
"test4": {
"alias": "Stream - startup measurement",
"file": "",
"expectation_ms": 1000
},
"test5": {
"alias": "Stream - shutdown measurement",
"file": "",
"expectation_ms": 10000
},
"test6": {
"alias": "Stream - Open 50 sessions",
"file": "",
"expectation_ms": 10000
},
"test7": {
"alias": "Indexes - Switch to breadcrumb mode",
"file": "test_files/indexing_access_huge.log",
"expectation_ms": 15000
},
"test8": {
"alias": "Assign & single search",
"file": "test_files/indexing_access_huge.log",
"expectation_ms": 1000
},
"test9": {
"alias": "Assign & multiple search",
"file": "test_files/indexing_access_huge.log",
"expectation_ms": 10000
}
}
}
Expand Down
61 changes: 0 additions & 61 deletions application/apps/rustcore/ts-bindings/spec/common.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
// tslint:disable

// We need to provide path to TypeScript types definitions
/// <reference path="../node_modules/@types/jasmine/index.d.ts" />
/// <reference path="../node_modules/@types/node/index.d.ts" />

import { Jobs, Tracker, Session } from '../src/index';
import { Logger, getLogger } from './logger';
import { error, numToLogLevel } from 'platform/log/utils';
import { state } from 'platform/log';
import { IRegularTests } from './config';
import { IPerformanceTest } from './config_benchmarks';

import * as tmp from 'tmp';
import * as fs from 'fs';
Expand All @@ -23,60 +17,6 @@ const MS_PER_SEC = 1000;
// Get rid of default Jasmine timeout
jasmine.DEFAULT_TIMEOUT_INTERVAL = 900000;

export type ScopeInjector<T> = (s: T) => T;

export function runner(
config: IRegularTests | IPerformanceTest,
id: string | number,
test: (
logger: Logger,
done: () => void,
add: ScopeInjector<Session | Tracker | Jobs>,
) => Promise<void>,
): Promise<void> {
const scope: Array<Session | Tracker | Jobs> = [];
const injector: ScopeInjector<Session | Tracker | Jobs> = (obj: Session | Tracker | Jobs) => {
scope.push(obj);
return obj;
};

let name: string;
let shouldExecute = true;

if ('list' in config) {
// Handling IRegularTests
name = config.list[id];
shouldExecute = config.execute_only.length === 0 || config.execute_only.includes(typeof id === 'number' ? id : parseInt(id, 10));
} else if ('alias' in config) {
// Handling IPerformanceTest
name = config.alias;
shouldExecute = !config.ignore;
} else {
// Log the type of config received
console.error('Invalid configuration passed to runner. Config:', config);
return Promise.reject(new Error('Invalid configuration passed to runner'));
}

const logger = getLogger(name);

if (!shouldExecute) {
console.log(`\nIgnored: ${name}`);
return Promise.resolve();
} else {
console.log(`\nStarted: ${name}`);
}

return new Promise((done) => {
try {
test(logger, done, injector).catch((err: Error) => {
finish(scope, done, err);
});
} catch (err) {
finish(scope, done, new Error(error(err)));
}
});
}

export function readConfigFile<T>(filenameEnvVar: string, defaultPaths: string[]): T | Error {
const defaults = (() => {
for (const target of defaultPaths) {
Expand Down Expand Up @@ -299,7 +239,6 @@ export function performanceReport(
output(`Missing necessary environment variables for file path.`);
}


return actual <= expectation;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ export interface IPerformanceTest {
export interface IConfiguration {
log_level: number;
tests: {
benchmark: {
performance: {
tests: { [key: string]: IPerformanceTest };
};
};
benchmark: { [key: string]: IPerformanceTest };
};
}

Expand Down
Loading

0 comments on commit f107582

Please sign in to comment.