Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functional and acceptance test harnesses and spl2 tests and bugfixes #102

Merged
merged 60 commits into from
Sep 8, 2023

Conversation

fantavlik
Copy link
Collaborator

@fantavlik fantavlik commented Aug 25, 2023

Added testing

Most of the Splunk Extension code depends on the vscode package which requires a running instance of vscode to work. This PR adds testing harnesses using @vscode/test-electron using these resources as guidance:

Functional tests: these import the code directly so that individual functions can be tested similar to unit tests but with a running instance of vscode
Acceptance tests: these actually install the packaged .vsix version of the Extension into running VSCode instance in the testing environment. Unfortunately I wasn't able to get a meaningful test working yet with this but it was quite a lot of work just getting the harness working across platforms so I thought it would still be useful to work off of moving forward.

Bugfixes

  • After adding functional tests this run actually uncovered a Windows Java installation bug
  • Fixed a Linux bug that could apply to any OS specifying a Java version of the format openjdk version "17.0.8.1" or similar
  • Fixed an issue with hardcoded java.exe being checked for Linux/Mac
  • Fixed an issue with installation continuing/looping due to functions not being returned after resolve()
  • Improved error messaging for common unauthenticated and endpoint-not-found scenarios

Bump LSP

  • Bumped the SPL2 language server to the latest version 2.0.375

@@ -53,6 +53,7 @@ export async function installMissingSpl2Requirements(context: ExtensionContext,
}
} catch (err) {
reject(`Error retrieving configuration '${configKeyJavaPath}', err: ${err}`);
return Promise.resolve();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new Promise statements fix an issue @JasonConger and I saw during a demo of mine where the installation process can get stuck in a loop - we were not actually exiting the function after resolving the promise for a bunch of cases.

}
} else if (!javaLoc) {
} else if (!javaLoc && termsStatus !== TermsAcceptanceStatus.Accepted) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes and issue where we were prompting to accept terms even if you already had accepted them

try {
const javaVerCmd = child_process.spawnSync(javaLoc, ['-version'], { encoding : 'utf8' });
if (!javaVerCmd || javaVerCmd.stdout) {
return false;
}
// java -version actually writes to stderr so check for a match there
const match = javaVerCmd.stderr.toString().match(/version \"([0-9]+)\.[0-9]+\.[0-9]\"/m);
output = javaVerCmd.stderr.toString();
const match = output.match(/version \"([0-9]+)\.[0-9]+\.[0-9].*\"/m);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a linux issue where Java version of format openjdk version "17.0.8.1" was not being parsed correctly

progressBar.text = `${progressBarText}...`;
await extract(zipfilePath, { dir: extractPath, onEntry: (entry, zipfile) => {
if (entry.fileName.endsWith(path.join('bin', 'java.exe'))) {
if (entry.fileName.endsWith('bin/java.exe') || entry.fileName.endsWith('bin\\java.exe')) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addresses a Windows installation issue found during testing!

@fantavlik fantavlik changed the title Add functional and acceptance test harnesses and spl2 tests Add functional and acceptance test harnesses and spl2 tests and bugfixes Aug 25, 2023
out/notebooks/spl2/installer.ts Show resolved Hide resolved
@JasonConger JasonConger merged commit b1b386f into master Sep 8, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants