Skip to content

Commit

Permalink
Fix test, add missing OpenAPI doc generation
Browse files Browse the repository at this point in the history
  • Loading branch information
emerkle826 committed Oct 13, 2023
1 parent 3182d1d commit ef42f52
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 1 deletion.
87 changes: 86 additions & 1 deletion management-api-server/doc/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,91 @@
"summary" : "Returns active compactions"
}
},
"/api/v1/ops/tables/flush" : {
"post" : {
"operationId" : "flush_1",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/KeyspaceRequest"
}
}
}
},
"responses" : {
"202" : {
"content" : {
"text/plain" : {
"example" : "d69d1d95-9348-4460-95d2-ae342870fade",
"schema" : {
"type" : "string"
}
}
},
"description" : "Job ID for table flush process"
},
"400" : {
"content" : {
"text/plain" : {
"example" : "keyspace sys-tem does not exists",
"schema" : {
"type" : "string"
}
}
},
"description" : "Invalid flush request"
}
},
"summary" : "Flush one or more tables"
}
},
"/api/v1/ops/tables/garbagecollect" : {
"post" : {
"operationId" : "garbageCollect_1",
"parameters" : [ {
"in" : "query",
"name" : "tombstoneOption",
"schema" : {
"type" : "string"
}
} ],
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/KeyspaceRequest"
}
}
}
},
"responses" : {
"202" : {
"content" : {
"text/plain" : {
"example" : "d69d1d95-9348-4460-95d2-ae342870fade",
"schema" : {
"type" : "string"
}
}
},
"description" : "Job ID for table garbage collection process"
},
"400" : {
"content" : {
"text/plain" : {
"example" : "tombstoneOption must be either ROW or CELL",
"schema" : {
"type" : "string"
}
}
},
"description" : "Invalid table garbage collection request"
}
},
"summary" : "Remove deleted data from one or more tables"
}
},
"/api/v1/ops/tables/scrub" : {
"post" : {
"operationId" : "scrub_1",
Expand Down Expand Up @@ -2034,7 +2119,7 @@
"type" : "array",
"items" : {
"type" : "string",
"enum" : [ "ASYNC_SSTABLE_TASKS", "FULL_QUERY_LOGGING", "REBUILD", "ASYNC_UPGRADE_SSTABLE_TASK", "ASYNC_COMPACTION_TASKS", "ASYNC_SCRUB_TASK", "ASYNC_MOVE_TASK" ]
"enum" : [ "ASYNC_SSTABLE_TASKS", "FULL_QUERY_LOGGING", "REBUILD", "ASYNC_UPGRADE_SSTABLE_TASK", "ASYNC_COMPACTION_TASKS", "ASYNC_SCRUB_TASK", "ASYNC_MOVE_TASK", "ASYNC_GC_TASK", "ASYNC_FLUSH_TASK" ]
}
},
"mgmt_version" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,8 @@ public void testGarbageCollectAsync() throws Exception {
when(mockResultSet.one()).thenReturn(mockRow);
when(mockRow.getString(0)).thenReturn("0fe65b47-98c2-47d8-9c3c-5810c9988e10");

setpMockGetKeyspaces(context, "keyspace");

String requestAsJSON = WriterUtility.asString(keyspaceRequest, MediaType.APPLICATION_JSON);
MockHttpResponse response =
postWithBodyFullPath(
Expand Down Expand Up @@ -1199,6 +1201,8 @@ public void testFlushAsync() throws Exception {
when(mockResultSet.one()).thenReturn(mockRow);
when(mockRow.getString(0)).thenReturn("0fe65b47-98c2-47d8-9c3c-5810c9988e10");

setpMockGetKeyspaces(context, "keyspace");

String requestAsJSON = WriterUtility.asString(keyspaceRequest, MediaType.APPLICATION_JSON);
MockHttpResponse response =
postWithBodyFullPath("/api/v1/ops/tables/flush", requestAsJSON, context);
Expand Down Expand Up @@ -2222,4 +2226,15 @@ public void testMoveAsync_MissingNewToken() throws Exception {
verify(context.cqlService, never())
.executePreparedStatement(any(), eq("CALL NodeOps.move(?, ?)"), eq("1234"), eq(true));
}

private void setpMockGetKeyspaces(Context context, String keyspaceName) throws Exception {
ResultSet mockKeyspacesResultSet = mock(ResultSet.class);
Row mockKeyspacesRow = mock(Row.class);

when(context.cqlService.executePreparedStatement(any(), eq("CALL NodeOps.getKeyspaces()")))
.thenReturn(mockKeyspacesResultSet);

when(mockKeyspacesResultSet.one()).thenReturn(mockKeyspacesRow);
when(mockKeyspacesRow.getList(0, String.class)).thenReturn(Arrays.asList(keyspaceName));
}
}

0 comments on commit ef42f52

Please sign in to comment.