Skip to content

Commit 509c2ed

Browse files
committed
chore: python
1 parent c6d4a7e commit 509c2ed

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

scripts/cts/testServer/replaceAllObjectsWithTransformation.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const raowtState: Record<
1010
string,
1111
{
1212
copyCount: number;
13+
deleteCount: number;
1314
pushCount: number;
1415
tmpIndexName: string;
1516
waitTaskCount: number;
@@ -33,6 +34,27 @@ function addRoutes(app: Express): void {
3334
}),
3435
);
3536

37+
app.delete('/1/indexes/:indexName', (req, res) => {
38+
expect(req.params.indexName).to.match(/^cts_e2e_replace_all_objects_with_transformation_(.*)$/);
39+
40+
const lang = req.params.indexName.replace('cts_e2e_replace_all_objects_with_transformation_', '');
41+
if (!raowtState[lang] || raowtState[lang].successful) {
42+
raowtState[lang] = {
43+
copyCount: 0,
44+
pushCount: 0,
45+
deleteCount: 1,
46+
waitTaskCount: 0,
47+
tmpIndexName: req.body.destination,
48+
waitingForFinalWaitTask: false,
49+
successful: false,
50+
};
51+
} else {
52+
raowtState[lang].deleteCount++;
53+
}
54+
55+
res.json({ taskID: 123 + raowtState[lang].copyCount, deletedAt: '2021-01-01T00:00:00.000Z' });
56+
});
57+
3658
app.post('/1/indexes/:indexName/operation', (req, res) => {
3759
expect(req.params.indexName).to.match(/^cts_e2e_replace_all_objects_with_transformation_(.*)$/);
3860

@@ -47,6 +69,7 @@ function addRoutes(app: Express): void {
4769
raowtState[lang] = {
4870
copyCount: 1,
4971
pushCount: 0,
72+
deleteCount: 0,
5073
waitTaskCount: 0,
5174
tmpIndexName: req.body.destination,
5275
waitingForFinalWaitTask: false,
@@ -123,10 +146,17 @@ function addRoutes(app: Express): void {
123146

124147
raowtState[lang].waitTaskCount++;
125148
if (raowtState[lang].waitingForFinalWaitTask) {
126-
expect(req.params.taskID).to.equal('777');
127-
expect(raowtState[lang].waitTaskCount).to.equal(3);
128-
129149
raowtState[lang].successful = true;
150+
expect(req.params.taskID).to.equal('777');
151+
expect(raowtState[lang]).to.deep.equal({
152+
copyCount: 2,
153+
pushCount: 10,
154+
deleteCount: 0,
155+
waitTaskCount: 3,
156+
tmpIndexName: req.params.indexName,
157+
waitingForFinalWaitTask: true,
158+
successful: true,
159+
});
130160
}
131161

132162
res.json({ status: 'published', updatedAt: '2021-01-01T00:00:00.000Z' });

templates/python/ingestion_helpers.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
records: List[PushTaskRecords] = []
1515
responses: List[WatchResponse] = []
1616
wait_batch_size = batch_size // 10
17+
if wait_batch_size == 0:
18+
wait_batch_size = batch_size
1719
for i, obj in enumerate(objects):
1820
records.append(obj) # pyright: ignore
1921
if len(records) == batch_size or i == len(objects) - 1:

0 commit comments

Comments
 (0)