fix: ui tests failing constantly

This commit is contained in:
Ryan Dowling 2023-07-15 09:40:00 +10:00
parent 493c9ae723
commit 2b64bd1620
No known key found for this signature in database
GPG key ID: 5539FCDB88950EFD
13 changed files with 66 additions and 26 deletions

View file

@ -8,3 +8,9 @@ indent_style = space
indent_size = 4 indent_size = 4
trim_trailing_whitespace = true trim_trailing_whitespace = true
max_line_length = 120 max_line_length = 120
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2

View file

@ -15,9 +15,9 @@ jobs:
- name: Set up JDK 1.8 - name: Set up JDK 1.8
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: "temurin"
java-version: 8 java-version: 8
cache: 'gradle' cache: "gradle"
- name: Check license headers - name: Check license headers
run: ./gradlew checkLicenses run: ./gradlew checkLicenses
@ -27,7 +27,7 @@ jobs:
strategy: strategy:
matrix: matrix:
java-version: ["8", "11", "17", "19"] # LTS + Latest java-version: ["8", "11", "17", "19"] # LTS + Latest
os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ] os: ["ubuntu-latest", "macos-latest", "windows-latest"]
name: Java ${{ matrix.java-version }} (${{ matrix.os }}) Tests name: Java ${{ matrix.java-version }} (${{ matrix.os }}) Tests
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -35,15 +35,15 @@ jobs:
- name: Set up JDK ${{ matrix.java-version }} - name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: "temurin"
java-version: ${{ matrix.java-version }} java-version: ${{ matrix.java-version }}
cache: 'gradle' cache: "gradle"
- name: Run Unit Tests - name: Run Unit Tests
run: ./gradlew --no-daemon test --tests com.atlauncher.* run: ./gradlew --no-daemon test --tests com.atlauncher.*
- name: Run UI Tests - name: Run UI Tests
uses: GabrielBB/xvfb-action@v1 uses: coactions/setup-xvfb@v1
if: matrix.os != 'macos-latest' # skipped on OSX as not working and no way to test fixes if: matrix.os != 'macos-latest' # skipped on OSX as not working and no way to test fixes
continue-on-error: ${{ matrix.os == 'windows-latest' }} # Windows seems flaky continue-on-error: ${{ matrix.os == 'windows-latest' }} # Windows seems flaky
with: with:
@ -60,9 +60,9 @@ jobs:
- name: Set up JDK 1.8 - name: Set up JDK 1.8
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: "temurin"
java-version: 8 java-version: 8
cache: 'gradle' cache: "gradle"
- name: Read version - name: Read version
id: version id: version
@ -77,7 +77,7 @@ jobs:
with: with:
string: ${{ steps.version.outputs.text }} string: ${{ steps.version.outputs.text }}
pattern: '([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\.?\w*' pattern: '([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\.?\w*'
replace-with: '$1' replace-with: "$1"
- name: Build - name: Build
run: ./gradlew build -x test run: ./gradlew build -x test
@ -111,7 +111,7 @@ jobs:
with: with:
string: ${{ steps.changelog.outputs.text }} string: ${{ steps.changelog.outputs.text }}
pattern: '^.*?(### (New Features|Fixes|Misc)\n.*)$' pattern: '^.*?(### (New Features|Fixes|Misc)\n.*)$'
replace-with: '$1' replace-with: "$1"
flags: gs flags: gs
- name: Clean up the changelog to only have used sections - name: Clean up the changelog to only have used sections
@ -190,12 +190,12 @@ jobs:
- name: Commit new version/CHANGELOG file - name: Commit new version/CHANGELOG file
uses: EndBug/add-and-commit@v7.0.0 uses: EndBug/add-and-commit@v7.0.0
with: with:
add: 'CHANGELOG.md src/main/resources/version' add: "CHANGELOG.md src/main/resources/version"
message: 'chore: bump version' message: "chore: bump version"
- name: Add comment, remove label and then close issues labeled with 'awaiting-release' - name: Add comment, remove label and then close issues labeled with 'awaiting-release'
uses: ./.github/actions/label-cleanup uses: ./.github/actions/label-cleanup
with: with:
label: 'awaiting-release' label: "awaiting-release"
comment: 'This has been fixed with version ${{ needs.build.outputs.clean-version }}' comment: "This has been fixed with version ${{ needs.build.outputs.clean-version }}"
token: ${{ secrets.BOT_GITHUB_TOKEN }} token: ${{ secrets.BOT_GITHUB_TOKEN }}

View file

@ -35,5 +35,5 @@ jobs:
- name: Commit changed files - name: Commit changed files
uses: EndBug/add-and-commit@v7.0.0 uses: EndBug/add-and-commit@v7.0.0
with: with:
add: 'packaging/aur/' add: "packaging/aur/"
message: 'chore: update aur packages' message: "chore: update aur packages"

View file

@ -9,6 +9,9 @@
"source.organizeImports": true "source.organizeImports": true
} }
}, },
"[github-actions-workflow]": {
"editor.tabSize": 2
},
"editor.formatOnSave": true, "editor.formatOnSave": true,
"better-comments.tags": [ "better-comments.tags": [
{ {
@ -30,4 +33,4 @@
"java.codeGeneration.generateComments": true, "java.codeGeneration.generateComments": true,
"git.inputValidationLength": 100, "git.inputValidationLength": 100,
"java.compile.nullAnalysis.mode": "automatic", "java.compile.nullAnalysis.mode": "automatic",
} }

View file

@ -15,4 +15,5 @@ This changelog only contains the changes that are unreleased. For changes for in
### Misc ### Misc
- Upgrade to Gradle 8.2 - Upgrade to Gradle 8.2
- Update dependency versions - Update dependency versions
- Fix ui tests failing constantly

View file

@ -178,6 +178,13 @@ public class App {
*/ */
public static Path workingDir = null; public static Path workingDir = null;
/**
* This will tell the launcher to disable HTTP2 connections.
* <p/>
* --disable-http2
*/
public static boolean disableHttp2 = false;
/** /**
* This will tell the launcher to allow all SSL certs regardless of validity. * This will tell the launcher to allow all SSL certs regardless of validity.
* This is insecure and only intended for development purposes. * This is insecure and only intended for development purposes.
@ -877,6 +884,9 @@ public class App {
parser.accepts("base-cdn-domain", "The base CDN domain.").withRequiredArg().ofType(String.class); parser.accepts("base-cdn-domain", "The base CDN domain.").withRequiredArg().ofType(String.class);
parser.accepts("base-cdn-path", "The path on the CDN used for downloading files.").withRequiredArg() parser.accepts("base-cdn-path", "The path on the CDN used for downloading files.").withRequiredArg()
.ofType(String.class); .ofType(String.class);
parser.accepts("disable-http2",
"This will tell the launcher to disable HTTP2 connections.")
.withOptionalArg().ofType(Boolean.class);
parser.accepts("allow-all-ssl-certs", parser.accepts("allow-all-ssl-certs",
"This will tell the launcher to allow all SSL certs regardless of validity. This is insecure and only intended for development purposes.") "This will tell the launcher to allow all SSL certs regardless of validity. This is insecure and only intended for development purposes.")
.withOptionalArg().ofType(Boolean.class); .withOptionalArg().ofType(Boolean.class);
@ -978,6 +988,8 @@ public class App {
LogManager.warn("Base cdn path set to " + baseCdnPath); LogManager.warn("Base cdn path set to " + baseCdnPath);
} }
disableHttp2 = options.has("disable-http2");
allowAllSslCerts = options.has("allow-all-ssl-certs"); allowAllSslCerts = options.has("allow-all-ssl-certs");
if (allowAllSslCerts) { if (allowAllSslCerts) {
LogManager.warn("Allowing all ssl certs. This is insecure and should only be used for development."); LogManager.warn("Allowing all ssl certs. This is insecure and should only be used for development.");

View file

@ -52,7 +52,8 @@ import okhttp3.tls.HandshakeCertificates;
public final class Network { public final class Network {
public static Cache CACHE = new Cache(FileSystem.CACHE.toFile(), 100 * 1024 * 1024); // 100MB cache public static Cache CACHE = new Cache(FileSystem.CACHE.toFile(), 100 * 1024 * 1024); // 100MB cache
private static List<Protocol> protocols = App.settings.dontUseHttp2 ? Arrays.asList(Protocol.HTTP_1_1) private static List<Protocol> protocols = (App.disableHttp2 || App.settings.dontUseHttp2)
? Arrays.asList(Protocol.HTTP_1_1)
: Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1); : Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1);
public static OkHttpClient CLIENT = new OkHttpClient.Builder().protocols(protocols) public static OkHttpClient CLIENT = new OkHttpClient.Builder().protocols(protocols)

View file

@ -119,7 +119,6 @@ public class AccountsTab extends JPanel implements Tab, RelocalizationListener {
JPanel rightPanel = new JPanel(); JPanel rightPanel = new JPanel();
rightPanel.setLayout(new BorderLayout()); rightPanel.setLayout(new BorderLayout());
JPanel bottomPanel = new JPanel(); JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new GridBagLayout()); bottomPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
@ -478,7 +477,6 @@ public class AccountsTab extends JPanel implements Tab, RelocalizationListener {
0, 0,
GetText.tr("Logging Into Minecraft"), GetText.tr("Logging Into Minecraft"),
"Aborting login for " + viewModel.getLoginUsername()); "Aborting login for " + viewModel.getLoginUsername());
dialog.setName("loginDialog");
dialog.addThread(new Thread(() -> { dialog.addThread(new Thread(() -> {
viewModel.login(); viewModel.login();
dialog.close(); dialog.close();

View file

@ -81,7 +81,7 @@ public class AbstractUiTest extends AssertJSwingTestCaseTemplate {
// start the application // start the application
ApplicationLauncher.application(App.class) ApplicationLauncher.application(App.class)
.withArgs("--skip-setup-dialog", "--disable-analytics", "--disable-error-reporting", .withArgs("--skip-setup-dialog", "--disable-analytics", "--disable-error-reporting",
"--skip-tray-integration", "--no-launcher-update", "--proxy-type=SOCKS", "--skip-tray-integration", "--no-launcher-update", "--disable-http2", "--proxy-type=SOCKS",
"--proxy-host=127.0.0.1", "--proxy-port=" + mockServer.getPort(), "--proxy-host=127.0.0.1", "--proxy-port=" + mockServer.getPort(),
"--working-dir=" + workingDir.toString()) "--working-dir=" + workingDir.toString())
.start(); .start();
@ -115,6 +115,7 @@ public class AbstractUiTest extends AssertJSwingTestCaseTemplate {
MockHelper.mockFileResponse(mockServer, "version.json"); MockHelper.mockFileResponse(mockServer, "version.json");
MockHelper.mockFileResponse(mockServer, "config.json"); MockHelper.mockFileResponse(mockServer, "config.json");
MockHelper.mockFileResponse(mockServer, "minecraft_versions.json"); MockHelper.mockFileResponse(mockServer, "minecraft_versions.json");
MockHelper.mockFileResponse(mockServer, "java_runtimes.json");
MockHelper.mockFileResponse(mockServer, "lwjgl.json"); MockHelper.mockFileResponse(mockServer, "lwjgl.json");
// files from Minecraft servers // files from Minecraft servers

View file

@ -84,9 +84,6 @@ public class BasicLauncherUiTest extends AbstractUiTest {
// login // login
loginButton.click(); loginButton.click();
DialogFixture loginDialog = WindowFinder.findDialog("loginDialog").using(robot());
loginDialog.requireVisible();
// give it 5 seconds // give it 5 seconds
Pause.pause(5, TimeUnit.SECONDS); Pause.pause(5, TimeUnit.SECONDS);
@ -129,7 +126,7 @@ public class BasicLauncherUiTest extends AbstractUiTest {
public boolean test() { public boolean test() {
return Files.exists(workingDir.resolve("instances/Minecraft1164/instance.json")); return Files.exists(workingDir.resolve("instances/Minecraft1164/instance.json"));
} }
}, Timeout.timeout(5, TimeUnit.MINUTES)); }, Timeout.timeout(30, TimeUnit.SECONDS));
DialogFixture installSuccessDialog = WindowFinder.findDialog(new GenericTypeMatcher<Dialog>(Dialog.class) { DialogFixture installSuccessDialog = WindowFinder.findDialog(new GenericTypeMatcher<Dialog>(Dialog.class) {
@Override @Override

View file

@ -46,6 +46,8 @@ public class MockHelper {
static { static {
mockedFilePaths.put("newnews.json", Paths.get("src/test/resources/mocks/download-nodecdn-net/newnews.json")); mockedFilePaths.put("newnews.json", Paths.get("src/test/resources/mocks/download-nodecdn-net/newnews.json"));
mockedFilePaths.put("runtimes.json", Paths.get("src/test/resources/mocks/download-nodecdn-net/runtimes.json")); mockedFilePaths.put("runtimes.json", Paths.get("src/test/resources/mocks/download-nodecdn-net/runtimes.json"));
mockedFilePaths.put("java_runtimes.json",
Paths.get("src/test/resources/mocks/download-nodecdn-net/java_runtimes.json"));
mockedFilePaths.put("users.json", Paths.get("src/test/resources/mocks/download-nodecdn-net/users.json")); mockedFilePaths.put("users.json", Paths.get("src/test/resources/mocks/download-nodecdn-net/users.json"));
mockedFilePaths.put("packsnew.json", Paths.get("src/test/resources/mocks/download-nodecdn-net/packsnew.json")); mockedFilePaths.put("packsnew.json", Paths.get("src/test/resources/mocks/download-nodecdn-net/packsnew.json"));
mockedFilePaths.put("version.json", Paths.get("src/test/resources/mocks/download-nodecdn-net/version.json")); mockedFilePaths.put("version.json", Paths.get("src/test/resources/mocks/download-nodecdn-net/version.json"));
@ -121,6 +123,13 @@ public class MockHelper {
minecraftVersions.size = (int) Files.size(mockedFilePaths.get("minecraft_versions.json")); minecraftVersions.size = (int) Files.size(mockedFilePaths.get("minecraft_versions.json"));
minecraftVersions.sha1 = Hashing.sha1(mockedFilePaths.get("minecraft_versions.json")).toString(); minecraftVersions.sha1 = Hashing.sha1(mockedFilePaths.get("minecraft_versions.json")).toString();
downloadableFiles.add(minecraftVersions); downloadableFiles.add(minecraftVersions);
DownloadableFile javaRuntimes = new DownloadableFile();
javaRuntimes.name = "java_runtimes.json";
javaRuntimes.folder = "json";
javaRuntimes.size = (int) Files.size(mockedFilePaths.get("java_runtimes.json"));
javaRuntimes.sha1 = Hashing.sha1(mockedFilePaths.get("java_runtimes.json")).toString();
downloadableFiles.add(javaRuntimes);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -2,6 +2,7 @@
"useLwjglReplacement": false, "useLwjglReplacement": false,
"analytics": { "analytics": {
"enabled": false, "enabled": false,
"enabledVersion": "0.0.0.0",
"percentage": 0, "percentage": 0,
"autoSendInSeconds": 300 "autoSendInSeconds": 300
}, },

View file

@ -0,0 +1,11 @@
{
"linux": {},
"linux-i386": {},
"mac-os": {},
"mac-os-arm64": {},
"windows-arm64": {},
"windows-x64": {},
"windows-x86": {},
"linux-arm": {},
"linux-arm64": {}
}