Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 4 additions & 7 deletions .ci/doc/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,28 @@ version: '3'

services:
kuzzle:
image: kuzzleio/kuzzle:1
image: kuzzleio/kuzzle:2
ports:
- "7512:7512"
cap_add:
- SYS_PTRACE
depends_on:
- redis
- elasticsearch
container_name: kuzzle
environment:
- kuzzle_services__db__client__host=http://elasticsearch:9200
- kuzzle_services__storageEngine__client__node=http://elasticsearch:9200
- kuzzle_services__internalCache__node__host=redis
- kuzzle_services__memoryStorage__node__host=redis
- kuzzle_services__storageEngine__commonMapping__dynamic=true
- NODE_ENV=production

redis:
image: redis:5

elasticsearch:
image: kuzzleio/elasticsearch:5.6.10
image: kuzzleio/elasticsearch:7.4.0
ulimits:
nofile: 65536
environment:
- cluster.name=kuzzle
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"

doc-tests:
image: kuzzleio/snippets-tests
Expand Down
10 changes: 4 additions & 6 deletions .ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'

services:
kuzzle:
image: kuzzleio/kuzzle:1
image: kuzzleio/kuzzle:2
ports:
- "7512:7512"
cap_add:
Expand All @@ -11,21 +11,19 @@ services:
- redis
- elasticsearch
environment:
- kuzzle_services__db__client__host=http://elasticsearch:9200
- kuzzle_services__storageEngine__client__node=http://elasticsearch:9200
- kuzzle_services__internalCache__node__host=redis
- kuzzle_services__memoryStorage__node__host=redis
- kuzzle_services__storageEngine__commonMapping__dynamic=true
- NODE_ENV=production

redis:
image: redis:5

elasticsearch:
image: kuzzleio/elasticsearch:5.6.10
image: kuzzleio/elasticsearch:7.4.0
ulimits:
nofile: 65536
environment:
- cluster.name=kuzzle
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"

volumes:
snippets:
30 changes: 21 additions & 9 deletions Kuzzle.Tests/API/Controllers/CollectionControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,7 @@ public async void ExistsAsyncTest(bool result) {
public async void GetMappingAsyncTest() {
var expected = JObject.Parse(@"
{
foo: {
mappings: {
bar: {
some: 'mappings'
}
}
}
some: 'mappings'
}");

_api.SetResult(new JObject { { "result", expected } });
Expand All @@ -100,7 +94,7 @@ public async void GetMappingAsyncTest() {
});

Assert.Equal(
expected["foo"]["mappings"]["bar"],
expected,
mappings,
new JTokenEqualityComparer());
}
Expand Down Expand Up @@ -297,15 +291,33 @@ public async void ValidateSpecificationsAsyncTest(bool response) {
var payload = new JObject { { "foo", "bar" } };

bool result =
await _collectionController.ValidateSpecificationsAsync(payload);
await _collectionController.ValidateSpecificationsAsync(
"foo", "bar", payload);

_api.Verify(new JObject {
{ "controller", "collection" },
{ "action", "validateSpecifications" },
{ "index", "foo" },
{ "collection", "bar" },
{ "body", payload }
});

Assert.Equal(response, result);
}

[Fact]
public async void RefreshAsyncTest() {
_api.SetResult(@"{result: null}");

await _collectionController.RefreshAsync("foo", "bar");

_api.Verify(new JObject {
{ "controller", "collection" },
{ "action", "refresh" },
{ "index", "foo" },
{ "collection", "bar" },
});
}

}
}
40 changes: 21 additions & 19 deletions Kuzzle.Tests/API/Controllers/DocumentControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ public async void GetAsync() {
[InlineData(true)]
[InlineData(false)]
public async void MCreateAsync(bool refresh) {
_api.SetResult("{ result: { hits: [1, 2, 3] } }");
_api.SetResult("{ result: { successes: [1, 2, 3], errors: [] } }");

var documents = new JArray { "foo", "bar", "baz" };

JArray result = await _documentController.MCreateAsync(
JObject result = await _documentController.MCreateAsync(
"foo",
"bar",
documents,
Expand All @@ -212,7 +212,7 @@ public async void MCreateAsync(bool refresh) {
_api.Verify(expected);

Assert.Equal(
new JArray { 1, 2, 3 },
JObject.Parse("{ successes: [1, 2, 3], errors: [] }"),
result,
new JTokenEqualityComparer());
}
Expand All @@ -221,11 +221,11 @@ public async void MCreateAsync(bool refresh) {
[InlineData(true)]
[InlineData(false)]
public async void MCreateOrReplaceAsync(bool refresh) {
_api.SetResult("{ result: { hits: [1, 2, 3] } }");
_api.SetResult("{ result: { successes: [1, 2, 3], errors: [] } }");

var documents = new JArray { "foo", "bar", "baz" };

JArray result = await _documentController.MCreateOrReplaceAsync(
JObject result = await _documentController.MCreateOrReplaceAsync(
"foo",
"bar",
documents,
Expand All @@ -245,7 +245,7 @@ public async void MCreateOrReplaceAsync(bool refresh) {
_api.Verify(expected);

Assert.Equal(
new JArray { 1, 2, 3 },
JObject.Parse("{ successes: [1, 2, 3], errors: [] }"),
result,
new JTokenEqualityComparer());
}
Expand All @@ -254,11 +254,11 @@ public async void MCreateOrReplaceAsync(bool refresh) {
[InlineData(true)]
[InlineData(false)]
public async void MDeleteAsync(bool refresh) {
_api.SetResult("{ result: ['foo', 'bar', 'baz'] }");
_api.SetResult("{ result: { successes: [1, 2, 3], errors: [] } }");

var ids = new string[] { "foo", "bar", "baz" };

string[] result = await _documentController.MDeleteAsync(
JObject result = await _documentController.MDeleteAsync(
"foo",
"bar",
ids,
Expand All @@ -277,16 +277,19 @@ public async void MDeleteAsync(bool refresh) {

_api.Verify(expected);

Assert.Equal(ids, result);
Assert.Equal(
JObject.Parse("{ successes: [1, 2, 3], errors: [] }"),
result,
new JTokenEqualityComparer());
}

[Fact]
public async void MGetAsyncTest() {
_api.SetResult("{ result: { hits: ['foo', 'bar', 'baz'] } }");
_api.SetResult("{ result: { successes: ['foo', 'bar', 'baz'], errors: [] } }");

var ids = new JArray { "foo", "bar", "baz" };

JArray result = await _documentController.MGetAsync(
JObject result = await _documentController.MGetAsync(
"foo", "bar", ids);

var expected = new JObject {
Expand All @@ -301,7 +304,7 @@ public async void MGetAsyncTest() {

_api.Verify(expected);
Assert.Equal(
new JArray { "foo", "bar", "baz" },
JObject.Parse("{ successes: ['foo', 'bar', 'baz'], errors: [] }"),
result,
new JTokenEqualityComparer());
}
Expand All @@ -310,11 +313,11 @@ public async void MGetAsyncTest() {
[InlineData(true)]
[InlineData(false)]
public async void MReplaceAsync(bool refresh) {
_api.SetResult("{ result: { hits: [1, 2, 3] } }");
_api.SetResult("{ result: { successes: [1, 2, 3], errors: [] } }");

var documents = new JArray { "foo", "bar", "baz" };

JArray result = await _documentController.MReplaceAsync(
JObject result = await _documentController.MReplaceAsync(
"foo",
"bar",
documents,
Expand All @@ -334,7 +337,7 @@ public async void MReplaceAsync(bool refresh) {
_api.Verify(expected);

Assert.Equal(
new JArray { 1, 2, 3 },
JObject.Parse("{ successes: [1, 2, 3], errors: [] }"),
result,
new JTokenEqualityComparer());
}
Expand All @@ -346,11 +349,11 @@ public async void MReplaceAsync(bool refresh) {
MemberType = typeof(DocumentControllerGenerators))
]
public async void MUpdateAsyncTest(bool refresh, int? retries) {
_api.SetResult("{ result: { hits: [1, 2, 3] } }");
_api.SetResult("{ result: { successes: [1, 2, 3], errors: [] } }");

var documents = new JArray { "foo", "bar", "baz" };

JArray result;
JObject result;

if (retries == null) {
result = await _documentController.MUpdateAsync(
Expand Down Expand Up @@ -381,9 +384,8 @@ public async void MUpdateAsyncTest(bool refresh, int? retries) {
expected.Add("retryOnConflict", retries ?? 0);

_api.Verify(expected);

Assert.Equal(
new JArray { 1, 2, 3 },
JObject.Parse("{ 'successes': [1, 2, 3], 'errors': [] }"),
result,
new JTokenEqualityComparer());
}
Expand Down
Loading