-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retry some of the occasionally flaky tests when failing on the CI (#3320
- Loading branch information
Showing
12 changed files
with
1,087 additions
and
1,022 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,87 +175,89 @@ class ConfigTests extends ScalaCliSuite { | |
|
||
if (TestUtil.isNativeCli) | ||
test(s"Create a PGP key with external JVM process, java version too low") { | ||
TestInputs().fromRoot { root => | ||
val configFile = { | ||
val dir = root / "config" | ||
os.makeDir.all(dir, perms = if (Properties.isWin) null else "rwx------") | ||
dir / "config.json" | ||
} | ||
|
||
val java8Home = | ||
os.Path(os.proc(TestUtil.cs, "java-home", "--jvm", "zulu:8").call().out.trim(), os.pwd) | ||
|
||
val extraEnv = Map( | ||
"JAVA_HOME" -> java8Home.toString, | ||
"PATH" -> ((java8Home / "bin").toString + File.pathSeparator + System.getenv("PATH")), | ||
"SCALA_CLI_CONFIG" -> configFile.toString | ||
) | ||
|
||
val pgpCreated = os.proc( | ||
TestUtil.cli, | ||
"--power", | ||
"config", | ||
"--create-pgp-key", | ||
"--email", | ||
"[email protected]", | ||
"--pgp-password", | ||
"none", | ||
"--force-jvm-signing-cli", | ||
"-v", | ||
"-v", | ||
"-v" | ||
) | ||
.call(cwd = root, env = extraEnv, mergeErrIntoOut = true) | ||
TestUtil.retryOnCi() { | ||
TestInputs().fromRoot { root => | ||
val configFile = { | ||
val dir = root / "config" | ||
os.makeDir.all(dir, perms = if (Properties.isWin) null else "rwx------") | ||
dir / "config.json" | ||
} | ||
|
||
val java8Home = | ||
os.Path(os.proc(TestUtil.cs, "java-home", "--jvm", "zulu:8").call().out.trim(), os.pwd) | ||
|
||
val extraEnv = Map( | ||
"JAVA_HOME" -> java8Home.toString, | ||
"PATH" -> ((java8Home / "bin").toString + File.pathSeparator + System.getenv("PATH")), | ||
"SCALA_CLI_CONFIG" -> configFile.toString | ||
) | ||
|
||
val pgpCreated = os.proc( | ||
TestUtil.cli, | ||
"--power", | ||
"config", | ||
"--create-pgp-key", | ||
"--email", | ||
"[email protected]", | ||
"--pgp-password", | ||
"none", | ||
"--force-jvm-signing-cli", | ||
"-v", | ||
"-v", | ||
"-v" | ||
) | ||
.call(cwd = root, env = extraEnv, mergeErrIntoOut = true) | ||
|
||
val javaCommandLine = pgpCreated.out.text() | ||
.linesIterator | ||
.dropWhile(!_.equals(" Running")).slice(1, 2) | ||
.toSeq | ||
val javaCommandLine = pgpCreated.out.text() | ||
.linesIterator | ||
.dropWhile(!_.equals(" Running")).slice(1, 2) | ||
.toSeq | ||
|
||
expect(javaCommandLine.nonEmpty) | ||
expect(javaCommandLine.head.contains("17")) | ||
expect(javaCommandLine.nonEmpty) | ||
expect(javaCommandLine.head.contains("17")) | ||
|
||
val passwordInConfig = os.proc(TestUtil.cli, "--power", "config", "pgp.secret-key-password") | ||
.call(cwd = root, env = extraEnv, stderr = os.Pipe) | ||
expect(passwordInConfig.out.text().isEmpty()) | ||
val passwordInConfig = | ||
os.proc(TestUtil.cli, "--power", "config", "pgp.secret-key-password") | ||
.call(cwd = root, env = extraEnv, stderr = os.Pipe) | ||
expect(passwordInConfig.out.text().isEmpty()) | ||
|
||
val secretKey = os.proc(TestUtil.cli, "--power", "config", "pgp.secret-key") | ||
.call(cwd = root, env = extraEnv, stderr = os.Pipe) | ||
.out.trim() | ||
val rawPublicKey = | ||
os.proc(TestUtil.cli, "--power", "config", "pgp.public-key", "--password-value") | ||
val secretKey = os.proc(TestUtil.cli, "--power", "config", "pgp.secret-key") | ||
.call(cwd = root, env = extraEnv, stderr = os.Pipe) | ||
.out.trim() | ||
|
||
val tmpFile = root / "test-file" | ||
val tmpFileAsc = root / "test-file.asc" | ||
os.write(tmpFile, "Hello") | ||
|
||
val q = "\"" | ||
|
||
def maybeEscape(arg: String): String = | ||
if (Properties.isWin) q + arg + q | ||
else arg | ||
|
||
os.proc( | ||
TestUtil.cli, | ||
"--power", | ||
"pgp", | ||
"sign", | ||
"--secret-key", | ||
maybeEscape(secretKey), | ||
tmpFile | ||
).call(cwd = root, stdin = os.Inherit, stdout = os.Inherit, env = extraEnv) | ||
|
||
val pubKeyFile = root / "key.pub" | ||
os.write(pubKeyFile, rawPublicKey) | ||
val verifyResult = | ||
os.proc(TestUtil.cli, "--power", "pgp", "verify", "--key", pubKeyFile, tmpFileAsc) | ||
.call(cwd = root, env = extraEnv, mergeErrIntoOut = true) | ||
|
||
expect(verifyResult.out.text().contains("valid signature")) | ||
val rawPublicKey = | ||
os.proc(TestUtil.cli, "--power", "config", "pgp.public-key", "--password-value") | ||
.call(cwd = root, env = extraEnv, stderr = os.Pipe) | ||
.out.trim() | ||
|
||
val tmpFile = root / "test-file" | ||
val tmpFileAsc = root / "test-file.asc" | ||
os.write(tmpFile, "Hello") | ||
|
||
val q = "\"" | ||
|
||
def maybeEscape(arg: String): String = | ||
if (Properties.isWin) q + arg + q | ||
else arg | ||
|
||
os.proc( | ||
TestUtil.cli, | ||
"--power", | ||
"pgp", | ||
"sign", | ||
"--secret-key", | ||
maybeEscape(secretKey), | ||
tmpFile | ||
).call(cwd = root, stdin = os.Inherit, stdout = os.Inherit, env = extraEnv) | ||
|
||
val pubKeyFile = root / "key.pub" | ||
os.write(pubKeyFile, rawPublicKey) | ||
val verifyResult = | ||
os.proc(TestUtil.cli, "--power", "pgp", "verify", "--key", pubKeyFile, tmpFileAsc) | ||
.call(cwd = root, env = extraEnv, mergeErrIntoOut = true) | ||
|
||
expect(verifyResult.out.text().contains("valid signature")) | ||
} | ||
} | ||
|
||
} | ||
|
||
def createDefaultPgpKeyTest(pgpPasswordOption: String): Unit = { | ||
|
Oops, something went wrong.