From 3186c42a2e0b3af8627c9bfa291b4c6209f06a6d Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 23 Jul 2023 14:55:01 +0100 Subject: [PATCH 1/7] try h2spec 2.6.0 --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 70a4b6f2d..7af4b3bb1 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -23,7 +23,7 @@ object Dependencies { val jacksonDatabindVersion = "2.14.3" val jacksonXmlVersion = jacksonDatabindVersion val junitVersion = "4.13.2" - val h2specVersion = "1.5.0" + val h2specVersion = "2.6.0" val h2specName = s"h2spec_${DependencyHelpers.osName}_amd64" val h2specExe = "h2spec" + DependencyHelpers.exeIfWindows val h2specUrl = s"https://github.com/summerwind/h2spec/releases/download/v$h2specVersion/$h2specName.zip" From 49614739c4a0d913a81d5ebbf7d6a6a393c662bd Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 23 Jul 2023 16:06:14 +0100 Subject: [PATCH 2/7] tar.gz support --- build.sbt | 4 ++-- project/Dependencies.scala | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index f54cdb3b6..dfcc6b09c 100644 --- a/build.sbt +++ b/build.sbt @@ -11,7 +11,7 @@ import org.apache.pekko import pekko._ import pekko.ValidatePullRequest._ import PekkoDependency._ -import Dependencies.{ h2specExe, h2specName } +import Dependencies.{ h2specExe, h2specName, h2specArtifactExtension } import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys.MultiJvm import java.nio.file.Files import java.nio.file.attribute.{ PosixFileAttributeView, PosixFilePermission } @@ -187,7 +187,7 @@ lazy val http2Tests = project("http2-tests") if (!h2spec.exists) { log.info("Extracting h2spec to " + h2spec) - for (zip <- (Test / update).value.select(artifact = artifactFilter(name = h2specName, extension = "zip"))) + for (zip <- (Test / update).value.select(artifact = artifactFilter(name = h2specName, extension = h2specArtifactExtension))) IO.unzip(zip, (Test / target).value) // Set the executable bit on the expected path to fail if it doesn't exist diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 7af4b3bb1..f31b99397 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -26,7 +26,8 @@ object Dependencies { val h2specVersion = "2.6.0" val h2specName = s"h2spec_${DependencyHelpers.osName}_amd64" val h2specExe = "h2spec" + DependencyHelpers.exeIfWindows - val h2specUrl = s"https://github.com/summerwind/h2spec/releases/download/v$h2specVersion/$h2specName.zip" + val h2specArtifactExtension = if (h2specExe == "exe") "zip" else "tar.gz" + val h2specUrl = s"https://github.com/summerwind/h2spec/releases/download/v$h2specVersion/$h2specName.$h2specArtifactExtension" val scalaTestVersion = "3.2.14" val specs2Version = "4.10.6" @@ -186,8 +187,7 @@ object DependencyHelpers { } def exeIfWindows: String = { - val os = System.getProperty("os.name").toLowerCase() - if (os.startsWith("win")) ".exe" + if (osName.startsWith("win")) ".exe" else "" } From c90b68dce17123dd0000ed66c34f717b89bbcdf7 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 23 Jul 2023 16:08:42 +0100 Subject: [PATCH 3/7] scalafmt --- build.sbt | 5 +++-- project/Dependencies.scala | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index dfcc6b09c..1b7b54dc1 100644 --- a/build.sbt +++ b/build.sbt @@ -11,7 +11,7 @@ import org.apache.pekko import pekko._ import pekko.ValidatePullRequest._ import PekkoDependency._ -import Dependencies.{ h2specExe, h2specName, h2specArtifactExtension } +import Dependencies.{ h2specArtifactExtension, h2specExe, h2specName } import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys.MultiJvm import java.nio.file.Files import java.nio.file.attribute.{ PosixFileAttributeView, PosixFilePermission } @@ -187,7 +187,8 @@ lazy val http2Tests = project("http2-tests") if (!h2spec.exists) { log.info("Extracting h2spec to " + h2spec) - for (zip <- (Test / update).value.select(artifact = artifactFilter(name = h2specName, extension = h2specArtifactExtension))) + for (zip <- (Test / update).value.select(artifact = artifactFilter(name = h2specName, + extension = h2specArtifactExtension))) IO.unzip(zip, (Test / target).value) // Set the executable bit on the expected path to fail if it doesn't exist diff --git a/project/Dependencies.scala b/project/Dependencies.scala index f31b99397..74fac3c31 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -27,7 +27,8 @@ object Dependencies { val h2specName = s"h2spec_${DependencyHelpers.osName}_amd64" val h2specExe = "h2spec" + DependencyHelpers.exeIfWindows val h2specArtifactExtension = if (h2specExe == "exe") "zip" else "tar.gz" - val h2specUrl = s"https://github.com/summerwind/h2spec/releases/download/v$h2specVersion/$h2specName.$h2specArtifactExtension" + val h2specUrl = + s"https://github.com/summerwind/h2spec/releases/download/v$h2specVersion/$h2specName.$h2specArtifactExtension" val scalaTestVersion = "3.2.14" val specs2Version = "4.10.6" From 6a1dc240ac4a7833dc8b28664b49948c99417e48 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 23 Jul 2023 17:41:55 +0100 Subject: [PATCH 4/7] untar support --- build.sbt | 8 +++++--- project/Untar.scala | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 project/Untar.scala diff --git a/build.sbt b/build.sbt index 1b7b54dc1..7411b917d 100644 --- a/build.sbt +++ b/build.sbt @@ -187,9 +187,11 @@ lazy val http2Tests = project("http2-tests") if (!h2spec.exists) { log.info("Extracting h2spec to " + h2spec) - for (zip <- (Test / update).value.select(artifact = artifactFilter(name = h2specName, - extension = h2specArtifactExtension))) - IO.unzip(zip, (Test / target).value) + for (zip <- (Test / update).value.select(artifact = artifactFilter(name = h2specName, extension = "zip"))) + IO.unzip(zip, (Test / target).value / h2specName) + + for (tarGz <- (Test / update).value.select(artifact = artifactFilter(name = h2specName, extension = "gz"))) + Untar.unTarGz(tarGz, (Test / target).value / h2specName) // Set the executable bit on the expected path to fail if it doesn't exist for (view <- Option(Files.getFileAttributeView(h2spec.toPath, classOf[PosixFileAttributeView]))) { diff --git a/project/Untar.scala b/project/Untar.scala new file mode 100644 index 000000000..32bef6de7 --- /dev/null +++ b/project/Untar.scala @@ -0,0 +1,48 @@ +/* + * 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.pekko + +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream +import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream +import org.apache.commons.io.IOUtils + +import java.io.{BufferedInputStream, File, FileInputStream, FileOutputStream} +import scala.util.Using + +object Untar { + + // extracts files from `.tar.gz` / `.tgz` files + def unTarGz(tarFile: File, toDirectory: File): Unit = { + Using(new FileInputStream(tarFile)) { tarFileStream => + val buffIn = new BufferedInputStream(tarFileStream) + val gzIn = new GzipCompressorInputStream(buffIn) + Using(new TarArchiveInputStream(gzIn)) { tis => + toDirectory.mkdirs() + var entry = tis.getNextTarEntry + while (entry ne null) { + val name = entry.getName + val outFile = new File(toDirectory, name) + Using(new FileOutputStream(outFile)) { fos => + IOUtils.copy(tis, fos) + } + entry = tis.getNextTarEntry + } + } + } + } +} From 5bd483be3e2939e50180850b398e2bb4d5456c41 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 23 Jul 2023 17:45:59 +0100 Subject: [PATCH 5/7] scalafmt --- project/Untar.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Untar.scala b/project/Untar.scala index 32bef6de7..6b5ccfda0 100644 --- a/project/Untar.scala +++ b/project/Untar.scala @@ -21,7 +21,7 @@ import org.apache.commons.compress.archivers.tar.TarArchiveInputStream import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream import org.apache.commons.io.IOUtils -import java.io.{BufferedInputStream, File, FileInputStream, FileOutputStream} +import java.io.{ BufferedInputStream, File, FileInputStream, FileOutputStream } import scala.util.Using object Untar { From 7feb5d494028761539224cd5f40d04019e1ad044 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 23 Jul 2023 18:05:17 +0100 Subject: [PATCH 6/7] Update H2SpecIntegrationSpec.scala --- .../pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala index d902f8dc2..25c7e517c 100644 --- a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala +++ b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala @@ -171,7 +171,7 @@ class H2SpecIntegrationSpec extends PekkoSpec( "-k", "-t", "-p", port.toString, "-j", junitOutput.getPath) ++ - specSectionNumber.toList.flatMap(number => Seq("-s", number)) + specSectionNumber.toList.flatMap(number => Seq(s"http2/$number")) log.debug(s"Executing h2spec: $command") val aggregateTckLogs = ProcessLogger( From 42726ab7e0bc5988945fd75130743d7d837626d5 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 23 Jul 2023 18:09:39 +0100 Subject: [PATCH 7/7] Update H2SpecIntegrationSpec.scala --- .../pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala index 25c7e517c..726f16767 100644 --- a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala +++ b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala @@ -171,7 +171,7 @@ class H2SpecIntegrationSpec extends PekkoSpec( "-k", "-t", "-p", port.toString, "-j", junitOutput.getPath) ++ - specSectionNumber.toList.flatMap(number => Seq(s"http2/$number")) + specSectionNumber.toList.map(number => s"http2/$number") log.debug(s"Executing h2spec: $command") val aggregateTckLogs = ProcessLogger(