Skip to content

Commit

Permalink
Tweak migrations integraiton tests to have a stable sort (elastic#23265)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdavies authored and cqliu1 committed Sep 25, 2018
1 parent a261077 commit 214a7c3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions test/api_integration/apis/saved_objects/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,20 @@ export default ({ getService }) => {

// The docs in the original index are unchanged
assert.deepEqual(await fetchDocs({ callCluster, index: `${index}_1` }), [
{ id: 'foo:a', type: 'foo', foo: { name: 'Foo A' } },
{ id: 'foo:e', type: 'foo', foo: { name: 'Fooey' } },
{ id: 'bar:i', type: 'bar', bar: { nomnom: 33 } },
{ id: 'bar:o', type: 'bar', bar: { nomnom: 2 } },
{ id: 'baz:u', type: 'baz', baz: { title: 'Terrific!' } },
{ id: 'foo:a', type: 'foo', foo: { name: 'Foo A' } },
{ id: 'foo:e', type: 'foo', foo: { name: 'Fooey' } },
]);

// The docs in the alias have been migrated
assert.deepEqual(await fetchDocs({ callCluster, index }), [
{ id: 'foo:a', type: 'foo', migrationVersion: { foo: '1.0.0' }, foo: { name: 'FOO A' } },
{ id: 'foo:e', type: 'foo', migrationVersion: { foo: '1.0.0' }, foo: { name: 'FOOEY' } },
{ id: 'bar:i', type: 'bar', migrationVersion: { bar: '1.9.0' }, bar: { mynum: 68 } },
{ id: 'bar:o', type: 'bar', migrationVersion: { bar: '1.9.0' }, bar: { mynum: 6 } },
{ id: 'baz:u', type: 'baz', baz: { title: 'Terrific!' } },
{ id: 'foo:a', type: 'foo', migrationVersion: { foo: '1.0.0' }, foo: { name: 'FOO A' } },
{ id: 'foo:e', type: 'foo', migrationVersion: { foo: '1.0.0' }, foo: { name: 'FOOEY' } },
]);
});

Expand Down Expand Up @@ -129,16 +129,14 @@ export default ({ getService }) => {

// The index for the initial migration has not been destroyed...
assert.deepEqual(await fetchDocs({ callCluster, index: `${index}_2` }), [
{ id: 'foo:a', type: 'foo', migrationVersion: { foo: '1.0.0' }, foo: { name: 'FOO A' } },
{ id: 'foo:e', type: 'foo', migrationVersion: { foo: '1.0.0' }, foo: { name: 'FOOEY' } },
{ id: 'bar:i', type: 'bar', migrationVersion: { bar: '1.9.0' }, bar: { mynum: 68 } },
{ id: 'bar:o', type: 'bar', migrationVersion: { bar: '1.9.0' }, bar: { mynum: 6 } },
{ id: 'foo:a', type: 'foo', migrationVersion: { foo: '1.0.0' }, foo: { name: 'FOO A' } },
{ id: 'foo:e', type: 'foo', migrationVersion: { foo: '1.0.0' }, foo: { name: 'FOOEY' } },
]);

// The docs were migrated again...
assert.deepEqual(await fetchDocs({ callCluster, index }), [
{ id: 'foo:a', type: 'foo', migrationVersion: { foo: '2.0.1' }, foo: { name: 'FOO Av2' } },
{ id: 'foo:e', type: 'foo', migrationVersion: { foo: '2.0.1' }, foo: { name: 'FOOEYv2' } },
{
id: 'bar:i',
type: 'bar',
Expand All @@ -151,6 +149,8 @@ export default ({ getService }) => {
migrationVersion: { bar: '2.3.4' },
bar: { mynum: 6, name: 'NAME o' },
},
{ id: 'foo:a', type: 'foo', migrationVersion: { foo: '2.0.1' }, foo: { name: 'FOO Av2' } },
{ id: 'foo:e', type: 'foo', migrationVersion: { foo: '2.0.1' }, foo: { name: 'FOOEYv2' } },
]);
});

Expand Down Expand Up @@ -260,5 +260,6 @@ async function fetchDocs({ callCluster, index }) {
return hits.map(h => ({
...h._source,
id: h._id,
}));
}))
.sort(((a, b) => a.id.localeCompare(b.id)));
}

0 comments on commit 214a7c3

Please sign in to comment.