You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by yz...@apache.org on 2026/10/17 00:46:23 UTC
(polaris-tools) branch main updated: Benchmark: Add delete simulation for benchmark (#286)
This is an automated email from the ASF dual-hosted git repository.
MonkeyCanCode pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris-tools.git
The following commit(s) were added to refs/heads/main by this push:
new b10f2cf Benchmark: Add delete simulation for benchmark (#286)
b10f2cf is described below
commit b10f2cf564de33b8be6b5a6a3363e9f5c3213b19
Author: Yong Zheng <yo...@gmail.com>
AuthorDate: Fri Oct 16 17:46:17 2026 -0700
Benchmark: Add delete simulation for benchmark (#286)
---
Makefile | 4 +
benchmarks/Makefile | 7 +
benchmarks/README.md | 4 +
.../src/gatling/resources/benchmark-defaults.conf | 26 ++++
.../polaris/benchmarks/NAryTreeBuilder.scala | 20 ++-
.../benchmarks/actions/CatalogActions.scala | 13 ++
.../benchmarks/actions/NamespaceActions.scala | 50 ++++--
.../polaris/benchmarks/actions/TableActions.scala | 18 +++
.../polaris/benchmarks/actions/ViewActions.scala | 11 ++
.../benchmarks/parameters/BenchmarkConfig.scala | 7 +
.../parameters/DeleteTreeDatasetParameters.scala | 41 +++++
.../benchmarks/parameters/WorkloadParameters.scala | 1 +
.../benchmarks/simulations/DeleteTreeDataset.scala | 168 +++++++++++++++++++++
13 files changed, 351 insertions(+), 19 deletions(-)
diff --git a/Makefile b/Makefile
index 31c4f6d..adf911a 100644
--- a/Makefile
+++ b/Makefile
@@ -39,6 +39,10 @@ benchmarks-create-commits-simulation: ## Run create commits simulation
benchmarks-create-dataset-simulation: ## Run create dataset simulation
@$(MAKE) -C benchmarks create-dataset-simulation
+.PHONY: benchmarks-delete-dataset-simulation
+benchmarks-delete-dataset-simulation: ## Run delete dataset simulation
+ @$(MAKE) -C benchmarks delete-dataset-simulation
+
.PHONY: benchmarks-read-simulation
benchmarks-read-simulation: ## Run read simulation
@$(MAKE) -C benchmarks read-simulation
diff --git a/benchmarks/Makefile b/benchmarks/Makefile
index 7ece33c..fe2997d 100644
--- a/benchmarks/Makefile
+++ b/benchmarks/Makefile
@@ -59,6 +59,13 @@ create-dataset-simulation: benchmarks-pre-requisite ## Run create dataset simula
-Dconfig.file=${APPLICATION_CONF_PATH}
@echo "--- Create dataset simulation completed ---"
+.PHONY: delete-dataset-simulation
+delete-dataset-simulation: benchmarks-pre-requisite ## Run delete dataset simulation
+ @echo "--- Running delete dataset simulation ---"
+ @./gradlew gatlingRun --simulation org.apache.polaris.benchmarks.simulations.DeleteTreeDataset \
+ -Dconfig.file=${APPLICATION_CONF_PATH}
+ @echo "--- Delete dataset simulation completed ---"
+
.PHONY: read-simulation
read-simulation: benchmarks-pre-requisite ## Run read simulation
@echo "--- Running read simulation ---"
diff --git a/benchmarks/README.md b/benchmarks/README.md
index eb5d027..026223f 100644
--- a/benchmarks/README.md
+++ b/benchmarks/README.md
@@ -24,6 +24,7 @@ Benchmarks for the Polaris service using Gatling.
## Available Benchmarks
- `org.apache.polaris.benchmarks.simulations.CreateTreeDataset`: Creates a test dataset with a specific structure. It is a write-only workload designed to populate the system for subsequent benchmarks.
+- `org.apache.polaris.benchmarks.simulations.DeleteTreeDataset`: Deletes the test dataset created by CreateTreeDataset. Tables are dropped with purge as controlled by the `delete-tree-dataset.purge` configuration (default `false`). When enabled, dropping a table also removes its data and metadata files and requires DROP_WITH_PURGE_ENABLED to be enabled on the server side. Views are always dropped without purge; their metadata purging is governed by the server-side PURGE_VIEW_METADATA_ON_ [...]
- `org.apache.polaris.benchmarks.simulations.ReadTreeDataset`: Performs read-only operations to fetch namespaces, tables, and views. Some attributes of the objects are also fetched. This benchmark is intended to be used against a Polaris instance with a pre-existing tree dataset. It has no side effects on the dataset and can be executed multiple times without any issues.
- `org.apache.polaris.benchmarks.simulations.ReadUpdateTreeDataset`: Performs read and update operations against a Polaris instance populated with a test dataset. It is a read/write workload that can be used to test the system's ability to handle concurrent read and update operations. It is not destructive and does not prevent subsequent executions of `ReadTreeDataset` or `ReadUpdateTreeDataset`.
- `org.apache.polaris.benchmarks.simulations.CreateCommits`: Creates table and view commits at configurable rates. This benchmark is useful for testing the system's ability to handle table and view commits and can be used to generate a history of thousands of commits for both tables and views.
@@ -144,6 +145,9 @@ make create-commits-simulation
# Weighted workload
make weighted-workload-simulation
+
+# Dataset deletion
+make delete-dataset-simulation
```
A message will show the location of the Gatling report:
diff --git a/benchmarks/src/gatling/resources/benchmark-defaults.conf b/benchmarks/src/gatling/resources/benchmark-defaults.conf
index d26dddd..139bbb0 100644
--- a/benchmarks/src/gatling/resources/benchmark-defaults.conf
+++ b/benchmarks/src/gatling/resources/benchmark-defaults.conf
@@ -189,6 +189,32 @@ workload {
view-concurrency = 10
}
+ # Configuration for the DeleteTreeDataset simulation
+ delete-tree-dataset {
+ # Number of namespace operations to perform simultaneously
+ # Namespaces are deleted one tree level at a time, starting from the deepest level
+ # Default: 20
+ namespace-concurrency = 20
+
+ # Number of table operations to perform simultaneously
+ # This controls the concurrency level for table operations
+ # Default: 20
+ table-concurrency = 20
+
+ # Number of view operations to perform simultaneously
+ # This controls the concurrency level for view operations
+ # Default: 10
+ view-concurrency = 10
+
+ # Whether tables are dropped with purge. When true, the table's data and metadata files are
+ # deleted as well, which requires DROP_WITH_PURGE_ENABLED to be enabled on the server side.
+ # Set to false to keep the benchmark data on disk for inspection.
+ # Note: views are always dropped without purge. Their metadata purging is governed by the
+ # server-side PURGE_VIEW_METADATA_ON_DROP configuration.
+ # Default: false
+ purge = false
+ }
+
# Configuration for the ReadUpdateTreeDataset simulation
read-update-tree-dataset {
# Ratio of read operations to write operations
diff --git a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/NAryTreeBuilder.scala b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/NAryTreeBuilder.scala
index 6e00f14..bf3037d 100644
--- a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/NAryTreeBuilder.scala
+++ b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/NAryTreeBuilder.scala
@@ -92,25 +92,33 @@ case class NAryTreeBuilder(nsWidth: Int, nsDepth: Int) {
}
/**
- * Returns a range of ordinals for the nodes on the last level of a complete n-ary tree.
+ * Returns a range of ordinals for the nodes at a given depth of a complete n-ary tree.
*
+ * @param depth The depth of the nodes, where the root namespace is at the depth 0.
* @return The range of ordinals for the nodes on the last level of the tree.
*/
- val lastLevelOrdinals: Range = {
- val lastLevel = nsDepth - 1
+ def ordinalsAtDepth(depth: Int): Range = {
+ require(depth >= 0 && depth < nsDepth, s"Depth ($depth) must be in [0, $nsDepth]")
if (nsWidth == 1) {
// For a unary tree, the only node at depth d is simply the node with ordinal d.
- Range.inclusive(lastLevel, lastLevel)
+ Range.inclusive(depth, depth)
} else {
// The sum of nodes from level 0 to level d-1 is (n^d - 1) / (n - 1)
- val start = ((math.pow(nsWidth, lastLevel) - 1) / (nsWidth - 1)).toInt
+ val start = ((math.pow(nsWidth, depth) - 1) / (nsWidth - 1)).toInt
// The sum of nodes from level 0 to level d is (n^(d+1) - 1) / (n - 1)
// Therefore, the last ordinal at depth d is:
- val end = (((math.pow(nsWidth, lastLevel + 1) - 1) / (nsWidth - 1)).toInt) - 1
+ val end = (((math.pow(nsWidth, depth + 1) - 1) / (nsWidth - 1)).toInt) - 1
Range.inclusive(start, end)
}
}
+ /**
+ * Return a range of ordinals for the nodes on the last level of a complete n-ary tree.
+ *
+ * @return the range of ordinals for the nodes on the last level of the tree.
+ */
+ val lastLevelOrdinals: Range = ordinalsAtDepth(nsDepth - 1)
+
val numberOfLastLevelElements: Int = {
val lastLevel = nsDepth - 1
math.pow(nsWidth, lastLevel).toInt
diff --git a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/CatalogActions.scala b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/CatalogActions.scala
index 1062b4d..de12ff8 100644
--- a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/CatalogActions.scala
+++ b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/CatalogActions.scala
@@ -129,4 +129,17 @@ case class CatalogActions(
.header("Content-Type", "application/json")
.check(status.is(200))
)
+
+ /**
+ * Delete an Iceberg catalog by name. The catalog name is defined in the
+ * [[CatalogActions.feeder]]. A catalog that does not exist is ignored.
+ */
+ val deleteCatalog: ChainBuilder =
+ retryOnHttpStatus(maxRetries, retryableHttpCodes, "Delete catalog")(
+ http("Delete Catalog")
+ .delete("/api/management/v1/catalogs/#{catalogName}")
+ .header("Authorization", "Bearer #{accessToken}")
+ .saveHttpStatusCode()
+ .check(status.in(204, 404))
+ )
}
diff --git a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/NamespaceActions.scala b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/NamespaceActions.scala
index 7d737ac..9f5c070 100644
--- a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/NamespaceActions.scala
+++ b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/NamespaceActions.scala
@@ -62,21 +62,33 @@ case class NamespaceActions(
*/
def namespaceIdentityFeeder(): Feeder[Any] = Iterator
.from(0)
- .map { tableId =>
- val namespaceId = tableId
- val namespacePath: Seq[String] = dp.nAryTree
- .pathToRoot(namespaceId)
- .map(mangler.maybeMangleNs)
- Map(
- "catalogName" -> "C_0",
- "namespaceId" -> tableId,
- "namespacePath" -> namespacePath,
- "namespaceJsonPath" -> Json.toJson(namespacePath).toString(),
- "namespaceMultipartPath" -> namespacePath.mkString("%1F")
- )
- }
+ .map(namespaceIdentity)
.take(dp.nAryTree.numberOfNodes)
+ /**
+ * Creates a Gatling Feeder that generates the identities of the namespaces located at a given
+ * depth of the n-ary. Rows have the same attribute as the ones of
+ * [[NamespaceActions.namespaceIdentityFeeder()]]
+ *
+ * @param depth The depth of the namespaces, where the root namespace is at the depth 0
+ * @return An iterator providing namespace details
+ */
+ def namespaceDeletionFeeder(depth: Int): Feeder[Any] =
+ dp.nAryTree.ordinalsAtDepth(depth).iterator.map(namespaceIdentity)
+
+ private def namespaceIdentity(namespaceId: Int): Map[String, Any] = {
+ val namespacePath: Seq[String] = dp.nAryTree
+ .pathToRoot(namespaceId)
+ .map(mangler.maybeMangleNs)
+ Map(
+ "catalogName" -> "C_0",
+ "namespaceId" -> namespaceId,
+ "namespacePath" -> namespacePath,
+ "namespaceJsonPath" -> Json.toJson(namespacePath).toString(),
+ "namespaceMultipartPath" -> namespacePath.mkString("%1F")
+ )
+ }
+
/**
* Creates a Gatling Feeder that generates namespace hierarchies. Each row is associated with a
* distinct namespace and leverages the [[NamespaceActions.namespaceIdentityFeeder()]]. Additional
@@ -230,4 +242,16 @@ case class NamespaceActions(
.saveHttpStatusCode()
.check(status.is(200))
)
+
+ /**
+ * Delete an Iceberg namespace by its path. A namespace that does not exist is ignored.
+ */
+ val deleteNamespace: ChainBuilder =
+ retryOnHttpStatus(maxRetries, retryableHttpCodes, "Delete namespace")(
+ http("Delete Namespace")
+ .delete("/api/catalog/v1/#{catalogName}/namespaces/#{namespaceMultipartPath}")
+ .header("Authorization", "Bearer #{accessToken}")
+ .saveHttpStatusCode()
+ .check(status.in(204, 404))
+ )
}
diff --git a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/TableActions.scala b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/TableActions.scala
index 5324376..e72b1ff 100644
--- a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/TableActions.scala
+++ b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/TableActions.scala
@@ -241,6 +241,24 @@ case class TableActions(
.saveHttpStatusCode()
.check(status.is(200).saveAs("lastStatus"))
)
+
+ /**
+ * Delete an Iceberg table by its name and namespace path. A table that does not exist is ignored.
+ *
+ * @param purge When true, the table is dropped with purge, which also removes the table's data
+ * and metadata files. This requires DROP_WITH_PURGE_ENABLED to be enabled on the server side.
+ */
+ def deleteTable(purge: Boolean): ChainBuilder =
+ retryOnHttpStatus(maxRetries, retryableHttpCodes, "Delete Table")(
+ http("Delete Table")
+ .delete(
+ s"/api/catalog/v1/#{catalogName}/namespaces/#{multipartNamespace}/tables/#{tableName}"
+ )
+ .queryParam("purgeRequested", purge.toString)
+ .header("Authorization", "Bearer #{accessToken}")
+ .saveHttpStatusCode()
+ .check(status.in(204, 404))
+ )
}
/**
diff --git a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/ViewActions.scala b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/ViewActions.scala
index 4775ae3..0ed0db8 100644
--- a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/ViewActions.scala
+++ b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/ViewActions.scala
@@ -227,6 +227,17 @@ case class ViewActions(
.saveHttpStatusCode()
.check(status.is(200).saveAs("lastStatus"))
)
+
+ /**
+ * Delete an Iceberg view by its name and namespace path. A view that does not exist is ignored.
+ */
+ val deleteView: ChainBuilder = retryOnHttpStatus(maxRetries, retryableHttpCodes, "Delete View")(
+ http("Delete View")
+ .delete("/api/catalog/v1/#{catalogName}/namespaces/#{multipartNamespace}/views/#{viewName}")
+ .header("Authorization", "Bearer #{accessToken}")
+ .saveHttpStatusCode()
+ .check(status.in(204, 404))
+ )
}
/**
diff --git a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/parameters/BenchmarkConfig.scala b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/parameters/BenchmarkConfig.scala
index ec48066..9e3f4a6 100644
--- a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/parameters/BenchmarkConfig.scala
+++ b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/parameters/BenchmarkConfig.scala
@@ -62,6 +62,7 @@ object BenchmarkConfig {
val ccConfig = workload.getConfig("create-commits")
val rtdConfig = workload.getConfig("read-tree-dataset")
val ctdConfig = workload.getConfig("create-tree-dataset")
+ val dtdConfig = workload.getConfig("delete-tree-dataset")
val rutdConfig = workload.getConfig("read-update-tree-dataset")
val wwotdConfig = workload.getConfig("weighted-workload-on-tree-dataset")
@@ -80,6 +81,12 @@ object BenchmarkConfig {
ctdConfig.getInt("table-concurrency"),
ctdConfig.getInt("view-concurrency")
),
+ DeleteTreeDatasetParameters(
+ dtdConfig.getInt("namespace-concurrency"),
+ dtdConfig.getInt("table-concurrency"),
+ dtdConfig.getInt("view-concurrency"),
+ dtdConfig.getBoolean("purge")
+ ),
ReadUpdateTreeDatasetParameters(
rutdConfig.getDouble("read-write-ratio"),
rutdConfig.getInt("throughput"),
diff --git a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/parameters/DeleteTreeDatasetParameters.scala b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/parameters/DeleteTreeDatasetParameters.scala
new file mode 100644
index 0000000..4425a26
--- /dev/null
+++ b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/parameters/DeleteTreeDatasetParameters.scala
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.benchmarks.parameters
+
+/**
+ * Case class to hold the parameters for the DeleteTreeDataset simulation.
+ *
+ * @param namespaceThroughput The number of namespace operations to perform per second.
+ * @param tableThroughput The number of table operations to perform per second.
+ * @param viewThroughput The number of view operations to perform per second.
+ * @param purge Whether tables are dropped with purge. When true, the table's data and metadata
+ * files are removed as well, which requires DROP_WITH_PURGE_ENABLED to be enabled on the server
+ * side. Views are always dropped without purge, as their metadata purging is governed by the
+ * server-side PURGE_VIEW_METADATA_ON_DROP configuration.
+ */
+case class DeleteTreeDatasetParameters(
+ namespaceThroughput: Int,
+ tableThroughput: Int,
+ viewThroughput: Int,
+ purge: Boolean
+) {
+ require(namespaceThroughput >= 0, "Namespace throughput cannot be negative")
+ require(tableThroughput >= 0, "Table throughput cannot be negative")
+ require(viewThroughput >= 0, "View throughput cannot be negative")
+}
diff --git a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/parameters/WorkloadParameters.scala b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/parameters/WorkloadParameters.scala
index 0ee9690..90b7072 100644
--- a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/parameters/WorkloadParameters.scala
+++ b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/parameters/WorkloadParameters.scala
@@ -22,6 +22,7 @@ case class WorkloadParameters(
createCommits: CreateCommitsParameters,
readTreeDataset: ReadTreeDatasetParameters,
createTreeDataset: CreateTreeDatasetParameters,
+ deleteTreeDataset: DeleteTreeDatasetParameters,
readUpdateTreeDataset: ReadUpdateTreeDatasetParameters,
weightedWorkloadOnTreeDataset: WeightedWorkloadOnTreeDatasetParameters
) {}
diff --git a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/simulations/DeleteTreeDataset.scala b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/simulations/DeleteTreeDataset.scala
new file mode 100644
index 0000000..b6b8104
--- /dev/null
+++ b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/simulations/DeleteTreeDataset.scala
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.benchmarks.simulations
+
+import io.gatling.core.Predef._
+import io.gatling.core.structure.{PopulationBuilder, ScenarioBuilder}
+import io.gatling.http.Predef._
+import org.apache.polaris.benchmarks.actions._
+import org.apache.polaris.benchmarks.parameters.BenchmarkConfig.config
+import org.apache.polaris.benchmarks.parameters.{
+ AuthParameters,
+ ConnectionParameters,
+ DatasetParameters,
+ WorkloadParameters
+}
+import org.slf4j.LoggerFactory
+
+import java.util.concurrent.atomic.AtomicInteger
+
+/**
+ * This simulation is a 100% delete workload that removes a tree dataset create by
+ * [[CreateTreeDataset]] in Polaris. It must be run with the same dataset parameters as the ones
+ * used to create the dataset.
+ *
+ * Tables and views are deleted first, then namespaces one tree level at a time starting from the
+ * deepest level, then the catalogs. Entities that don't exist are ignored.
+ *
+ * Tables are dropped with purge as controlled by the `purge` configuration (default false). When
+ * enabled, it removes their data and metadata files on drop and requires DROP_WITH_PURGE_ENABLED to
+ * be enabled on the server side. Views are always dropped without purge; their metadata purging is
+ * governed by the server-side PURGE_VIEW_METADATA_ON_DROP configuration.
+ */
+class DeleteTreeDataset extends Simulation {
+ private val logger = LoggerFactory.getLogger(getClass)
+
+ // --------------------------------------------------------------------------------
+ // Load parameters
+ // --------------------------------------------------------------------------------
+ val cp: ConnectionParameters = config.connectionParameters
+ val ap: AuthParameters = config.authParameters
+ val dp: DatasetParameters = config.datasetParameters
+ val wp: WorkloadParameters = config.workloadParameters
+
+ // --------------------------------------------------------------------------------
+ // Helper values
+ // --------------------------------------------------------------------------------
+ private val numNamespaces: Int = dp.nAryTree.numberOfNodes
+ private val purge: Boolean = wp.deleteTreeDataset.purge
+ private val setupActions = SetupActions(cp, ap)
+ private val catalogActions = CatalogActions(dp, setupActions.accessToken, 0, Set())
+ private val namespaceActions = NamespaceActions(dp, wp, setupActions.accessToken, 5, Set(500))
+ private val tableActions = TableActions(dp, wp, setupActions.accessToken, 5, Set(500))
+ private val viewActions = ViewActions(dp, wp, setupActions.accessToken, 5, Set(500))
+
+ private val deletedCatalogs = new AtomicInteger()
+ private val deletedTables = new AtomicInteger()
+ private val deletedViews = new AtomicInteger()
+
+ // --------------------------------------------------------------------------------
+ // Workload: Delete views
+ // --------------------------------------------------------------------------------
+ val deleteViews: ScenarioBuilder = scenario("Delete views using the Iceberg REST API")
+ .exec(setupActions.restoreAccessTokenInSession)
+ .asLongAs(session =>
+ deletedViews.getAndIncrement() < dp.numViews && session.contains("accessToken")
+ )(
+ feed(viewActions.viewIdentityFeeder())
+ .exec(viewActions.deleteView)
+ )
+
+ // --------------------------------------------------------------------------------
+ // Workload: Delete tables
+ // --------------------------------------------------------------------------------
+ val deleteTables: ScenarioBuilder = scenario("Delete tables using the Iceberg REST API")
+ .exec(setupActions.restoreAccessTokenInSession)
+ .asLongAs(session =>
+ deletedTables.getAndIncrement() < dp.numTables && session.contains("accessToken")
+ )(
+ feed(tableActions.tableIdentityFeeder())
+ .exec(tableActions.deleteTable(purge))
+ )
+
+ // --------------------------------------------------------------------------------
+ // Workload: Delete namespaces
+ // --------------------------------------------------------------------------------
+ private def deleteNamespacesAtDepth(depth: Int): ScenarioBuilder = {
+ val numNamespacesAtDepth = dp.nAryTree.ordinalsAtDepth(depth).size
+ val deletedNamespaces = new AtomicInteger()
+ scenario(s"Delete namespaces at depth $depth using the Iceberg REST API")
+ .exec(setupActions.restoreAccessTokenInSession)
+ .asLongAs(session =>
+ deletedNamespaces.getAndIncrement() < numNamespacesAtDepth && session
+ .contains("accessToken")
+ )(
+ feed(namespaceActions.namespaceDeletionFeeder(depth))
+ .exec(namespaceActions.deleteNamespace)
+ )
+ }
+
+ // --------------------------------------------------------------------------------
+ // Workload: Delete catalogs
+ // --------------------------------------------------------------------------------
+ val deleteCatalogs: ScenarioBuilder =
+ scenario("Delete catalogs using the Polaris Management REST API")
+ .exec(setupActions.restoreAccessTokenInSession)
+ .asLongAs(session =>
+ deletedCatalogs.getAndIncrement() < dp.numCatalogs && session.contains("accessToken")
+ )(
+ feed(catalogActions.feeder())
+ .exec(catalogActions.deleteCatalog)
+ )
+
+ // --------------------------------------------------------------------------------
+ // Build up the HTTP protocol configuration and set up the simulation
+ // --------------------------------------------------------------------------------
+ private val httpProtocol = http
+ .baseUrl(cp.baseUrl)
+ .headers(cp.headers)
+ .acceptHeader("application/json")
+ .contentTypeHeader("application/json")
+ .disableCaching
+
+ // Get the configured throughput for namespace, tables and views
+ private val namespaceThroughput = wp.deleteTreeDataset.namespaceThroughput
+ private val tableThroughput = wp.deleteTreeDataset.tableThroughput
+ private val viewThroughput = wp.deleteTreeDataset.viewThroughput
+
+ private val deleteViewsAndTables: PopulationBuilder = setupActions.waitForAuthentication
+ .inject(atOnceUsers(1))
+ .andThen(deleteViews.inject(atOnceUsers(viewThroughput)).protocols(httpProtocol))
+ .andThen(deleteTables.inject(atOnceUsers(tableThroughput)).protocols(httpProtocol))
+
+ private val deleteViewsTablesAndNamespaces: PopulationBuilder =
+ (dp.nsDepth - 1 to 0 by -1).foldLeft(deleteViewsAndTables) { (populationBuilder, depth) =>
+ val users = math.min(namespaceThroughput, dp.nAryTree.ordinalsAtDepth(depth).size)
+ populationBuilder.andThen(
+ deleteNamespacesAtDepth(depth).inject(atOnceUsers(users)).protocols(httpProtocol)
+ )
+ }
+
+ setUp(
+ setupActions.continuouslyRefreshOauthToken().inject(atOnceUsers(1)).protocols(httpProtocol),
+ deleteViewsTablesAndNamespaces
+ .andThen(deleteCatalogs.inject(atOnceUsers(1)).protocols(httpProtocol))
+ .andThen(setupActions.stopRefreshingToken.inject(atOnceUsers(1)).protocols(httpProtocol))
+ ).assertions(
+ details("Delete View").successfulRequests.count.is(dp.numViews),
+ details("Delete Table").successfulRequests.count.is(dp.numTables),
+ details("Delete Namespace").successfulRequests.count.is(numNamespaces),
+ details("Delete Catalog").successfulRequests.count.is(dp.numCatalogs)
+ )
+}