dimas-b commented on code in PR #24:
URL: https://github.com/apache/polaris-tools/pull/24#discussion_r2132171584


##########
benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/simulations/CreateCommits.scala:
##########
@@ -0,0 +1,138 @@
+/*
+ * 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.ScenarioBuilder
+import io.gatling.http.Predef.http
+import org.apache.polaris.benchmarks.actions.{
+  AuthenticationActions,
+  NamespaceActions,
+  TableActions,
+  ViewActions
+}
+import org.apache.polaris.benchmarks.parameters.BenchmarkConfig.config
+import org.apache.polaris.benchmarks.parameters.{
+  ConnectionParameters,
+  DatasetParameters,
+  WorkloadParameters
+}
+import org.apache.polaris.benchmarks.util.CircularIterator
+import org.slf4j.LoggerFactory
+
+import java.util.concurrent.atomic.{AtomicBoolean, AtomicReference}
+import scala.concurrent.duration._
+
+class CreateCommits extends Simulation {
+  private val logger = LoggerFactory.getLogger(getClass)
+
+  // 
--------------------------------------------------------------------------------
+  // Load parameters
+  // 
--------------------------------------------------------------------------------
+  val cp: ConnectionParameters = config.connectionParameters
+  val dp: DatasetParameters = config.datasetParameters
+  val wp: WorkloadParameters = config.workloadParameters
+
+  // 
--------------------------------------------------------------------------------
+  // Helper values
+  // 
--------------------------------------------------------------------------------
+  private val accessToken: AtomicReference[String] = new AtomicReference()
+  private val shouldRefreshToken: AtomicBoolean = new AtomicBoolean(true)
+
+  private val authActions = AuthenticationActions(cp, accessToken)
+  private val tableActions = TableActions(dp, wp, accessToken)
+  private val viewActions = ViewActions(dp, wp, accessToken)
+
+  // 
--------------------------------------------------------------------------------
+  // Authentication related workloads:
+  // * Authenticate and store the access token for later use every minute
+  // * Wait for an OAuth token to be available
+  // * Stop the token refresh loop
+  // 
--------------------------------------------------------------------------------
+  val continuouslyRefreshOauthToken: ScenarioBuilder =
+    scenario("Authenticate every minute using the Iceberg REST API")
+      .asLongAs(_ => shouldRefreshToken.get())(
+        feed(authActions.feeder())
+          .exec(authActions.authenticateAndSaveAccessToken)
+          .pause(1.minute)
+      )
+
+  val waitForAuthentication: ScenarioBuilder =
+    scenario("Wait for the authentication token to be available")
+      .asLongAs(_ => accessToken.get() == null)(
+        pause(1.second)
+      )
+
+  val stopRefreshingToken: ScenarioBuilder =
+    scenario("Stop refreshing the authentication token")
+      .exec { session =>
+        shouldRefreshToken.set(false)
+        session
+      }
+
+  // 
--------------------------------------------------------------------------------
+  // Read and write workloads:
+  // * Create table commits by updating table properties
+  // * Read namespaces, tables and views
+  // 
--------------------------------------------------------------------------------
+  val tableUpdateScenario: ScenarioBuilder =
+    scenario("Create table commits by updating properties")
+      .exec(authActions.restoreAccessTokenInSession)
+      .feed(tableActions.propertyUpdateFeeder())
+      .exec(tableActions.updateTable)

Review Comment:
   Updating properties in multiple tables at the same time (the 
`/v1/{prefix}/transactions/commit` endpoint) is realistic enough for now :) 
That should exercise the code path that deals with atomically changing multiple 
entities in Persistence (same Persistence operation as for table data updates).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to