@@ -6,8 +6,7 @@ const { Command, Flags, Args } = require('@oclif/core');
6
6
const telemetry = require ( '../telemetry' ) . init ( ) ;
7
7
const { Plugin : CloudPlugin } = require ( '../platform/cloud/cloud' ) ;
8
8
9
- const tryRequire = require ( 'try-require' ) ;
10
- const PlatformFargateLegacy = tryRequire ( '@artilleryio/platform-fargate' ) ;
9
+ const runCluster = require ( '../platform/aws-ecs/legacy/run-cluster' ) ;
11
10
const PlatformECS = require ( '../platform/aws-ecs/ecs' ) ;
12
11
const { ECS_WORKER_ROLE_NAME } = require ( '../platform/aws/constants' ) ;
13
12
@@ -18,6 +17,11 @@ class RunCommand extends Command {
18
17
19
18
async run ( ) {
20
19
const { flags, _argv, args } = await this . parse ( RunCommand ) ;
20
+
21
+ flags [ 'platform-opt' ] = [ `region=${ flags . region } ` ] ;
22
+
23
+ flags . platform = 'aws:ecs' ;
24
+
21
25
new CloudPlugin ( null , null , { flags } ) ;
22
26
23
27
const ECS = new PlatformECS ( null , null , { } , { testRunId : 'foo' } ) ;
@@ -34,14 +38,105 @@ class RunCommand extends Command {
34
38
} ) ;
35
39
36
40
// Delegate the rest to existing implementation:
37
- PlatformFargateLegacy . commands . runCluster ( args . script , flags ) ;
41
+ runCluster ( args . script , flags ) ;
38
42
}
39
43
}
40
44
41
- if ( PlatformFargateLegacy ) {
42
- RunCommand . description = PlatformFargateLegacy . oclif . runTest . description ;
43
- RunCommand . flags = PlatformFargateLegacy . oclif . runTest . flags ;
44
- RunCommand . args = PlatformFargateLegacy . oclif . runTest . args ;
45
- }
45
+ const runTestDescriptions = {
46
+ count : 'Number of load generator workers to launch' ,
47
+ cluster : 'Name of the Fargate/ECS cluster to run the test on' ,
48
+ region : 'The AWS region to run in' ,
49
+ packages :
50
+ 'Path to package.json file which lists dependencies for the test script' ,
51
+ maxDuration : 'Maximum duration of the test run' ,
52
+ dotenv : 'Path to a .env file to load environment variables from'
53
+ } ;
54
+
55
+ RunCommand . description = `launch a test using AWS ECS/Fargate
56
+
57
+ Examples:
58
+
59
+ To launch a test with 10 load generating workers using AWS Fargate in us-east-1:
60
+
61
+ $ artillery run:fargate --count 10 --region us-east-1 my-test.yml
62
+ ` ;
63
+
64
+ RunCommand . flags = {
65
+ count : Flags . integer ( {
66
+ description : runTestDescriptions . count
67
+ } ) ,
68
+ cluster : Flags . string ( {
69
+ description : runTestDescriptions . cluster
70
+ } ) ,
71
+ region : Flags . string ( {
72
+ char : 'r' ,
73
+ description : runTestDescriptions . region
74
+ } ) ,
75
+ secret : Flags . string ( {
76
+ multiple : true
77
+ } ) ,
78
+ // TODO: Descriptions
79
+ 'launch-type' : Flags . string ( { } ) ,
80
+ 'launch-config' : Flags . string ( { } ) ,
81
+ 'subnet-ids' : Flags . string ( { } ) ,
82
+ 'security-group-ids' : Flags . string ( { } ) ,
83
+ 'task-role-name' : Flags . string ( { } ) ,
84
+ target : Flags . string ( {
85
+ char : 't' ,
86
+ description :
87
+ 'Set target endpoint. Overrides the target already set in the test script'
88
+ } ) ,
89
+ output : Flags . string ( {
90
+ char : 'o' ,
91
+ description : 'Write a JSON report to file'
92
+ } ) ,
93
+ insecure : Flags . boolean ( {
94
+ char : 'k' ,
95
+ description : 'Allow insecure TLS connections; do not use in production'
96
+ } ) ,
97
+ environment : Flags . string ( {
98
+ char : 'e' ,
99
+ description : 'Use one of the environments specified in config.environments'
100
+ } ) ,
101
+ config : Flags . string ( {
102
+ description : 'Read configuration for the test from the specified file'
103
+ } ) ,
104
+ 'scenario-name' : Flags . string ( {
105
+ description : 'Name of the specific scenario to run'
106
+ } ) ,
107
+ overrides : Flags . string ( {
108
+ description : 'Dynamically override values in the test script; a JSON object'
109
+ } ) ,
110
+ input : Flags . string ( {
111
+ char : 'i' ,
112
+ description : 'Input script file' ,
113
+ multiple : true ,
114
+ hidden : true
115
+ } ) ,
116
+ tags : Flags . string ( {
117
+ description :
118
+ 'Comma-separated list of tags in key:value format to tag the test run, for example: --tags team:sre,service:foo'
119
+ } ) ,
120
+ note : Flags . string ( { } ) , // TODO: description
121
+ packages : Flags . string ( {
122
+ description : runTestDescriptions . packages
123
+ } ) ,
124
+ 'max-duration' : Flags . string ( {
125
+ description : runTestDescriptions . maxDuration
126
+ } ) ,
127
+ dotenv : Flags . string ( {
128
+ description : runTestDescriptions . dotenv
129
+ } ) ,
130
+ record : Flags . boolean ( {
131
+ description : 'Record test run to Artillery Cloud'
132
+ } ) ,
133
+ key : Flags . string ( {
134
+ description : 'API key for Artillery Cloud'
135
+ } )
136
+ } ;
137
+
138
+ RunCommand . args = {
139
+ script : Args . string ( )
140
+ } ;
46
141
47
142
module . exports = RunCommand ;
0 commit comments