Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time sync #921

Merged
merged 22 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3024381
feat(types): add time sync to compute
narekhovhannisyan Jul 26, 2024
77cc1f2
feat(lib): add time sync
narekhovhannisyan Jul 26, 2024
5c7ef1d
feat(lib): add time sync logic yo initialize
narekhovhannisyan Jul 26, 2024
0cbb144
feat(lib): add time sync logic to compute
narekhovhannisyan Jul 26, 2024
20f7441
feat(util): add time sync message
narekhovhannisyan Jul 26, 2024
d44a184
revert(builtins): drop time sync
narekhovhannisyan Jul 26, 2024
fcdaae0
feat(src): pass time sync config to compute
narekhovhannisyan Jul 26, 2024
efa9983
feat(util): add time sync yo validations
narekhovhannisyan Jul 26, 2024
1a221fa
test(lib): move time sync to lib
narekhovhannisyan Jul 26, 2024
f1f090a
test(lib): update and add cases to initialize
narekhovhannisyan Jul 26, 2024
1ac5038
test(lib): update and add cases to compute
narekhovhannisyan Jul 26, 2024
679e8b2
chore(src): fetch changes from main
narekhovhannisyan Jul 26, 2024
49a42d5
feat(.github): init dispatch workflow
narekhovhannisyan Jul 26, 2024
e53e9fe
chore(src): fetch changes from distinct execution
narekhovhannisyan Jul 30, 2024
de4866d
feat(src): drop time sync from plugins after exec
narekhovhannisyan Jul 31, 2024
fbeff34
revert(types): drop isGroupBy interface
narekhovhannisyan Jul 31, 2024
b44e95f
fix(types): use plugin options in explain
narekhovhannisyan Jul 31, 2024
45ce81f
fix(lib): tune types in initialize
narekhovhannisyan Jul 31, 2024
2ab3e15
fix(util): make plugins optional
narekhovhannisyan Jul 31, 2024
7fc1882
fix(lib): tune types in explain
narekhovhannisyan Jul 31, 2024
8450286
fix(lib): fallback pipeline to empty object if missing, fix regroup p…
narekhovhannisyan Jul 31, 2024
593c7af
feat(builtins): update time sync success manifest
narekhovhannisyan Jul 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/dispatch-integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run if-check on requested branch

on:
workflow_dispatch:

jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Run integration tests
run: npm run if-check -- -d manifests/outputs
19 changes: 6 additions & 13 deletions manifests/examples/builtins/time-sync/success.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
name: time-sync
description: successful path
tags:
'time-sync':
start-time: '2023-12-12T00:00:00.000Z'
end-time: '2023-12-12T00:01:00.000Z'
interval: 5
allow-padding: true
initialize:
output:
- yaml
plugins:
'time-sync':
method: TimeSync
path: "builtin"
global-config:
start-time: '2023-12-12T00:00:00.000Z'
end-time: '2023-12-12T00:01:00.000Z'
interval: 5
allow-padding: true
plugins: {}
tree:
children:
child:
pipeline:
- time-sync
config:
inputs:
- timestamp: '2023-12-12T00:00:00.000Z'
Expand Down
132 changes: 131 additions & 1 deletion src/__tests__/if-run/lib/compute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,59 @@ describe('lib/compute: ', () => {
kind: 'execute',
},
});
const mockObservePlugin = () => ({
execute: () => [
{timestamp: '2024-09-02', duration: 40, 'cpu/utilization': 30},
{timestamp: '2024-09-03', duration: 60, 'cpu/utilization': 40},
],
metadata: {
kind: 'execute',
},
});
const mockObservePluginTimeSync = () => ({
execute: () => [
{
timestamp: '2023-12-12T00:00:00.000Z',
duration: 60,
'cpu/utilization': 30,
},
{
timestamp: '2023-12-12T00:01:00.000Z',
duration: 60,
'cpu/utilization': 40,
},
],
metadata: {
kind: 'execute',
},
});
const mockTimeSync = () => ({
execute: () => [
{
timestamp: '2023-12-12T00:00:00.000Z',
duration: 30,
'cpu/utilization': 30,
},
{
timestamp: '2023-12-12T00:00:30.000Z',
duration: 30,
'cpu/utilization': 30,
},
{
timestamp: '2023-12-12T00:01:00.000Z',
duration: 30,
'cpu/utilization': 40,
},
{
timestamp: '2023-12-12T00:01:30.000Z',
duration: 30,
'cpu/utilization': 40,
},
],
metadata: {
kind: 'execute',
},
});
/**
* Compute params.
*/
Expand All @@ -35,7 +88,11 @@ describe('lib/compute: ', () => {
},
},
},
pluginStorage: pluginStorage().set('mock', mockExecutePlugin()),
pluginStorage: pluginStorage()
.set('mock', mockExecutePlugin())
.set('mock-observe', mockObservePlugin())
.set('mock-observe-time-sync', mockObservePluginTimeSync())
.set('time-sync', mockTimeSync()),
};

describe('compute(): ', () => {
Expand Down Expand Up @@ -221,4 +278,77 @@ describe('lib/compute: ', () => {
expect(response.children.mockChild.outputs).toEqual(expectedResult);
});
});

it('computes simple tree with observe plugin.', async () => {
const tree = {
children: {
mockChild: {
pipeline: {observe: ['mock-observe']},
},
},
};

const response = await compute(tree, paramsExecute);
const expectedResult = [
{timestamp: '2024-09-02', duration: 40, 'cpu/utilization': 30},
{timestamp: '2024-09-03', duration: 60, 'cpu/utilization': 40},
];

expect(response.children.mockChild.inputs).toEqual(expectedResult);
});

it('computes simple tree with time sync plugin.', async () => {
const tree = {
children: {
mockChild: {
pipeline: {observe: ['mock-observe-time-sync']},
},
},
};
const timeSync = {
'start-time': '2023-12-12T00:00:00.000Z',
'end-time': '2023-12-12T00:02:00.000Z',
interval: 5,
'allow-padding': true,
};

const response = await compute(tree, {...paramsExecute, timeSync});
const expectedInputs = [
{
timestamp: '2023-12-12T00:00:00.000Z',
duration: 60,
'cpu/utilization': 30,
},
{
timestamp: '2023-12-12T00:01:00.000Z',
duration: 60,
'cpu/utilization': 40,
},
];
const expectedOutput = [
{
timestamp: '2023-12-12T00:00:00.000Z',
duration: 30,
'cpu/utilization': 30,
},
{
timestamp: '2023-12-12T00:00:30.000Z',
duration: 30,
'cpu/utilization': 30,
},
{
timestamp: '2023-12-12T00:01:00.000Z',
duration: 30,
'cpu/utilization': 40,
},
{
timestamp: '2023-12-12T00:01:30.000Z',
duration: 30,
'cpu/utilization': 40,
},
];

expect(response.children.mockChild.inputs).toEqual(expectedInputs);
expect(response.children.mockChild.outputs).toEqual(expectedOutput);
});
});
Loading