@teamscale/coverage-collector 0.1.0-beta.8 → 1.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +23 -25
- package/dist/src/config/RemoteProfilerConfig.d.ts +24 -0
- package/dist/src/config/RemoteProfilerConfig.js +76 -0
- package/dist/src/control/App.d.ts +31 -0
- package/dist/src/control/App.js +202 -0
- package/dist/src/control/ControlServer.d.ts +24 -0
- package/dist/src/control/ControlServer.js +100 -0
- package/dist/src/control/CoverageDumper.d.ts +27 -0
- package/dist/src/control/CoverageDumper.js +166 -0
- package/dist/src/main.js +29 -2
- package/dist/src/receiver/CollectingServer.d.ts +2 -2
- package/dist/src/receiver/CollectingServer.js +70 -20
- package/dist/src/receiver/Session.d.ts +15 -25
- package/dist/src/receiver/Session.js +34 -7
- package/dist/src/storage/DataStorage.d.ts +154 -81
- package/dist/src/storage/DataStorage.js +361 -81
- package/dist/src/upload/ArtifactoryUpload.d.ts +2 -2
- package/dist/src/upload/ArtifactoryUpload.js +25 -28
- package/dist/src/upload/TeamscaleUpload.d.ts +8 -2
- package/dist/src/upload/TeamscaleUpload.js +67 -31
- package/dist/src/utils/PrettyFileLogger.d.ts +0 -1
- package/dist/src/utils/PrettyFileLogger.js +1 -0
- package/dist/src/utils/RestApis.d.ts +37 -0
- package/dist/src/utils/RestApis.js +141 -0
- package/dist/src/utils/StdConsoleLogger.js +11 -1
- package/package.json +23 -25
- package/dist/src/App.d.ts +0 -44
- package/dist/src/App.js +0 -267
- package/dist/src/upload/CommonUpload.d.ts +0 -16
- package/dist/src/upload/CommonUpload.js +0 -63
- package/dist/src/upload/ProxyUpload.d.ts +0 -6
- package/dist/src/upload/ProxyUpload.js +0 -30
- package/dist/src/utils/ConfigParameters.d.ts +0 -36
- package/dist/src/utils/ConfigParameters.js +0 -107
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CollectorOptions, ConfigurationParameters } from '@cqse/commons';
|
|
1
2
|
import Logger from 'bunyan';
|
|
2
3
|
/**
|
|
3
4
|
* Lines covered for the specified file.
|
|
@@ -8,79 +9,62 @@ export type FileCoverage = {
|
|
|
8
9
|
/** Lines covered */
|
|
9
10
|
coveredLines: Set<number>;
|
|
10
11
|
};
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
export interface IReadableStorage {
|
|
12
|
+
/** Specifier of a coverage target bucket */
|
|
13
|
+
export type CoverageBucketSpecifier = {
|
|
15
14
|
/**
|
|
16
|
-
* The
|
|
15
|
+
* The unique ID of the application the coverage is collected for.
|
|
17
16
|
*/
|
|
18
|
-
|
|
17
|
+
appId: string;
|
|
19
18
|
/**
|
|
20
|
-
*
|
|
19
|
+
* The configuration that shall be used along with this application.
|
|
21
20
|
*/
|
|
22
|
-
|
|
21
|
+
configId?: string;
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @param coverageFolder - Full path of the file to write the coverage to.
|
|
27
|
-
* @param date - Date to use for the appended timestamp
|
|
28
|
-
*
|
|
29
|
-
* @return The number of lines written
|
|
23
|
+
* Concrete configuration option values to set.
|
|
30
24
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
configOptions?: string;
|
|
26
|
+
/** The project's commit to contribute coverage for. Either a revision or a
|
|
27
|
+
* commit in the sense of branch+timestamp.
|
|
28
|
+
*/
|
|
29
|
+
commit: string;
|
|
30
|
+
};
|
|
33
31
|
/**
|
|
34
|
-
*
|
|
32
|
+
* Summary of the coverage dump that has been performed.
|
|
35
33
|
*/
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* @param project - The project to add the information to.
|
|
41
|
-
* @param sourceFilePath - The file for that lines are covered.
|
|
42
|
-
* @param coveredOriginalLines - The covered lines.
|
|
43
|
-
*/
|
|
44
|
-
putCoverage(project: string, sourceFilePath: string, coveredOriginalLines: number[]): void;
|
|
45
|
-
/**
|
|
46
|
-
* Signals that we have received coverage information
|
|
47
|
-
* for that no mapping based on sourcemaps was possible.
|
|
48
|
-
*
|
|
49
|
-
* @param project - The project to add the information to.
|
|
50
|
-
*/
|
|
51
|
-
signalUnmappedCoverage(project: string): void;
|
|
52
|
-
/**
|
|
53
|
-
* Discard the coverage information that has been collected up to this point.
|
|
54
|
-
*/
|
|
55
|
-
discardCollectedCoverage(): void;
|
|
56
|
-
}
|
|
34
|
+
export type DumpSummary = {
|
|
35
|
+
hadCoverageToDump: boolean;
|
|
36
|
+
details: CoverageDumpDetails[];
|
|
37
|
+
};
|
|
57
38
|
/**
|
|
58
|
-
*
|
|
39
|
+
* Details of a single dump (for a single application and commit).
|
|
59
40
|
*/
|
|
60
|
-
export
|
|
61
|
-
|
|
41
|
+
export type CoverageDumpDetails = {
|
|
42
|
+
appId: string;
|
|
43
|
+
commit: string;
|
|
44
|
+
simpleCoverageFileLines: number;
|
|
45
|
+
simpleCoverageFile: string;
|
|
46
|
+
};
|
|
62
47
|
/**
|
|
63
|
-
* The coverage information received for one particular project.
|
|
48
|
+
* The coverage information received for one particular project/revision/application.
|
|
64
49
|
*/
|
|
65
|
-
export declare class
|
|
50
|
+
export declare class CoverageBucket {
|
|
66
51
|
/**
|
|
67
|
-
* The identifier of the
|
|
52
|
+
* The identifier of the application.
|
|
68
53
|
*/
|
|
69
|
-
|
|
54
|
+
readonly appId: string;
|
|
70
55
|
/**
|
|
71
|
-
* The coverage.
|
|
56
|
+
* The commit the coverage is reported for.
|
|
72
57
|
*/
|
|
73
|
-
|
|
58
|
+
readonly commit: string;
|
|
74
59
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @param projectId - The identifier of the project to collect the coverage for.
|
|
60
|
+
* The actual coverage.
|
|
78
61
|
*/
|
|
79
|
-
|
|
62
|
+
private readonly coveredLinesByFile;
|
|
63
|
+
constructor(appId: string, commit: string);
|
|
80
64
|
/**
|
|
81
65
|
* Put coverage for a single line to the storage.
|
|
82
66
|
*
|
|
83
|
-
* @param sourceFile - The file in
|
|
67
|
+
* @param sourceFile - The file in which the line is covered.
|
|
84
68
|
* @param line - The line number.
|
|
85
69
|
*/
|
|
86
70
|
putLine(sourceFile: string, line: number): void;
|
|
@@ -88,41 +72,126 @@ export declare class ProjectCoverage {
|
|
|
88
72
|
* Returns an iterator over the projects' coverage.
|
|
89
73
|
*/
|
|
90
74
|
getCoverage(): IterableIterator<FileCoverage>;
|
|
75
|
+
/**
|
|
76
|
+
* Clears the coverage of the bucket.
|
|
77
|
+
*/
|
|
78
|
+
clear(): void;
|
|
91
79
|
}
|
|
80
|
+
type AppId = string;
|
|
81
|
+
type ConfigId = string;
|
|
82
|
+
/**
|
|
83
|
+
* Callbacks called before a new configuration will take effect, that is,
|
|
84
|
+
* with the old config still active.
|
|
85
|
+
*/
|
|
86
|
+
export type BeforeConfigUpdateCallback = (appId: string, dataStorage: DataStorage) => Promise<void>;
|
|
92
87
|
/**
|
|
93
88
|
* The data storage which retrieves coverage information.
|
|
94
89
|
*/
|
|
95
|
-
export declare class DataStorage
|
|
90
|
+
export declare class DataStorage {
|
|
91
|
+
/**
|
|
92
|
+
* The different coverage buckets, identified by a bucket key.
|
|
93
|
+
*/
|
|
94
|
+
private coverageBuckets;
|
|
95
|
+
/**
|
|
96
|
+
* Configuration per application.
|
|
97
|
+
*/
|
|
98
|
+
private readonly configPerApp;
|
|
96
99
|
/**
|
|
97
|
-
*
|
|
100
|
+
* Which configurations (their hashes) have already been validated? We store the hash of the validated config on the right.
|
|
98
101
|
*/
|
|
99
|
-
private
|
|
102
|
+
private readonly validatedPerApp;
|
|
103
|
+
/**
|
|
104
|
+
* Configuration ID per application (key: app id, value: config id).
|
|
105
|
+
*/
|
|
106
|
+
private readonly configIdPerApp;
|
|
100
107
|
/**
|
|
101
108
|
* Logger to use.
|
|
102
109
|
*/
|
|
103
110
|
private readonly logger;
|
|
104
111
|
/**
|
|
105
|
-
*
|
|
112
|
+
* Base configuration to use.
|
|
106
113
|
*/
|
|
107
|
-
private
|
|
114
|
+
private readonly baseConfig;
|
|
108
115
|
/**
|
|
109
116
|
* Date format for the timestamp appended to the coverage files
|
|
110
117
|
*/
|
|
111
|
-
readonly DATE_FORMAT = "YYYY-MM-DD-HH-mm-ss
|
|
118
|
+
readonly DATE_FORMAT = "YYYY-MM-DD-HH-mm-ss";
|
|
119
|
+
/**
|
|
120
|
+
* The configuration parameters the collector can be configured with.
|
|
121
|
+
*/
|
|
122
|
+
private readonly reconfigurableParameters;
|
|
123
|
+
/**
|
|
124
|
+
* All configuration parameters the collector can be configured with.
|
|
125
|
+
*/
|
|
126
|
+
private readonly allParameters;
|
|
127
|
+
/**
|
|
128
|
+
* Callbacks registered to be invoked before a new configuration will take effect.
|
|
129
|
+
*/
|
|
130
|
+
private readonly beforeConfigUpdateCallbacks;
|
|
112
131
|
/**
|
|
113
132
|
* Constructs the data storage.
|
|
114
133
|
*
|
|
115
134
|
* @param logger - The logger to use.
|
|
135
|
+
* @param allParameters - The description of all available configuration parameters.
|
|
136
|
+
* @param reconfigurableParameters - The description of the reconfigurable configuration parameters.
|
|
137
|
+
* @param baseConfig - The configuration that has initially been done via the command line.
|
|
138
|
+
*/
|
|
139
|
+
constructor(logger: Logger, allParameters: ConfigurationParameters, reconfigurableParameters: ConfigurationParameters, baseConfig: CollectorOptions);
|
|
140
|
+
/**
|
|
141
|
+
* Create a coverage bucket as specified by the given `bucketSpecifier`; if it already exists,
|
|
142
|
+
* keep the existing one. Retrieve the configuration from Teamscale if a config ID is supplied with the bucket specifier.
|
|
143
|
+
*/
|
|
144
|
+
setupCoverageBucket(bucketSpecifier: CoverageBucketSpecifier): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Change the configuration (id) for the given app.
|
|
147
|
+
* <p>
|
|
148
|
+
* If the given app ID has not yet assigned a configuration ID
|
|
149
|
+
* or if it is different, then fetch the configuration from Teamscale and assign it to the application.
|
|
150
|
+
*/
|
|
151
|
+
changeAppConfiguration(appId: AppId, configId: ConfigId): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* For all applications, re-fetch the remote configuration, if set.
|
|
154
|
+
* The configuration cache in `RemoteProfilerConfig.ts` ensures that we do not make
|
|
155
|
+
* the fetch repeatedly if the same config id is assigned to different applications.
|
|
156
|
+
*/
|
|
157
|
+
refreshAllRemoteConfigurations(): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Re-retrieve the configuration from Teamscale for the given application and configuration ID.
|
|
116
160
|
*/
|
|
117
|
-
|
|
161
|
+
refreshApplicationConfiguration(appId: string, newConfigId?: string): Promise<void>;
|
|
162
|
+
private getOrCreateAppConfig;
|
|
163
|
+
private setConfigurationParameter;
|
|
164
|
+
/**
|
|
165
|
+
* Check the configuration for its validity. If invalid, report it (if not already
|
|
166
|
+
* done in this run of the collector).
|
|
167
|
+
*/
|
|
168
|
+
private validateConfiguration;
|
|
169
|
+
/**
|
|
170
|
+
* Returns the collector configuration with overrides for the given app ID.
|
|
171
|
+
*/
|
|
172
|
+
getAppConfiguration(appId: string): CollectorOptions;
|
|
173
|
+
/**
|
|
174
|
+
* Return the bucket which is defined by the given bucket specifier.
|
|
175
|
+
* Creates a new one if it does not yet exist.
|
|
176
|
+
*/
|
|
177
|
+
private getBucketFor;
|
|
178
|
+
/**
|
|
179
|
+
* For testing: Get the bucket of the given application and commit.
|
|
180
|
+
*/
|
|
181
|
+
getBucket(appId: string, commit: string): CoverageBucket | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Gets all coverage buckets with the given appId. If now appId is given, all buckets will be returned.
|
|
184
|
+
*/
|
|
185
|
+
private getAppBuckets;
|
|
118
186
|
/**
|
|
119
187
|
* Put coverage into the storage.
|
|
120
188
|
*
|
|
121
|
-
* @param
|
|
189
|
+
* @param appId - The ID of the application to add coverage for.
|
|
190
|
+
* @param commit - The target commit (or revision) to add coverage for.
|
|
122
191
|
* @param sourceFilePath - The covered file.
|
|
123
192
|
* @param coveredOriginalLines - The lines covered in the file.
|
|
124
193
|
*/
|
|
125
|
-
putCoverage(
|
|
194
|
+
putCoverage(appId: string, commit: string, sourceFilePath: string, coveredOriginalLines: number[]): void;
|
|
126
195
|
/**
|
|
127
196
|
* Normalize the source file names provided by the Web browsers / from the
|
|
128
197
|
* instrumentation such that they can be matched to the original source code by Teamscale.
|
|
@@ -131,39 +200,43 @@ export declare class DataStorage implements IDataStorage {
|
|
|
131
200
|
*/
|
|
132
201
|
private static normalizeSourceFileName;
|
|
133
202
|
/**
|
|
134
|
-
*
|
|
203
|
+
* Dump coverage to the given coverage folder. Either for a specified application only,
|
|
204
|
+
* or if not given, for all applications.
|
|
135
205
|
*/
|
|
136
|
-
|
|
206
|
+
dumpToSimpleCoverageFile(coverageFolder: string, date: Date, dumpForAppIdOnly?: string): DumpSummary;
|
|
137
207
|
/**
|
|
138
|
-
*
|
|
208
|
+
* Set the collected coverage to 0 for all buckets of the given application.
|
|
139
209
|
*/
|
|
140
|
-
|
|
210
|
+
private resetCoverage;
|
|
141
211
|
/**
|
|
142
|
-
*
|
|
212
|
+
* Appends the timestamp given with date to the coverageFolder (before the file ending if there is one).
|
|
213
|
+
*
|
|
214
|
+
* @param coverageFolder - Path to the coverage file
|
|
215
|
+
* @param date - Represents the timestamp to be appended with the format {@link DataStorage.DATE_FORMAT}
|
|
216
|
+
* @param commit - The commit to report coverage for.
|
|
217
|
+
* @param appId - The id of the application to dump coverage for.
|
|
143
218
|
*/
|
|
144
|
-
|
|
219
|
+
private prepareValidCoverageFileName;
|
|
145
220
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
221
|
+
* Generate file contents in the Simple Coverage Format for the collected coverage.
|
|
222
|
+
* The resulting map contains one entry for each commit.
|
|
148
223
|
*/
|
|
149
|
-
private
|
|
224
|
+
private toSimpleCoverage;
|
|
150
225
|
/**
|
|
151
|
-
*
|
|
152
|
-
* @param coverageFolder Path to the coverage file
|
|
153
|
-
* @param date Represents the timestamp to be appended with the format {@link DataStorage.DATE_FORMAT}
|
|
154
|
-
* @private
|
|
226
|
+
* Returns the applications that are known to us.
|
|
155
227
|
*/
|
|
156
|
-
|
|
228
|
+
getApplicationIDs(): Set<AppId>;
|
|
157
229
|
/**
|
|
158
|
-
*
|
|
230
|
+
* Returns all app IDs that are configured with the given config ID.
|
|
159
231
|
*/
|
|
160
|
-
|
|
232
|
+
getApplicationsWithConfig(configId: string): Set<AppId>;
|
|
161
233
|
/**
|
|
162
|
-
*
|
|
234
|
+
* Discard the coverage information that has been collected up to this point.
|
|
163
235
|
*/
|
|
164
|
-
|
|
236
|
+
discardCollectedCoverage(appId?: AppId): void;
|
|
165
237
|
/**
|
|
166
|
-
*
|
|
238
|
+
* Add a before-config-update callback.
|
|
167
239
|
*/
|
|
168
|
-
|
|
240
|
+
addBeforeConfigUpdateCallback(callback: BeforeConfigUpdateCallback): void;
|
|
169
241
|
}
|
|
242
|
+
export {};
|