Skip to content

Commit a9aff3d

Browse files
committed
all yaml tests (including cat succeeding) for 1.0 generated client and yaml testS
1 parent 823a197 commit a9aff3d

File tree

60 files changed

+2003
-1309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2003
-1309
lines changed

src/CodeGeneration/CodeGeneration.LowLevelClient/ApiGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace CodeGeneration.LowLevelClient
1616
{
1717
public static class ApiGenerator
1818
{
19-
private readonly static string _listingUrl = "https://github.com/elasticsearch/elasticsearch/tree/1.0/rest-api-spec/api";
20-
private readonly static string _rawUrlPrefix = "https://raw.github.com/elasticsearch/elasticsearch/1.0/rest-api-spec/api/";
19+
private readonly static string _listingUrl = "https://github.com/elasticsearch/elasticsearch/tree/v1.0.0/rest-api-spec/api";
20+
private readonly static string _rawUrlPrefix = "https://raw.github.com/elasticsearch/elasticsearch/v1.0.0/rest-api-spec/api/";
2121
private readonly static string _nestFolder = @"..\..\..\..\..\src\Nest\";
2222
private readonly static string _viewFolder = @"..\..\Views\";
2323
private readonly static string _cacheFolder = @"..\..\Cache\";

src/CodeGeneration/CodeGeneration.LowLevelClient/Views/RawElasticClient.Generated.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace Nest
4545
{
4646
@foreach (ApiUrlPart part in method.Parts.Where(p=>p.Name != "body").ToList())
4747
{
48-
<text>@(part.Name).ThrowIfNull("@part.Name");</text>
48+
<text>@(part.Name).@(part.Type == "string" || part.Type == "list" ? "ThrowIfNullOrEmpty" : "ThrowIfNull")("@part.Name");</text>
4949
}
5050
@if (method.Parts.Any())
5151
{

src/CodeGeneration/CodeGeneration.YamlTestsRunner/Domain/DoStep.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Text.RegularExpressions;
5+
using CsQuery.ExtensionMethods.Internal;
56

67
namespace CodeGeneration.YamlTestsRunner.Domain
78
{
@@ -64,13 +65,13 @@ private void PatchCall()
6465
this.QueryString = new Dictionary<string, object>();
6566
this.QueryString.Add("op_type", "create");
6667
}
67-
else if (
68-
this.Call == "indices.delete_alias"
68+
else if (!this.Catch.IsNullOrEmpty() &&
69+
(this.Call == "indices.delete_alias"
6970
|| this.Call == "indices.delete_warmer"
7071
|| this.Call == "indices.delete_mapping"
7172
|| this.Call == "indices.put_alias"
7273
|| this.Call == "indices.put_warmer"
73-
|| this.Call == "indices.put_mapping")
74+
|| this.Call == "indices.put_mapping"))
7475
{
7576
Func<string, bool> m = (s) => Regex.IsMatch(this.TestDescription, "(blank|empty|missing) " + s);
7677

@@ -172,16 +173,6 @@ private IEnumerable<string> CsharpArguments(string call, bool inverse = false)
172173
.Select(ki => ki.Key);
173174
return csharpArguments.ToList();
174175
}
175-
private int MethodPreference(string method)
176-
{
177-
var postBoost = this.Body != null ? 10 : 0;
178-
var getBoost = this.Body == null ? 10 : 0;
179-
180-
//if (method.Contains("Post(")) return 5 + postBoost;
181-
//if (method.Contains("Put(")) return 4 + postBoost;
182-
//if (method.Contains("Get(")) return 3 + getBoost;
183-
//if (method.Contains("Head(")) return 2 + postBoost;
184-
return 0;
185-
}
176+
186177
}
187178
}

src/CodeGeneration/CodeGeneration.YamlTestsRunner/Domain/TestSuite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private static string PropertyPath(string value)
141141
value = value.Replace(@"\.", "|||");
142142
value = Regex.Replace(value, @"\.([^\.]+)", m => "[" + m.Value.Trim('.').SurroundWithQuotes() + "]");
143143
value = value.Replace("|||", ".");
144-
return "_responseDictionary" + value;
144+
return "_response" + value;
145145
}
146146
return "_response" + value;
147147
}

src/CodeGeneration/CodeGeneration.YamlTestsRunner/Extensions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ public static string SerializeToAnonymousObject(this object o, string indentatio
110110
serializer.Serialize(writer, o);
111111
writer.Close();
112112
//anonymousify the json
113-
var anon = stringWriter.ToString().Replace("{", "new {").Replace("]", "}").Replace("[", "new [] {").Replace(":", "=");
113+
var anon = stringWriter.ToString()
114+
.Replace("{", "new {")
115+
.Replace("]", "}")
116+
.Replace("[", "new [] {")
117+
.Replace(":", "=")
118+
.Replace("http=", "http:");
114119
//match indentation of the view
115120
anon = Regex.Replace(anon, @"^(\s+)?", (m) =>
116121
{

src/CodeGeneration/CodeGeneration.YamlTestsRunner/YamlTestsGenerator.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ namespace CodeGeneration.YamlTestsRunner
2424
using YamlTestSuite = Dictionary<string, object>;
2525
public static class YamlTestsGenerator
2626
{
27-
private readonly static string _listingUrl = "https://github.com/elasticsearch/elasticsearch/tree/1.0/rest-api-spec/test";
28-
private readonly static string _rawUrlPrefix = "https://raw.github.com/elasticsearch/elasticsearch/1.0/rest-api-spec/test/";
27+
private readonly static string _listingUrl = "https://github.com/elasticsearch/elasticsearch/tree/v1.0.0/rest-api-spec/test";
28+
private readonly static string _rawUrlPrefix = "https://raw.github.com/elasticsearch/elasticsearch/v1.0.0/rest-api-spec/test/";
2929
private readonly static string _testProjectFolder = @"..\..\..\..\..\src\Tests\Nest.Tests.Integration.Yaml\";
3030
private readonly static string _rawClientInterface = @"..\..\..\..\..\src\Nest\IRawElasticClient.generated.cs";
3131
private readonly static string _viewFolder = @"..\..\Views\";
@@ -128,13 +128,14 @@ private static void PatchDefinition(YamlDefinition yamlDefinition, string folder
128128
if (file == "20_fields_pre_0.90.3.yaml")
129129
yamlDefinition.Suites.First().Description = "Fields Pre 0.90.3";
130130

131-
var setupRoutine = yamlDefinition.Suites.FirstOrDefault(s => s.Description == "setup");
131+
var setupRoutine = yamlDefinition.Suites
132+
.FirstOrDefault(s => s.Description.Contains("setup"));
132133
if (setupRoutine != null)
133134
{
134135
yamlDefinition.SetupSuite = setupRoutine;
135136
foreach (var suite in yamlDefinition.Suites)
136137
suite.HasSetup = true;
137-
yamlDefinition.Suites = yamlDefinition.Suites.Where(s => s.Description != "setup");
138+
yamlDefinition.Suites = yamlDefinition.Suites.Where(s => !s.Description.Contains("setup"));
138139
}
139140
}
140141

src/Nest.Connection.Thrift/ThriftConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private ConnectionStatus Execute(RestRequest restRequest)
263263

264264
var result = client.execute(restRequest);
265265
if (result.Status == Status.OK || result.Status == Status.CREATED || result.Status == Status.ACCEPTED)
266-
return new ConnectionStatus(this._connectionSettings, DecodeStr(result.Body));
266+
return new ConnectionStatus(this._connectionSettings, result.Body);
267267
else
268268
{
269269
var connectionException = new ConnectionException(

src/Nest/DSL/_Descriptors.generated.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Nest.Resolvers;
77
///This file lays the base for all the descriptors based on the query string parameters in the spec for IElasticClient.
88
///This file is automatically generated from https://github.com/elasticsearch/elasticsearch-rest-api-spec
9-
///Generated of commit 7f80a0b723
9+
///Generated of commit
1010

1111
namespace Nest
1212
{

src/Nest/Domain/Connection/AsyncRequestOperation.cs

Lines changed: 0 additions & 143 deletions
This file was deleted.

src/Nest/Domain/Connection/Connection.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ protected virtual HttpWebRequest CreateWebRequest(string path, string method)
161161
var url = this._CreateUriString(path);
162162

163163
var myReq = (HttpWebRequest)WebRequest.Create(url);
164-
myReq.Accept = "application/json";
165-
myReq.ContentType = "application/json";
166-
164+
if (!path.StartsWith("_cat"))
165+
{
166+
myReq.Accept = "application/json";
167+
myReq.ContentType = "application/json";
168+
}
167169
var timeout = this._ConnectionSettings.Timeout;
168170
myReq.Timeout = timeout; // 1 minute timeout.
169171
myReq.ReadWriteTimeout = timeout; // 1 minute timeout.
@@ -188,10 +190,10 @@ protected virtual ConnectionStatus DoSynchronousRequest(HttpWebRequest request,
188190
{
189191
using (var response = (HttpWebResponse)request.GetResponse())
190192
using (var responseStream = response.GetResponseStream())
191-
using (var streamReader = new StreamReader(responseStream))
193+
using (var memoryStream = new MemoryStream())
192194
{
193-
var result = streamReader.ReadToEnd();
194-
cs = new ConnectionStatus(this._ConnectionSettings, result)
195+
responseStream.CopyTo(memoryStream);
196+
cs = new ConnectionStatus(this._ConnectionSettings, memoryStream.ToArray())
195197
{
196198
Request = requestData,
197199
RequestUrl = request.RequestUri.ToString(),
@@ -288,21 +290,20 @@ private IEnumerable<Task> _AsyncSteps(HttpWebRequest request, TaskCompletionSour
288290
// Get the response stream
289291
using (var response = (HttpWebResponse)getResponse.Result)
290292
using (var responseStream = response.GetResponseStream())
293+
using (var memoryStream = new MemoryStream())
291294
{
292295
// Copy all data from the response stream
293-
var output = new MemoryStream();
294296
var buffer = new byte[BUFFER_SIZE];
295297
while (responseStream != null)
296298
{
297299
var read = Task<int>.Factory.FromAsync(responseStream.BeginRead, responseStream.EndRead, buffer, 0, BUFFER_SIZE, null);
298300
yield return read;
299301
if (read.Result == 0) break;
300-
output.Write(buffer, 0, read.Result);
302+
memoryStream.Write(buffer, 0, read.Result);
301303
}
302304

303305
// Decode the data and store the result
304-
var result = output.ToArray().Utf8String();
305-
var cs = new ConnectionStatus(this._ConnectionSettings, result)
306+
var cs = new ConnectionStatus(this._ConnectionSettings, memoryStream.ToArray())
306307
{
307308
Request = data.Utf8String(),
308309
RequestUrl = request.RequestUri.ToString(),
@@ -312,9 +313,7 @@ private IEnumerable<Task> _AsyncSteps(HttpWebRequest request, TaskCompletionSour
312313
tracer.SetResult(cs);
313314
_ConnectionSettings.ConnectionStatusHandler(cs);
314315
}
315-
yield break;
316316
}
317-
318317
}
319318

320319
public void Iterate(IEnumerable<Task> asyncIterator, TaskCompletionSource<ConnectionStatus> tcs)

0 commit comments

Comments
 (0)