From 526189c6b101c4fbdd6267d77cf1433e3f32877d Mon Sep 17 00:00:00 2001 From: chepk <41194083+chepk@users.noreply.github.com> Date: Fri, 18 Sep 2020 10:50:54 +0300 Subject: [PATCH] merge dev into master (#10) * Add List to Feeder transformer (#4) * Maven publish (#9) Co-authored-by: John Co-authored-by: eevulution <37728480+eevulution@users.noreply.github.com> --- .travis.yml | 24 ++++++++++-- build.sbt | 1 - .../load/example/feeders/Feeders.scala | 14 ++++++- .../example/scenarios/SampleScenario.scala | 2 + project/plugins.sbt | 5 ++- publish.sbt | 8 +++- signingkey.asc.enc | Bin 0 -> 5088 bytes .../ru/tinkoff/gatling/feeders/feeders.scala | 9 ++++- .../gatling/feeders/FeedersBaseSpec.scala | 36 +++++++++++++----- 9 files changed, 79 insertions(+), 20 deletions(-) create mode 100644 signingkey.asc.enc diff --git a/.travis.yml b/.travis.yml index 05b698d..b429e0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,23 @@ language: scala + jdk: - - openjdk11 -script: - - sbt compile test \ No newline at end of file +- openjdk11 + +jobs: + include: + - stage: Tests + name: Unit tests + script: + - sbt compile test + + - stage: Publish + name: Publish release + if: branch = master + before_script: + - gpg --import signingkey.asc + script: + - sbt publish + +before_install: +- openssl aes-256-cbc -K $encrypted_171b1c559d7b_key -iv $encrypted_171b1c559d7b_iv + -in signingkey.asc.enc -out signingkey.asc -d diff --git a/build.sbt b/build.sbt index 51eae14..bd1deb4 100644 --- a/build.sbt +++ b/build.sbt @@ -15,7 +15,6 @@ lazy val root = (project in file(".")) scalacOptions := Seq( "-encoding", "UTF-8", - "-target:jvm-1.8", "-deprecation", "-feature", "-unchecked", diff --git a/example/src/test/scala/ru/tinkoff/load/example/feeders/Feeders.scala b/example/src/test/scala/ru/tinkoff/load/example/feeders/Feeders.scala index 7e4a2c1..4c84077 100644 --- a/example/src/test/scala/ru/tinkoff/load/example/feeders/Feeders.scala +++ b/example/src/test/scala/ru/tinkoff/load/example/feeders/Feeders.scala @@ -1,8 +1,10 @@ package ru.tinkoff.load.example.feeders +import io.gatling.core.Predef._ +import ru.tinkoff.gatling.feeders._ import java.time.LocalDateTime import java.time.temporal.ChronoUnit -import ru.tinkoff.gatling.feeders._ + object Feeders { @@ -59,6 +61,14 @@ object Feeders { //how to combine together 2 or more feeders //as result we get feeder with 3 params: digit, string, phone - val gluedTogetherFeeder = digitFeeder ** stringFeeder ** phoneFeeder + val gluedTogetherFeeder = digitFeeder ** stringFeeder ** phoneFeeder + + //tranform values of this Feeder + val finiteRandomDigitsWithTransform = RandomDigitFeeder("randomDigit") + .toFiniteLength(20) + .convert { case (k, v) => k -> v.toString() } + + //tranform List to Feeder + val list2feeder = List(1, 2, 3).toFeeder("listId").circular } diff --git a/example/src/test/scala/ru/tinkoff/load/example/scenarios/SampleScenario.scala b/example/src/test/scala/ru/tinkoff/load/example/scenarios/SampleScenario.scala index 45d138d..5e6b7a5 100644 --- a/example/src/test/scala/ru/tinkoff/load/example/scenarios/SampleScenario.scala +++ b/example/src/test/scala/ru/tinkoff/load/example/scenarios/SampleScenario.scala @@ -31,6 +31,8 @@ class SampleScenario { .feed(simpleRandomDate) .feed(vacationDate) .feed(gluedTogetherFeeder) + .feed(list2feeder) + .feed(finiteRandomDigitsWithTransform) .exec(getMainPage) } diff --git a/project/plugins.sbt b/project/plugins.sbt index 9e3b167..6649a46 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,7 @@ +resolvers += Resolver.bintrayIvyRepo("rallyhealth", "sbt-plugins") + addSbtPlugin("io.gatling" % "gatling-sbt" % "3.0.0") addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0") +addSbtPlugin("com.rallyhealth.sbt" % "sbt-git-versioning" % "1.4.0") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.2") -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0-M2") +addSbtPlugin("io.crashbox" % "sbt-gpg" % "0.2.1") diff --git a/publish.sbt b/publish.sbt index d12ee2d..2483709 100644 --- a/publish.sbt +++ b/publish.sbt @@ -48,4 +48,10 @@ ThisBuild / description := "Gatling Utils" ThisBuild / licenses := List("Apache 2" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt")) ThisBuild / homepage := Some(url("https://github.com/TinkoffCreditSystems/gatling-picatinny.git")) -ThisBuild / pomIncludeRepository := { _ => false } \ No newline at end of file +ThisBuild / pomIncludeRepository := { _ => false } + +val NEXUS_USER = sys.env.getOrElse("NEXUS_USER", "") +val NEXUS_PASS = sys.env.getOrElse("NEXUS_PASS", "") + +credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", NEXUS_USER, NEXUS_PASS) +credentials += Credentials("GnuPG Key ID", "gpg", "gatling-picatinny", "ignored") diff --git a/signingkey.asc.enc b/signingkey.asc.enc new file mode 100644 index 0000000000000000000000000000000000000000..e54ce913eaf3ea3355f6fa6e2b9445a7108c48d7 GIT binary patch literal 5088 zcmV<66CdpAE(n7(hbDu0yBQ#%|5U#OhzwWwiF)?|e%#EKc*wGULncj);v*EVUubVa zk7Av>LNt&g_LD@dKI%AvT>xI8cfmc3w0b;0sST z4ozbzK{PpH4w4pf822fKcCneMw4CR1!V$^dV=@CH-AcdkIt+_ z-MotI(M@v6)jkWn3Y5ouanWQ|`>k=^+5Z%ti?R8V`$oOEeMXs=A9;Mk!Q7wFV>rwC zz1S+viWOLU$n)_&_Zb=-d_-2^&260|yp`J7Eimx5Lf^gy>#{jbn(qPj3{T?{U}P+c#~|s8kQ$OkA@pY^4fxgiXPE4qhwJMNT=Hv`p%yC&yA}wtj)2 zzPc&xW)Evpo^|e8CIL}7#Z%juuk@ZQ6uLpk-Kum2{aa+P1A?>4ew{q4 zydX^+=Uh6zh$cg6Zo;d?h3%ZGG?Wl^4g32Oa+w)LV^3~Z;Wb8#w3RuuFXcoZ`=8}# zx`ta^sOS{3`0&2uG*%cWtNxt=2UrIzmqpoUWquQu!R{KBb6&q2R>W|x7#tpB?DG%0 z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Tm&2(zKPE(^#i!|6GdnW8oJcy<2k~5V+kY{ho+2 z7FEd)ncCUFXVvA^!d#R8Kl1y@Rz`GMVHkdV?XJazdnYP2J57;J%ZsT`7PoVP7Bk(- C1jkAM literal 0 HcmV?d00001 diff --git a/src/main/scala/ru/tinkoff/gatling/feeders/feeders.scala b/src/main/scala/ru/tinkoff/gatling/feeders/feeders.scala index 1753a1d..623b900 100644 --- a/src/main/scala/ru/tinkoff/gatling/feeders/feeders.scala +++ b/src/main/scala/ru/tinkoff/gatling/feeders/feeders.scala @@ -1,13 +1,18 @@ package ru.tinkoff.gatling -import io.gatling.core.feeder.Feeder +import io.gatling.core.feeder._ package object feeders { def feeder[T](name: String)(f: => T): Feeder[T] = Iterator.continually(Map(name -> f)) implicit class FeederOps[A](val feeder: Feeder[A]) extends AnyVal { - def **[B](other: Feeder[B]): Feeder[Any] = feeder.zip(other).map { case (r1, r2) => r1 ++ r2 } + def **[B](other: Feeder[B]): Feeder[Any] = feeder.zip(other).map { case (r1, r2) => r1 ++ r2 } + def toFiniteLength(n: Int): IndexedSeq[Record[A]] = feeder.take(n).toIndexedSeq + } + + implicit class Collection2FeederOps[A](val sequence: Traversable[A]) { + def toFeeder(name: String): IndexedSeq[Map[String, A]] = sequence.toIndexedSeq.map(x => Map(name -> x)) } } diff --git a/src/test/scala/ru/tinkoff/gatling/feeders/FeedersBaseSpec.scala b/src/test/scala/ru/tinkoff/gatling/feeders/FeedersBaseSpec.scala index 337ade0..8bc61b5 100644 --- a/src/test/scala/ru/tinkoff/gatling/feeders/FeedersBaseSpec.scala +++ b/src/test/scala/ru/tinkoff/gatling/feeders/FeedersBaseSpec.scala @@ -1,13 +1,10 @@ package ru.tinkoff.gatling.feeders -import io.gatling.core.feeder.Feeder -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers - -import org.scalatest.prop._ +import io.gatling.core.feeder._ import org.scalacheck.Arbitrary._ import org.scalacheck.Prop._ -import org.scalatest._ +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers class FeedersBaseSpec extends AnyFlatSpec with Matchers { @@ -31,10 +28,29 @@ class FeedersBaseSpec extends AnyFlatSpec with Matchers { it should "zip two feeders" in { forAll { (n1: String, n2: String, v1: AnyVal, v2: AnyVal) => - val feeder1: Feeder[AnyVal] = Iterator.continually(Map(n1 -> v1)) - val feeder2: Feeder[AnyVal] = Iterator.continually(Map(n2 -> v2)) - val result: Feeder[Any] = feeder1 ** feeder2 - result.next().equals(Map(n1 -> v1, n2 -> v2)) + val feeder1: Feeder[AnyVal] = Iterator.continually(Map(n1 -> v1)) + val feeder2: Feeder[AnyVal] = Iterator.continually(Map(n2 -> v2)) + val result: Feeder[Any] = feeder1 ** feeder2 + result.next().equals(Map(n1 -> v1, n2 -> v2)) }.check } + + it should "prepare feeder with finite size" in { + forAll { (n: String, v: Char) => + val fdr = RandomDigitFeeder(n) + val result = fdr.toFiniteLength(v) + + result.size == v + }.check + } + + it should "transform Collection to Feeder" in { + forAll { (n: String, v: AnyVal) => + val collection = List.fill(100)(v) + val result = collection.toFeeder(n) + + result.forall(r => r.equals(Map(n -> v))) + }.check + } + }