RussellSpitzer commented on code in PR #2: URL: https://github.com/apache/polaris-tools/pull/2#discussion_r2023178284
########## benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/actions/CatalogActions.scala: ########## @@ -0,0 +1,135 @@ +/* + * 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.actions + +import io.gatling.core.Predef._ +import io.gatling.core.feeder.Feeder +import io.gatling.core.structure.ChainBuilder +import io.gatling.http.Predef._ +import org.apache.polaris.benchmarks.RetryOnHttpCodes.{ + retryOnHttpStatus, + HttpRequestBuilderWithStatusSave +} +import org.apache.polaris.benchmarks.parameters.DatasetParameters +import org.slf4j.LoggerFactory + +import java.util.concurrent.atomic.AtomicReference + +/** + * Actions for performance testing catalog operations in Apache Iceberg. This class provides methods + * to create and fetch catalogs. + * + * @param dp Dataset parameters controlling the dataset generation + * @param accessToken Reference to the authentication token for API requests + * @param maxRetries Maximum number of retry attempts for failed operations + * @param retryableHttpCodes HTTP status codes that should trigger a retry + */ +case class CatalogActions( + dp: DatasetParameters, + accessToken: AtomicReference[String], + maxRetries: Int = 10, + retryableHttpCodes: Set[Int] = Set(409, 500) +) { + private val logger = LoggerFactory.getLogger(getClass) + + /** + * Creates a Gatling Feeder that generates catalog names and their default storage locations. Each + * catalog will be named "C_n" where n is a sequential number, and will have a corresponding + * storage location under the configured base path. + * + * @return An iterator providing catalog names and their storage locations + */ + def feeder(): Feeder[String] = Iterator + .from(0) + .map { i => + val catalogName = s"C_$i" + Map( + "catalogName" -> catalogName, + "defaultBaseLocation" -> s"${dp.defaultBaseLocation}/$catalogName" + ) + } + .take(dp.numCatalogs) + + /** + * Creates a new Iceberg catalog with FILE storage type. The catalog is created as an INTERNAL + * type with a name and a default base location that are defined in the [[CatalogActions.feeder]]. + * This represents the fundamental operation of establishing a new catalog in an Iceberg + * deployment. + * + * There is no limit to the number of users that can create catalogs concurrently. + */ + val createCatalog: ChainBuilder = + retryOnHttpStatus(maxRetries, retryableHttpCodes, "Create catalog")( Review Comment: Looks good for now, but I was wondering if this should be using a Polaris client rather than doing String based querying? Probably not important because I assume we are going to keep these apis static but I generally am afraid of string constants. -- 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]
