Skip to content

Commit cbd16d2

Browse files
committed
backport of #2756
1 parent 4917664 commit cbd16d2

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

build/scripts/Testing.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Tests =
1919
let private buildingOnTravis = getEnvironmentVarAsBool "TRAVIS"
2020

2121
let private setLocalEnvVars() =
22-
let clusterFilter = getBuildParamOrDefault "escluster" ""
22+
let clusterFilter = getBuildParamOrDefault "clusterfilter" ""
2323
let testFilter = getBuildParamOrDefault "testfilter" ""
2424
setProcessEnvironVar "NEST_INTEGRATION_CLUSTER" clusterFilter
2525
setProcessEnvironVar "NEST_TEST_FILTER" testFilter

src/Tests/Aggregations/Metric/ScriptedMetric/ScriptedMetricAggregationUsageTests.cs

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,36 +95,20 @@ class Scripted
9595

9696
private Scripted First = new Scripted
9797
{
98-
Language = "painless",
99-
Init = "params._agg.map = [:]",
100-
Map =
101-
"if (params._agg.map.containsKey(doc['state'].value))" +
102-
" params._agg.map[doc['state'].value] += 1;" +
103-
"else" +
104-
" params._agg.map[doc['state'].value] = 1;",
105-
106-
Reduce =
107-
"def reduce = [:];" +
108-
"for (agg in params._aggs)" +
109-
"{" +
110-
" for (entry in agg.map.entrySet())" +
111-
" {" +
112-
" if (reduce.containsKey(entry.getKey()))" +
113-
" reduce[entry.getKey()] += entry.getValue();" +
114-
" else" +
115-
" reduce[entry.getKey()] = entry.getValue();" +
116-
" }" +
117-
"}" +
118-
"return reduce;"
98+
Language = "groovy",
99+
Combine = "sum = 0; for (c in _agg.commits) { sum += c }; return sum",
100+
Reduce = "sum = 0; for (a in _aggs) { sum += a }; return sum",
101+
Map = "if (doc['state'].value == \"Stable\") { _agg.commits.add(doc['numberOfCommits']) }",
102+
Init = "_agg['commits'] = []"
119103
};
120104

121105
private Scripted Second = new Scripted
122106
{
123-
Language = "painless",
124-
Combine = "def sum = 0.0; for (c in params._agg.commits) { sum += c } return sum",
125-
Reduce = "def sum = 0.0; for (a in params._aggs) { sum += a } return sum",
126-
Map = "if (doc['state'].value == \"Stable\") { params._agg.commits.add(doc['numberOfCommits'].value) }",
127-
Init = "params._agg.commits = []"
107+
Language = "groovy",
108+
Combine = "sum = 0; for (c in _agg.commits) { sum += c }; return sum",
109+
Reduce = "sum = 0; for (a in _aggs) { sum += a }; return sum",
110+
Map = "if (doc['state'].value == \"Stable\") { _agg.commits.add(doc['numberOfCommits']) }",
111+
Init = "_agg['commits'] = []"
128112
};
129113

130114
public ScriptedMetricMultiAggregationTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { }
@@ -147,6 +131,11 @@ public ScriptedMetricMultiAggregationTests(ReadOnlyCluster i, EndpointUsage usag
147131
inline = First.Map,
148132
lang = First.Language
149133
},
134+
combine_script = new
135+
{
136+
inline = First.Combine,
137+
lang = First.Language
138+
},
150139
reduce_script = new
151140
{
152141
inline = First.Reduce,
@@ -188,6 +177,7 @@ public ScriptedMetricMultiAggregationTests(ReadOnlyCluster i, EndpointUsage usag
188177
.ScriptedMetric("by_state_total", sm => sm
189178
.InitScript(ss => ss.Inline(First.Init).Lang(First.Language))
190179
.MapScript(ss => ss.Inline(First.Map).Lang(First.Language))
180+
.CombineScript(ss => ss.Inline(First.Combine).Lang(First.Language))
191181
.ReduceScript(ss => ss.Inline(First.Reduce).Lang(First.Language))
192182
)
193183
.ScriptedMetric("total_commits", sm => sm
@@ -206,6 +196,7 @@ public ScriptedMetricMultiAggregationTests(ReadOnlyCluster i, EndpointUsage usag
206196
{
207197
InitScript = new InlineScript(First.Init) {Lang = First.Language},
208198
MapScript = new InlineScript(First.Map) {Lang = First.Language},
199+
CombineScript = new InlineScript(First.Combine) {Lang = First.Language},
209200
ReduceScript = new InlineScript(First.Reduce) {Lang = First.Language}
210201
} &&
211202
new ScriptedMetricAggregation("total_commits")
@@ -226,7 +217,7 @@ protected override void ExpectResponse(ISearchResponse<Project> response)
226217
by_state_total.Should().NotBeNull();
227218
total_commits.Should().NotBeNull();
228219

229-
by_state_total.Value<IDictionary<string, int>>().Should().NotBeNull();
220+
by_state_total.Value<double>().Should().BeGreaterThan(0);
230221
total_commits.Value<int>().Should().BeGreaterThan(0);
231222
}
232223
}

src/Tests/Framework/Xunit/TestFrameworkExecutor.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@ public TestFrameworkExecutor(AssemblyName assemblyName, ISourceInformationProvid
1515

1616
protected override async void RunTestCases(IEnumerable<IXunitTestCase> testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions)
1717
{
18-
using (var assemblyRunner = new TestAssemblyRunner(TestAssembly, testCases, DiagnosticMessageSink, executionMessageSink, executionOptions))
19-
await assemblyRunner.RunAsync();
18+
try
19+
{
20+
using (var assemblyRunner = new TestAssemblyRunner(TestAssembly, testCases, DiagnosticMessageSink, executionMessageSink, executionOptions))
21+
await assemblyRunner.RunAsync();
22+
23+
}
24+
catch (Exception e)
25+
{
26+
Console.WriteLine(e);
27+
throw;
28+
}
2029
}
2130
}
2231
}

0 commit comments

Comments
 (0)