From 8419610775c4db68161e2446d56b819bc2dd7ec6 Mon Sep 17 00:00:00 2001 From: Leonid Shlyapnikov Date: Fri, 14 Aug 2020 12:37:10 -0400 Subject: [PATCH 1/3] Removing unused Main and Config, cleaning up BUILD.bazel: removing common scala options, --- ledger-service/http-json-perf/BUILD.bazel | 33 ------- .../release/json-api-perf-logback.xml | 17 ---- .../scala/com/daml/http/perf/Config.scala | 89 ------------------- .../main/scala/com/daml/http/perf/Main.scala | 66 -------------- 4 files changed, 205 deletions(-) delete mode 100644 ledger-service/http-json-perf/release/json-api-perf-logback.xml delete mode 100644 ledger-service/http-json-perf/src/main/scala/com/daml/http/perf/Config.scala delete mode 100644 ledger-service/http-json-perf/src/main/scala/com/daml/http/perf/Main.scala diff --git a/ledger-service/http-json-perf/BUILD.bazel b/ledger-service/http-json-perf/BUILD.bazel index f222515a61e2..e2c2581a7b25 100644 --- a/ledger-service/http-json-perf/BUILD.bazel +++ b/ledger-service/http-json-perf/BUILD.bazel @@ -3,7 +3,6 @@ load( "//bazel_tools:scala.bzl", - "da_scala_binary", "da_scala_library", "da_scala_test", "lf_scalacopts", @@ -12,7 +11,6 @@ load("//rules_daml:daml.bzl", "daml_compile") hj_scalacopts = lf_scalacopts + [ "-P:wartremover:traverser:org.wartremover.warts.NonUnitStatements", - "-Ywarn-unused", ] da_scala_library( @@ -44,34 +42,3 @@ da_scala_library( "@maven//:org_slf4j_slf4j_api", ], ) - -da_scala_binary( - name = "http-json-perf-binary", - main_class = "com.daml.http.perf.Main", - scalacopts = hj_scalacopts, - tags = [ - "maven_coordinates=com.daml:http-json-perf-deploy:__VERSION__", - "no_scala_version_suffix", - ], - visibility = ["//visibility:public"], - deps = [ - ":http-json-perf", - "//ledger-service/jwt", - "//libs-scala/ports", - "//libs-scala/scala-utils", - "@maven//:ch_qos_logback_logback_classic", - "@maven//:com_fasterxml_jackson_core_jackson_core", - "@maven//:com_fasterxml_jackson_core_jackson_databind", - "@maven//:com_github_scopt_scopt_2_12", - "@maven//:com_typesafe_akka_akka_actor_2_12", - "@maven//:com_typesafe_scala_logging_scala_logging_2_12", - "@maven//:io_gatling_gatling_commons", - "@maven//:io_gatling_gatling_core", - "@maven//:io_gatling_gatling_http", - "@maven//:io_gatling_gatling_http_client", - "@maven//:org_scalaz_scalaz_core_2_12", - "@maven//:org_slf4j_slf4j_api", - ], -) - -exports_files(["release/json-api-perf-logback.xml"]) diff --git a/ledger-service/http-json-perf/release/json-api-perf-logback.xml b/ledger-service/http-json-perf/release/json-api-perf-logback.xml deleted file mode 100644 index f61cc99b7708..000000000000 --- a/ledger-service/http-json-perf/release/json-api-perf-logback.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - \ No newline at end of file diff --git a/ledger-service/http-json-perf/src/main/scala/com/daml/http/perf/Config.scala b/ledger-service/http-json-perf/src/main/scala/com/daml/http/perf/Config.scala deleted file mode 100644 index a854f18d3b6a..000000000000 --- a/ledger-service/http-json-perf/src/main/scala/com/daml/http/perf/Config.scala +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package com.daml.http.perf - -import com.daml.jwt.JwtDecoder -import com.daml.jwt.domain.Jwt -import com.daml.ports.Port -import scopt.RenderingMode - -private[perf] final case class Config( - jsonApiHost: String, - jsonApiPort: Port, - scenario: String, - jwt: Jwt, - packageId: Option[String], -) { - override def toString: String = - s"Config(jsonApiHost=${this.jsonApiHost}, " + - s"jsonApiPort=${this.jsonApiPort.value: Int}, " + - s"scenario=${this.scenario}, " + - s"jwt=..., " + // don't print the JWT - s"packageId=${this.packageId.toString})" -} - -private[perf] object Config { - val Empty = - Config( - jsonApiHost = "", - jsonApiPort = Port.Dynamic, - scenario = "", - jwt = Jwt(""), - packageId = None) - - def parseConfig(args: Seq[String]): Option[Config] = - configParser.parse(args, Config.Empty) - - @SuppressWarnings(Array("org.wartremover.warts.NonUnitStatements")) - private val configParser: scopt.OptionParser[Config] = - new scopt.OptionParser[Config]("http-json-perf-binary") { - override def renderingMode: RenderingMode = RenderingMode.OneColumn - - head("JSON API Perf Test Tool") - - help("help").text("Print this usage text") - - opt[String]("json-api-host") - .action((x, c) => c.copy(jsonApiHost = x)) - .required() - .text("JSON API host name or IP address") - - opt[Int]("json-api-port") - .action((x, c) => c.copy(jsonApiPort = Port(x))) - .required() - .validate(validatePort) - .text("JSON API port number") - - opt[String]("scenario") - .action((x, c) => c.copy(scenario = x)) - .required() - .text("Performance test scenario to run") - - opt[String]("jwt") - .action((x, c) => c.copy(jwt = Jwt(x))) - .required() - .validate(validateJwt) - .text("JWT token to use when connecting to JSON API") - - opt[String]("package-id") - .action((x, c) => c.copy(packageId = Some(x))) - .optional() - .text("Optional package ID to specify in the commands sent to JSON API") - } - - private def validatePort(p: Int): Either[String, Unit] = - Port.validate(p).toEither.left.map(x => x.getMessage) - - private def validateJwt(s: String): Either[String, Unit] = { - import scalaz.syntax.show._ - - JwtDecoder - .decode(Jwt(s)) - .bimap( - error => error.shows, - _ => () - ) - .toEither - } -} diff --git a/ledger-service/http-json-perf/src/main/scala/com/daml/http/perf/Main.scala b/ledger-service/http-json-perf/src/main/scala/com/daml/http/perf/Main.scala deleted file mode 100644 index 93fc5ac685a3..000000000000 --- a/ledger-service/http-json-perf/src/main/scala/com/daml/http/perf/Main.scala +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package com.daml.http.perf - -import akka.actor.ActorSystem -import com.daml.scalautil.Statement.discard -import com.typesafe.scalalogging.StrictLogging - -import scala.concurrent.duration.{Duration, _} -import scala.concurrent.{Await, ExecutionContext, Future} -import scala.util.{Failure, Success} - -object Main extends StrictLogging { - - type Scenario = Config => Future[Unit] - - sealed abstract class ExitCode(val code: Int) extends Product with Serializable - object ExitCode { - case object Ok extends ExitCode(0) - case object InvalidUsage extends ExitCode(100) - case object StartupError extends ExitCode(101) - case object InvalidScenario extends ExitCode(102) - } - - def main(args: Array[String]): Unit = { - implicit val asys: ActorSystem = ActorSystem("http-json-perf") - // implicit val mat: Materializer = Materializer(asys) - implicit val ec: ExecutionContext = asys.dispatcher - - def terminate(): Unit = discard { Await.result(asys.terminate(), 10.seconds) } - - val exitCode: ExitCode = Config.parseConfig(args) match { - case Some(config) => - main(config) - case None => - // error is printed out by scopt - ExitCode.InvalidUsage - } - - terminate() - sys.exit(exitCode.code) - } - - private def main(config: Config)(implicit ec: ExecutionContext): ExitCode = { - logger.info(s"$config") - if (config.scenario == "commands") { - runScenarioSync(config, null) // XXX - ExitCode.Ok - } else { - logger.error(s"Unsupported scenario: ${config.scenario}") - ExitCode.InvalidScenario - } - } - - private def runScenarioSync(config: Config, scenario: Scenario)( - implicit ec: ExecutionContext - ): Unit = { - val scenarioF: Future[Unit] = scenario(config) - scenarioF.onComplete { - case Success(_) => logger.info(s"Scenario: ${config.scenario} completed") - case Failure(e) => logger.error(s"Scenario: ${config.scenario} failed", e) - } - Await.result(scenarioF, Duration.Inf) - } -} From 5fe101460fee5c8f133b77a13cd2760ec26e1b8d Mon Sep 17 00:00:00 2001 From: Leonid Shlyapnikov Date: Fri, 14 Aug 2020 12:52:28 -0400 Subject: [PATCH 2/3] Removing unused dependencies --- ledger-service/http-json-perf/BUILD.bazel | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ledger-service/http-json-perf/BUILD.bazel b/ledger-service/http-json-perf/BUILD.bazel index e2c2581a7b25..c525ed6086ca 100644 --- a/ledger-service/http-json-perf/BUILD.bazel +++ b/ledger-service/http-json-perf/BUILD.bazel @@ -26,19 +26,12 @@ da_scala_library( "@maven//:ch_qos_logback_logback_classic", ], deps = [ - "//ledger-service/jwt", - "//libs-scala/ports", - "//libs-scala/scala-utils", "@maven//:com_fasterxml_jackson_core_jackson_core", "@maven//:com_fasterxml_jackson_core_jackson_databind", - "@maven//:com_github_scopt_scopt_2_12", - "@maven//:com_typesafe_akka_akka_actor_2_12", "@maven//:com_typesafe_scala_logging_scala_logging_2_12", "@maven//:io_gatling_gatling_commons", "@maven//:io_gatling_gatling_core", "@maven//:io_gatling_gatling_http", "@maven//:io_gatling_gatling_http_client", - "@maven//:org_scalaz_scalaz_core_2_12", - "@maven//:org_slf4j_slf4j_api", ], ) From f9f3f629e0646e5a92d818bef6783a645f3edec0 Mon Sep 17 00:00:00 2001 From: Leonid Shlyapnikov Date: Fri, 14 Aug 2020 12:55:16 -0400 Subject: [PATCH 3/3] Removing unused dependencies changelog_begin changelog_end --- ledger-service/http-json-perf/BUILD.bazel | 3 --- 1 file changed, 3 deletions(-) diff --git a/ledger-service/http-json-perf/BUILD.bazel b/ledger-service/http-json-perf/BUILD.bazel index c525ed6086ca..60c5d6f39fe1 100644 --- a/ledger-service/http-json-perf/BUILD.bazel +++ b/ledger-service/http-json-perf/BUILD.bazel @@ -22,9 +22,6 @@ da_scala_library( scalacopts = hj_scalacopts, tags = ["maven_coordinates=com.daml:http-json-perf:__VERSION__"], visibility = ["//visibility:public"], - runtime_deps = [ - "@maven//:ch_qos_logback_logback_classic", - ], deps = [ "@maven//:com_fasterxml_jackson_core_jackson_core", "@maven//:com_fasterxml_jackson_core_jackson_databind",