-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[teraslice, elasticsearch-store] opensearch2 mappings missing dynamic…
…s: false field (#3808) This PR makes the following changes: - updates `ensureNoTypeInMapping()` to copy `dynamic` property when removing type from mapping. - creates `method-helpers-spec.ts` and adds unit tests for `ensureNoTypeInMapping()`. - creates an e2e `storage-spec.ts` to confirm that the jobs state storage index mapping is created with `dynamic` set to `false`. - bump teraslice from version 2.6.2 to 2.6.3 - bump elasticsearch-api from 1.3.2 to 1.3.3 - bump elasticsearch-store from 1.3.2 to 1.3.3 - bump terafoundation from 1.5.3 to 1.5.4 Ref: #3809
- Loading branch information
Showing
10 changed files
with
174 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { TerasliceHarness } from '../../teraslice-harness.js'; | ||
import { TEST_OPENSEARCH } from '../../config.js'; | ||
|
||
describe('mappings', () => { | ||
let terasliceHarness: TerasliceHarness; | ||
|
||
beforeAll(async () => { | ||
terasliceHarness = new TerasliceHarness(); | ||
await terasliceHarness.init(); | ||
await terasliceHarness.resetState(); | ||
}); | ||
|
||
it('should have a jobs index with dynamic mapping false', async () => { | ||
const mapping = await terasliceHarness.client.indices.getMapping({ index: '*__jobs' }); | ||
const indexName = Object.keys(mapping)[0]; | ||
const searchVersion = terasliceHarness.client.__meta.version; | ||
if (!TEST_OPENSEARCH && searchVersion.charAt(0) === '6') { | ||
expect(mapping[indexName]).toMatchObject({ | ||
mappings: { | ||
job: expect.objectContaining({ dynamic: 'false' }) | ||
} | ||
}); | ||
} else { | ||
expect(mapping[indexName]).toMatchObject({ | ||
mappings: expect.objectContaining({ dynamic: 'false' }) | ||
}); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,5 +111,6 @@ export { | |
MINIO_ACCESS_KEY, | ||
MINIO_SECRET_KEY, | ||
ENCRYPT_MINIO, | ||
ROOT_CERT_PATH | ||
ROOT_CERT_PATH, | ||
TEST_OPENSEARCH | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
packages/elasticsearch-store/test/method-helpers-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import { ensureNoTypeInMapping } from '../src/elasticsearch-client/method-helpers/index.js'; | ||
|
||
describe('test method helpers', () => { | ||
describe('->ensureNoTypeInMapping', () => { | ||
describe('mappings with type', () => { | ||
const mappingsWithType = { | ||
myType: { | ||
_meta: { | ||
foo: 'foo' | ||
}, | ||
_all: { | ||
enabled: false | ||
}, | ||
dynamic: false, | ||
properties: { | ||
_context: { | ||
type: 'keyword' | ||
}, | ||
_created: { | ||
type: 'date' | ||
}, | ||
_updated: { | ||
type: 'date' | ||
}, | ||
_deleted: { | ||
type: 'boolean' | ||
}, | ||
_deleted_on: { | ||
type: 'date' | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const newMappings = ensureNoTypeInMapping(mappingsWithType); | ||
|
||
it('should remove myType wrapper object from mappingsWithType', () => { | ||
expect(newMappings.myType).toBe(undefined); | ||
}); | ||
|
||
it('should remove _all from mappingsWithType', () => { | ||
expect(newMappings._all).toBe(undefined); | ||
}); | ||
|
||
it('should include properties, _meta, and dynamic from mappingsWithType', () => { | ||
expect(newMappings).toMatchObject({ | ||
_meta: { | ||
foo: 'foo' | ||
}, | ||
dynamic: false, | ||
properties: { | ||
_context: { | ||
type: 'keyword', | ||
}, | ||
_created: { | ||
type: 'date', | ||
}, | ||
_deleted: { | ||
type: 'boolean', | ||
}, | ||
_deleted_on: { | ||
type: 'date', | ||
}, | ||
_updated: { | ||
type: 'date', | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('mappings without type', () => { | ||
const mappingsWithoutType = { | ||
_meta: { | ||
foo: 'foo' | ||
}, | ||
_all: { | ||
enabled: false | ||
}, | ||
dynamic: false, | ||
properties: { | ||
_context: { | ||
type: 'keyword' | ||
}, | ||
_created: { | ||
type: 'date' | ||
}, | ||
_updated: { | ||
type: 'date' | ||
}, | ||
_deleted: { | ||
type: 'boolean' | ||
}, | ||
_deleted_on: { | ||
type: 'date' | ||
} | ||
} | ||
}; | ||
|
||
const newMappings = ensureNoTypeInMapping(mappingsWithoutType); | ||
|
||
it('should remove _all from mappingsWithoutType', () => { | ||
expect(newMappings._all).toBe(undefined); | ||
}); | ||
|
||
it('should include properties, _meta, and dynamic from mappingsWithoutType', () => { | ||
expect(newMappings).toMatchObject({ | ||
_meta: { | ||
foo: 'foo' | ||
}, | ||
dynamic: false, | ||
properties: { | ||
_context: { | ||
type: 'keyword', | ||
}, | ||
_created: { | ||
type: 'date', | ||
}, | ||
_deleted: { | ||
type: 'boolean', | ||
}, | ||
_deleted_on: { | ||
type: 'date', | ||
}, | ||
_updated: { | ||
type: 'date', | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters