Skip to content

Commit

Permalink
feat: Adding Artillery and K6 triggers (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoscar committed Mar 14, 2024
1 parent 223ae0f commit e31a23f
Show file tree
Hide file tree
Showing 27 changed files with 390 additions and 9 deletions.
24 changes: 22 additions & 2 deletions api/triggers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ components:
properties:
type:
type: string
enum: ["http", "grpc", "traceid", "kafka", "cypress", "playwright"]
enum:
[
"http",
"grpc",
"traceid",
"kafka",
"cypress",
"playwright",
"artillery",
"k6",
]
httpRequest:
$ref: "./http.yaml#/components/schemas/HTTPRequest"
grpc:
Expand All @@ -21,7 +31,17 @@ components:
properties:
type:
type: string
enum: ["http", "grpc", "traceid", "kafka", "cypress", "playwright"]
enum:
[
"http",
"grpc",
"traceid",
"kafka",
"cypress",
"playwright",
"artillery",
"k6",
]
triggerResult:
type: object
properties:
Expand Down
4 changes: 3 additions & 1 deletion server/test/trigger/traceid.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package trigger
const TriggerTypeTraceID TriggerType = "traceid"
const TriggerTypeCypress TriggerType = "cypress"
const TriggerTypePlaywright TriggerType = "playwright"
const TriggerTypeArtillery TriggerType = "artillery"
const TriggerTypeK6 TriggerType = "k6"

var traceIDBasedTriggers = []TriggerType{TriggerTypeTraceID, TriggerTypeCypress, TriggerTypePlaywright}
var traceIDBasedTriggers = []TriggerType{TriggerTypeTraceID, TriggerTypeCypress, TriggerTypePlaywright, TriggerTypeArtillery, TriggerTypeK6}

type TraceIDRequest struct {
ID string `json:"id,omitempty" expr_enabled:"true"`
Expand Down
2 changes: 1 addition & 1 deletion server/test/trigger/trigger_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (v3 triggerJSONV3) valid() bool {
(v3.HTTP != nil ||
v3.GRPC != nil ||
v3.TraceID != nil ||
v3.Kafka != nil)) || (v3.Type == TriggerTypeCypress || v3.Type == TriggerTypePlaywright)
v3.Kafka != nil)) || (v3.Type == TriggerTypeCypress || v3.Type == TriggerTypePlaywright || v3.Type == TriggerTypeArtillery || v3.Type == TriggerTypeK6)
}

type triggerJSONV2 struct {
Expand Down
26 changes: 25 additions & 1 deletion web/src/components/RunDetailAutomate/RunDetailAutomate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import DeepLink from 'components/RunDetailAutomateMethods/methods/DeepLink';
import Playwright from 'components/RunDetailAutomateMethods/methods/Playwright';
import Typescript from 'components/RunDetailAutomateMethods/methods/Typescript';
import GithubActions from 'components/RunDetailAutomateMethods/methods/GithubActions';
import K6 from 'components/RunDetailAutomateMethods/methods/K6';
import Artillery from 'components/RunDetailAutomateMethods/methods/Artillery';
import ArtilleryEngine from 'components/RunDetailAutomateMethods/methods/ArtilleryEngine';
import {CLI_RUNNING_TESTS_URL} from 'constants/Common.constants';
import useDefinitionFile from 'hooks/useDefinitionFile';
import {TriggerTypes} from 'constants/Test.constants';
Expand Down Expand Up @@ -36,6 +39,22 @@ function getMethods(triggerType: TriggerTypes) {
component: Playwright,
},
];
case TriggerTypes.artillery:
return [
{
id: 'artillery',
label: 'Artillery',
component: Artillery,
},
];
case TriggerTypes.k6:
return [
{
id: 'k6',
label: 'K6',
component: K6,
},
];
default:
return [
{
Expand All @@ -58,6 +77,11 @@ function getMethods(triggerType: TriggerTypes) {
label: 'TypeScript',
component: Typescript,
},
{
id: 'artillery-engine',
label: 'Artillery',
component: ArtilleryEngine,
},
];
}
}
Expand All @@ -78,7 +102,7 @@ const RunDetailAutomate = ({test, run}: IProps) => {

return (
<S.Container>
<ResizablePanels saveId='run-detail-automate'>
<ResizablePanels saveId="run-detail-automate">
<FillPanel>
<RunDetailAutomateDefinition
definition={definition}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {Typography} from 'antd';
import styled from 'styled-components';

export const Title = styled(Typography.Title).attrs({
level: 3,
})`
&& {
font-size: ${({theme}) => theme.size.md};
font-weight: 600;
margin-bottom: 16px;
}
`;

export const TitleContainer = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
`;

export const Container = styled.div`
margin: 16px 0;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {ArtilleryCodeSnippet} from 'constants/Automate.constants';
import {Typography} from 'antd';
import {ReadOutlined} from '@ant-design/icons';
import {FramedCodeBlock} from 'components/CodeBlock';
import Test from 'models/Test.model';
import * as S from './Artillery.styled';
import {IMethodChildrenProps} from '../../RunDetailAutomateMethods';

interface IProps extends IMethodChildrenProps {
test: Test;
}

const ARTILLERY_DOCS = 'https://docs.tracetest.io/tools-and-integrations/artillery-plugin';

const Artillery = ({test}: IProps) => (
<S.Container>
<S.TitleContainer>
<S.Title>Artillery Integration</S.Title>
<a href={ARTILLERY_DOCS} target="_blank">
<ReadOutlined />
</a>
</S.TitleContainer>
<Typography.Paragraph>
The code snippet below enables you to run this test via a Artillery run.
</Typography.Paragraph>
<FramedCodeBlock
title="Install:"
language="bash"
value="npm i -g artillery-plugin-tracetest"
minHeight="50px"
maxHeight="50px"
/>
<br />
<FramedCodeBlock
title="Artillery Test Script:"
minHeight="300px"
maxHeight="300px"
language="yaml"
value={ArtilleryCodeSnippet(test.id)}
/>
</S.Container>
);

export default Artillery;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line no-restricted-exports
export {default} from './Artillery';
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {Typography} from 'antd';
import styled from 'styled-components';

export const Title = styled(Typography.Title).attrs({
level: 3,
})`
&& {
font-size: ${({theme}) => theme.size.md};
font-weight: 600;
margin-bottom: 16px;
}
`;

export const TitleContainer = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
`;

export const Container = styled.div`
margin: 16px 0;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {ArtilleryEngineCodeSnippet} from 'constants/Automate.constants';
import {ReadOutlined} from '@ant-design/icons';
import {Typography} from 'antd';
import {FramedCodeBlock} from 'components/CodeBlock';
import Test from 'models/Test.model';
import * as S from './ArtilleryEngine.styled';
import {IMethodChildrenProps} from '../../RunDetailAutomateMethods';

interface IProps extends IMethodChildrenProps {
test: Test;
}

const ARTILLERY_DOCS = 'https://docs.tracetest.io/tools-and-integrations/artillery-engine';

const ArtilleryEngine = ({test}: IProps) => (
<S.Container>
<S.TitleContainer>
<S.Title>Artillery Engine Integration</S.Title>
<a href={ARTILLERY_DOCS} target="_blank">
<ReadOutlined />
</a>
</S.TitleContainer>
<Typography.Paragraph>
The code snippet below enables you to run this test via a Artillery run.
</Typography.Paragraph>
<FramedCodeBlock
title="Install:"
language="bash"
value="npm i -g artillery-engine-tracetest"
minHeight="50px"
maxHeight="50px"
/>
<br />
<FramedCodeBlock
title="Artillery Test Script:"
language="yaml"
value={ArtilleryEngineCodeSnippet(test.id)}
/>
</S.Container>
);

export default ArtilleryEngine;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line no-restricted-exports
export {default} from './ArtilleryEngine';
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Typography} from 'antd';
import {ReadOutlined} from '@ant-design/icons';
import {FramedCodeBlock} from 'components/CodeBlock';
import {CypressCodeSnippet} from 'constants/Automate.constants';
import Test from 'models/Test.model';
Expand All @@ -9,12 +10,25 @@ interface IProps extends IMethodChildrenProps {
test: Test;
}

const CYPRESS_DOCS = 'https://docs.tracetest.io/tools-and-integrations/cypress';

const Cypress = ({test}: IProps) => (
<S.Container>
<S.TitleContainer>
<S.Title>Cypress Integration</S.Title>
<a href={CYPRESS_DOCS} target="_blank">
<ReadOutlined />
</a>
</S.TitleContainer>
<Typography.Paragraph>The code snippet below enables you to run this test via a Cypress run.</Typography.Paragraph>
<FramedCodeBlock
title="Install:"
language="bash"
value="npm i -g @tracetest/cypress"
minHeight="50px"
maxHeight="50px"
/>
<br />
<FramedCodeBlock title="Cypress code snippet:" language="javascript" value={CypressCodeSnippet(test.name)} />
</S.Container>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {Typography} from 'antd';
import styled from 'styled-components';

export const Title = styled(Typography.Title).attrs({
level: 3,
})`
&& {
font-size: ${({theme}) => theme.size.md};
font-weight: 600;
margin-bottom: 16px;
}
`;

export const TitleContainer = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
`;

export const Container = styled.div`
margin: 16px 0;
`;
36 changes: 36 additions & 0 deletions web/src/components/RunDetailAutomateMethods/methods/K6/K6.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {K6CodeSnippet} from 'constants/Automate.constants';
import {ReadOutlined} from '@ant-design/icons';
import {Typography} from 'antd';
import {FramedCodeBlock} from 'components/CodeBlock';
import * as S from './K6.styled';

const K6_DOCS = 'https://docs.tracetest.io/tools-and-integrations/k6';

const K6 = () => (
<S.Container>
<S.TitleContainer>
<S.Title>K6 Integration</S.Title>
<a href={K6_DOCS} target="_blank">
<ReadOutlined />
</a>
</S.TitleContainer>
<Typography.Paragraph>The code snippet below enables you to run this test via a K6 run.</Typography.Paragraph>
<FramedCodeBlock
title="Bundle:"
language="bash"
value="xk6 build v0.49.0 --with github.com/kubeshop/xk6-tracetest"
minHeight="50px"
maxHeight="50px"
/>
<br />
<FramedCodeBlock
title="K6 Test Script:"
minHeight="50px"
maxHeight="50px"
language="bash"
value={K6CodeSnippet()}
/>
</S.Container>
);

export default K6;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line no-restricted-exports
export {default} from './K6';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ const Playwright = ({test}: IProps) => (
<S.TitleContainer>
<S.Title>Playwright Integration</S.Title>
</S.TitleContainer>
<Typography.Paragraph>The code snippet below enables you to run this test via a Playwright run.</Typography.Paragraph>
<Typography.Paragraph>
The code snippet below enables you to run this test via a Playwright run.
</Typography.Paragraph>
<FramedCodeBlock
title="Install:"
language="bash"
value="npm i @tracetest/playwright"
minHeight="50px"
maxHeight="50px"
/>
<br />
<FramedCodeBlock title="Playwright code snippet:" language="javascript" value={PlaywrightCodeSnippet(test.name)} />
</S.Container>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const ComponentMap: Record<TriggerTypes, (props: IPropsComponent) => React.React
[TriggerTypes.traceid]: RunDetailTriggerData,
[TriggerTypes.cypress]: RunDetailTriggerData,
[TriggerTypes.playwright]: RunDetailTriggerData,
[TriggerTypes.artillery]: RunDetailTriggerData,
[TriggerTypes.k6]: RunDetailTriggerData,
};

interface IProps extends IPropsComponent {
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/TestPlugins/EntryPointFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const EntryPointFactoryMap = {
[TriggerTypes.traceid]: TriggerHeaderBarTraceID,
[TriggerTypes.cypress]: () => null,
[TriggerTypes.playwright]: () => null,
[TriggerTypes.artillery]: () => null,
[TriggerTypes.k6]: () => null,
};

interface IProps {
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/TestPlugins/FormFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const FormFactoryMap = {
[TriggerTypes.traceid]: () => null,
[TriggerTypes.cypress]: () => null,
[TriggerTypes.playwright]: () => null,
[TriggerTypes.artillery]: () => null,
[TriggerTypes.k6]: () => null,
};

interface IProps {
Expand Down
Loading

0 comments on commit e31a23f

Please sign in to comment.