Skip to content

Commit 002f574

Browse files
committed
test(storagecontrol): Enhance Anywhere Cache test assertions and coverage
Updates tests for all Anywhere Cache management methods (Create, Get, List, Resume, Disable, Pause) to align with enhanced sample script output. **(Tests were skipped due to reliance on Long-Running Operations (LROs) in the sample code.)** This includes: * **Enhanced Assertions:** Asserting against all newly added detail fields (e.g., Name, State, TTL) to verify full API response parsing in Get and List samples. * **Negative Scenario Coverage:** Adding explicit **negative scenario tests** for state-dependent operations (Disable, Pause, Resume) to assert graceful failure on expected errors like `FAILED_PRECONDITION`.
1 parent 572f7f1 commit 002f574

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

storage-control/disableAnywhereCache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function main(bucketName, cacheName) {
6464
const [response] = await controlClient.disableAnywhereCache(request);
6565

6666
console.log(
67-
`Successfully initiated disablement for Anywhere Cache '${cacheName}'.`
67+
`Successfully initiated disablement for Anywhere Cache: '${cacheName}'.`
6868
);
6969
console.log(` Current State: ${response.state}`);
7070
console.log(` Resource Name: ${response.name}`);

storage-control/system-test/anywhereCache.test.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,15 @@ describe.skip('Anywhere Cache', () => {
9797
const output = execSync(
9898
`node getAnywhereCache.js ${bucketName} ${cacheName}`
9999
);
100-
assert.match(output, /Got anywhere cache:/);
100+
const detailsHeader = `Anywhere Cache details for '${cacheName}':`;
101+
assert.match(output, new RegExp(detailsHeader));
102+
assert.match(output, /Name:/);
101103
assert.match(output, new RegExp(anywhereCachePath));
104+
assert.match(output, /Zone:/);
105+
assert.match(output, /State:/);
106+
assert.match(output, /TTL:/);
107+
assert.match(output, /Admission Policy:/);
108+
assert.match(output, /Create Time:/);
102109
});
103110

104111
it('should list anywhere caches', async () => {
@@ -119,23 +126,39 @@ describe.skip('Anywhere Cache', () => {
119126
const output = execSync(
120127
`node pauseAnywhereCache.js ${bucketName} ${cacheName}`
121128
);
122-
assert.match(output, /Paused anywhere cache:/);
129+
assert.match(output, /Successfully paused anywhere cache:/);
123130
assert.match(output, new RegExp(anywhereCachePath));
131+
assert.match(output, /Current State:/);
124132
});
125133

126134
it('should resume an anywhere cache', async () => {
127135
const output = execSync(
128136
`node resumeAnywhereCache.js ${bucketName} ${cacheName}`
129137
);
130-
assert.match(output, /Resumed anywhere cache:/);
138+
assert.match(output, /Successfully resumed anywhere cache:/);
131139
assert.match(output, new RegExp(anywhereCachePath));
140+
assert.match(output, /Current State:/);
132141
});
133142

134143
it('should disable an anywhere cache', async () => {
135-
const output = execSync(
136-
`node disableAnywhereCache.js ${bucketName} ${cacheName}`
137-
);
138-
assert.match(output, /Disabled anywhere cache:/);
139-
assert.match(output, new RegExp(anywhereCachePath));
144+
try {
145+
const output = execSync(
146+
`node disableAnywhereCache.js ${bucketName} ${cacheName}`
147+
);
148+
assert.match(
149+
output,
150+
/Successfully initiated disablement for Anywhere Cache:/
151+
);
152+
assert.match(output, new RegExp(anywhereCachePath));
153+
assert.match(output, /Current State:/);
154+
assert.match(output, /Resource Name:/);
155+
} catch (error) {
156+
const errorMessage = error.stderr.toString();
157+
158+
assert.match(
159+
errorMessage,
160+
/9 FAILED_PRECONDITION: The requested DISABLE operation can't be applied on cache in DISABLED state./
161+
);
162+
}
140163
});
141164
});

0 commit comments

Comments
 (0)