Skip to content

Commit 46473c0

Browse files
authored
feat: Support capabilities in metadata api (#347)
* Support capabilities in metadata api Signed-off-by: Deepanshu Agarwal <[email protected]> * Add E2E test http/grpc Signed-off-by: Deepanshu Agarwal <[email protected]> * Correction Signed-off-by: Deepanshu Agarwal <[email protected]> * Fix error Signed-off-by: Deepanshu Agarwal <[email protected]> * Name correction Signed-off-by: Deepanshu Agarwal <[email protected]> * Comment out grpc E2E test Signed-off-by: Deepanshu Agarwal <[email protected]> * Fix issue Signed-off-by: Deepanshu Agarwal <[email protected]> Signed-off-by: Deepanshu Agarwal <[email protected]>
1 parent 07b9969 commit 46473c0

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

src/implementation/Client/GRPCClient/metadata.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ export default class GRPCClientMetadata implements IClientMetadata {
4949
components: res.getRegisteredComponentsList().map(c => ({
5050
name: c.getName(),
5151
type: c.getType(),
52-
version: c.getVersion()
52+
version: c.getVersion(),
53+
capabilities: c.getCapabilitiesList()
5354
}))
5455
}
5556

src/types/metadata/GetMetadataResponse.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ type MetadataComponent = {
2929
name: string;
3030
type: string;
3131
version: string;
32+
capabilities: Array<string>;
3233
}

test/e2e/grpc/client.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,26 @@ describe('grpc/client', () => {
120120
// expect(res.components.length).toBeGreaterThan(0);
121121
});
122122

123+
// Commenting out as it would need next version of Dapr to be used in E2E test.
124+
// It would specifically require changes from https://github.com/dapr/dapr/pull/5052
125+
// it('should be able to get the capabilities of components via metadata call', async () => {
126+
// const res = await client.metadata.get();
127+
// const redisStateComponent = res.components.filter( (component) => component.name == "state-redis" );
128+
// const expectedRedisStateCapabilities = [ 'ETAG', 'TRANSACTIONAL', 'QUERY_API', 'ACTOR' ];
129+
// expect(res.id.length).toBeGreaterThan(0);
130+
// expect(res.components.length).toBeGreaterThan(0);
131+
// expect(redisStateComponent.length).toEqual(1)
132+
// expect(redisStateComponent[0].capabilities).toEqual(expect.arrayContaining(expectedRedisStateCapabilities));
133+
// });
134+
135+
123136
it('should be able to set a custom metadata value of the Dapr sidecar', async () => {
124137
await client.metadata.set("testKey", "Hello World");
125138

126139
const res = await client.metadata.get();
127140

128141
// app id is not set in grpc?
129142
// expect(res.id.length).toBeGreaterThan(0);
130-
// expect(res.id.length).toBeGreaterThan(0);
131143
// expect(res.components.length).toBeGreaterThan(0);
132144
expect(res.extended["testKey"]).toEqual("Hello World");
133145
});

test/e2e/http/client.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ describe('http/client', () => {
5252
expect(res.components.length).toBeGreaterThan(0);
5353
});
5454

55+
it('should be able to get the capabilities of components via metadata call', async () => {
56+
const res = await client.metadata.get();
57+
const redisStateComponent = res.components.filter( (component) => component.name == "state-redis" );
58+
const expectedRedisStateCapabilities = [ 'ETAG', 'TRANSACTIONAL', 'QUERY_API', 'ACTOR' ];
59+
expect(res.id.length).toBeGreaterThan(0);
60+
expect(res.components.length).toBeGreaterThan(0);
61+
expect(redisStateComponent.length).toEqual(1)
62+
expect(redisStateComponent[0].capabilities).toEqual(expect.arrayContaining(expectedRedisStateCapabilities))
63+
});
64+
65+
5566
it('should be able to set a custom metadata value of the Dapr sidecar', async () => {
5667
await client.metadata.set("testKey", "Hello World");
5768

0 commit comments

Comments
 (0)