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

View file

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

View file

@ -9,6 +9,9 @@
"source.organizeImports": true
}
},
"[github-actions-workflow]": {
"editor.tabSize": 2
},
"editor.formatOnSave": true,
"better-comments.tags": [
{

View file

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

View file

@ -178,6 +178,13 @@ public class App {
*/
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 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-path", "The path on the CDN used for downloading files.").withRequiredArg()
.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",
"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);
@ -978,6 +988,8 @@ public class App {
LogManager.warn("Base cdn path set to " + baseCdnPath);
}
disableHttp2 = options.has("disable-http2");
allowAllSslCerts = options.has("allow-all-ssl-certs");
if (allowAllSslCerts) {
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 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);
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();
rightPanel.setLayout(new BorderLayout());
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
@ -478,7 +477,6 @@ public class AccountsTab extends JPanel implements Tab, RelocalizationListener {
0,
GetText.tr("Logging Into Minecraft"),
"Aborting login for " + viewModel.getLoginUsername());
dialog.setName("loginDialog");
dialog.addThread(new Thread(() -> {
viewModel.login();
dialog.close();

View file

@ -81,7 +81,7 @@ public class AbstractUiTest extends AssertJSwingTestCaseTemplate {
// start the application
ApplicationLauncher.application(App.class)
.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(),
"--working-dir=" + workingDir.toString())
.start();
@ -115,6 +115,7 @@ public class AbstractUiTest extends AssertJSwingTestCaseTemplate {
MockHelper.mockFileResponse(mockServer, "version.json");
MockHelper.mockFileResponse(mockServer, "config.json");
MockHelper.mockFileResponse(mockServer, "minecraft_versions.json");
MockHelper.mockFileResponse(mockServer, "java_runtimes.json");
MockHelper.mockFileResponse(mockServer, "lwjgl.json");
// files from Minecraft servers

View file

@ -84,9 +84,6 @@ public class BasicLauncherUiTest extends AbstractUiTest {
// login
loginButton.click();
DialogFixture loginDialog = WindowFinder.findDialog("loginDialog").using(robot());
loginDialog.requireVisible();
// give it 5 seconds
Pause.pause(5, TimeUnit.SECONDS);
@ -129,7 +126,7 @@ public class BasicLauncherUiTest extends AbstractUiTest {
public boolean test() {
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) {
@Override

View file

@ -46,6 +46,8 @@ public class MockHelper {
static {
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("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("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"));
@ -121,6 +123,13 @@ public class MockHelper {
minecraftVersions.size = (int) Files.size(mockedFilePaths.get("minecraft_versions.json"));
minecraftVersions.sha1 = Hashing.sha1(mockedFilePaths.get("minecraft_versions.json")).toString();
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) {
e.printStackTrace();
}

View file

@ -2,6 +2,7 @@
"useLwjglReplacement": false,
"analytics": {
"enabled": false,
"enabledVersion": "0.0.0.0",
"percentage": 0,
"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": {}
}