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

make -V/--version fast on Windows #8508

Merged
merged 1 commit into from Feb 21, 2018

Conversation

czlowieq
Copy link
Contributor

Do not run logstash when checking version on windows

Fixes #5526

@original-brownbear
Copy link
Member

Jenkins test this please

@czlowieq
Copy link
Contributor Author

I've seen some windows tests in logstash/qa/scripts/windows/acceptance/logstash_release_acceptance.ps1. Should I put this test(s) in there too? I've noticed that there is no version number in environment variables, which could make it tricky.

*nix version tests use rspec, so there is the const containing the version. But I'm not sure if it is possible to test the batch file like this too.

@original-brownbear
Copy link
Member

@jakelandis @colinsurprenant I think the above is a question for one of you guys :)

@jordansissel
Copy link
Contributor

I would like tests added for this. The proposal is simple (shortcut showing the verson) but the implementation is complex and fragile (nobody on the team is an expert in DOS batch, so this may break without us realizing it).

bin/logstash.bat Outdated
goto end

:version
set "LOGSTASH_VERSION_FILE1=%LOGSTASH_HOME%/logstash-core/versions-gem-copy.yml"
Copy link
Member

Choose a reason for hiding this comment

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

should this be LS_HOME instead of LOGSTASH_HOME? This is the first reference to LOGSTASH_HOME I see in this file, but LS_HOME is referenced several times.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Fixed.

@czlowieq
Copy link
Contributor Author

@jordansissel I totally agree that it needs to be tested. I'm not sure how to do it though. It seems that there are tests in PowerShell script, but there is no version number variable, as stated above. Putting the same logic to extract the version number from the same files as in batch is doable, but I'm not sure if it makes sense.

Unless it should be tested in rspec (not sure if it's suitable for rspec tests).

@jakelandis jakelandis removed their request for review November 6, 2017 15:01
@andrewvc
Copy link
Contributor

@czlowieq I think rspec tests are fine for this case. Have you seen the tests in https://github.com/elastic/logstash/tree/master/qa/scripts/windows ?

@andrewvc
Copy link
Contributor

Blah, I misspoke, those are all powershell, but that should be fine :)

@czlowieq
Copy link
Contributor Author

@andrewvc Yeah, seen those. But still, I'm not sure if there is a version number I can easily get in those scripts, so I can compare it with the command result. Any ideas?

@elastic elastic deleted a comment from elasticmachine Nov 14, 2017
@colinsurprenant
Copy link
Contributor

what this would require is integration testing and we don't have a good story for that yet on Windows. Personally I am ok if we end up merging this without test IIF it has been throughly manually tested and we have other tests for the versions.yml file & content.

I will go ahead and review this shortly. Let me know if anyone has concerns in moving forward like this.

bin/logstash.bat Outdated
if "%LS_HOME%" == "" (
for %%a in ("%~dp0..") do set "LS_HOME=%%~fa"
)

Copy link
Contributor

Choose a reason for hiding this comment

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

this LS_HOME handling is no required since the first thing this bat file does is to call setup.bat which handle the setup of LS_HOME see

logstash/bin/setup.bat

Lines 5 to 19 in 40827a5

rem ### 1: determine logstash home
rem to do this, we strip from the path until we
rem find bin, and then strip bin (there is an assumption here that there is no
rem nested directory under bin also named bin)
for %%I in (%SCRIPT%) do set LS_HOME=%%~dpI
:ls_home_loop
for %%I in ("%LS_HOME:~1,-1%") do set DIRNAME=%%~nxI
if not "%DIRNAME%" == "bin" (
for %%I in ("%LS_HOME%..") do set LS_HOME=%%~dpfI
goto ls_home_loop
)
for %%I in ("%LS_HOME%..") do set LS_HOME=%%~dpfI

bin/logstash.bat Outdated
)
)
)
echo "logstash !LOGSTASH_VERSION!"

Copy link
Contributor

Choose a reason for hiding this comment

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

++ this seems consistent with the bash version logic. will manually test shortly. 👍

@colinsurprenant
Copy link
Contributor

@czlowieq good stuff. I left a few comments - please check about the LS_HOME handling. Other than that I will perform manual test and we should be good to go.

@jsvd jsvd removed the v6.1.0 label Dec 11, 2017
@colinsurprenant
Copy link
Contributor

@czlowieq could you please rebase and resolve conflicts? sorry about that, once done I will prioritize testing so we can go ahead and merge. Thanks.

@czlowieq
Copy link
Contributor Author

czlowieq commented Jan 9, 2018

@colinsurprenant Should I squash the commits into one or leave them as is?

@colinsurprenant
Copy link
Contributor

@czlowieq sure - it will have to be done anyway before merging so ...

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@colinsurprenant
Copy link
Contributor

Jenkins please test this

bin/logstash.bat Outdated
)
)
)
echo "logstash !LOGSTASH_VERSION!"
Copy link
Contributor

Choose a reason for hiding this comment

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

this outputs the following:

C:\Users\colin\dev\logstash (pr/8508)
λ bin\logstash -V
"logstash 7.0.0-alpha1"

C:\Users\colin\dev\logstash (pr/8508)
λ bin\logstash --version
"logstash 7.0.0-alpha1"

To be consistent with the Linux behaviour we should remote the quotes from the output, it should be

echo logstash !LOGSTASH_VERSION!

@colinsurprenant
Copy link
Contributor

@czlowieq while manually testing, I noticed that the version string is quoted which is different from the Linux output. Please correct this, then we should be good.
Thanks for your patience.

@ppawlikmb
Copy link

@colinsurprenant Thanks. Fixed it.

@colinsurprenant
Copy link
Contributor

LGTM - merging!

@colinsurprenant colinsurprenant merged commit 30401e3 into elastic:master Feb 21, 2018
@colinsurprenant
Copy link
Contributor

Merged into master and 6.x
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants