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

Automate prism service. #229

Merged
merged 17 commits into from
Oct 22, 2017

Conversation

dmitraver
Copy link
Contributor

Fixes #159.

-Installs prism on travis.
-Creates new gradle task to download and start prism locally. Prism is only downloaded if it wasn't downloaded before. To start prism locally do:

./gradlew startPrism

@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Oct 4, 2017
@dmitry-avershin
Copy link

@thinkingserious hi, should the build succeed now with my change or do you need to setup something on Travis first? 🤔

fi
}

install
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a new line at the end of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -0,0 +1,42 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

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

The Travis builds are currently failing because this file does not have execute permissions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, might be, I haven't seen chmod in any other projects travis.yaml files though.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not suggesting this be done via Travis. Try the following and commit the changes:
chmod a+x test/prism.sh
Note that this won't work if you're on a Windows box. If that's the case, then I can make the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it doesn’t matter as executable flag is stored in inode and it’s not a part of the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct. This particular issue is resolved with a21f3da

Copy link
Contributor Author

@dmitraver dmitraver Oct 11, 2017

Choose a reason for hiding this comment

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

@andy-trimble I still don't understand how this could solve the problem, permissions are stored in inode which is a structure that is stored somewhere on OS. chmod updates the inode. Could you plz explain where my understanding is wrong?

Copy link
Contributor

Choose a reason for hiding this comment

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

@dmitraver It is no longer a problem. You fixed it with commit a21f3da.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andy-trimble yeah but for me this not enough, I want to figure out why its fixed behind the curtains. Just curious ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

@dmitraver At the time that I made this comment, the Travis build was failing with the following message /home/travis/.travis/job_stages: line 57: ./test/prism.sh: Permission denied This indicates that the execute permission on the file were not present. Github preserves file permissions, and when Travis checked it out to execute the build, it was not executable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andy-trimble yup, I figured out that git actually preserves the file permissions .
git cat-file -p $hash permission bits are stored there as well.

echo "Prism is not installed."
install
run
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a new line at the end of this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@thinkingserious
Copy link
Contributor

Thanks for the review @andy-trimble!

@dmitraver
Copy link
Contributor Author

@andy-trimble, fixed the issues you mentioned.

@andy-trimble
Copy link
Contributor

@dmitraver The Travis build is still failing because Prism is not started up before the tests are run.

@dmitraver
Copy link
Contributor Author

Hmm, I think before_script in travis.yaml does exactly that, maybe adding a sleep should help

@andy-trimble
Copy link
Contributor

@dmitraver The before_script only installs Prism. It does not start the process.

@thinkingserious thinkingserious added difficulty: hard fix is hard in difficulty hacktoberfest labels Oct 10, 2017
@dmitraver
Copy link
Contributor Author

@andy-trimble sure, you are right, my original understanding was that it is run by some other mean but I guess I'm wrong. I will update the scripts tomorrow.

@dmitraver
Copy link
Contributor Author

@andy-trimble, @thinkingserious I fixed the prism startup. Build is still failing because of the issue Andy mentioned.

@thinkingserious thinkingserious dismissed andy-trimble’s stale review October 11, 2017 15:29

dmitraver has made the updates

@thinkingserious
Copy link
Contributor

Which issue @dmitraver? It seems like you fixed the issues Andy mentioned.

@dmitraver
Copy link
Contributor Author

@thinkingserious sorry, it was in his branch
b9647e4.

Builds are still failing due to IOExceptions on travis.

@andy-trimble
Copy link
Contributor

@dmitraver The current exceptions in Travis are due to Prism not running. It seems that Prism is installed and started, but the process is killed before continuing on to the testing portion of the build.

@thinkingserious
Copy link
Contributor

Can you add that to travis.yml please?

@thinkingserious
Copy link
Contributor

@dmitraver, maybe try not running prism in the background.

@andy-trimble
Copy link
Contributor

andy-trimble commented Oct 11, 2017

@dmitraver In my PR here, I'm using Groovy to kick off the Prism process, thus avoiding having Gradle shut down the process before the tests are run. Additionally, it waits until the Prism port is attached so that we don't have a race condition. Feel free to take whatever you need from that PR to keep your change moving forward. I really only made it as a reference implementation. I'm happy for you to get the Hacktoberfest credit, I'm already getting my swag. 😄

@dmitraver
Copy link
Contributor Author

@thinkingserious running prism not in background seems to hang the process. I will try to experiment with it a bit. Locally it works fine.

@dmitraver
Copy link
Contributor Author

dmitraver commented Oct 15, 2017

hi @thinkingserious, @andy-trimble I've done some testing locally and found why the tests are failing on Jenkins. Most of the tests have this check

if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
which resolves to the first branch on Travis because the TRAVIS env variable is set to 'true'. MOCK_HOST variable is not set on Travis so it basically uses empty string as a host and fails. I've tried to set the variable in Travis to localhost but it tries to use SSL then cause it assumes HTTPS. I think its because this branch is not intended to be used for local testing. So there are two solutions to this problem, first is to provide a real host with https connection for testing and set MOCK_HOST var in Travis for it. Second one is to remove this logic and only use localhost for testing. Let me know what is the behaviour you want and I will adapt the code.

@andy-trimble
Copy link
Contributor

@dmitraver The TRAVIS environment variable isn't actually being set in Travis. You can verify this in the "Setting environment variables from .travis.yml" section in the Travis log.

Also, MOCK_HOST is being set to be localhost:4010 (as you can see in the Travis logs).

@andy-trimble
Copy link
Contributor

@dmitraver One thing you could try is to insert a ps -ef | grep prism into the before_script section, after the sleep command. This should tell you if prism is actually running.

@dmitraver
Copy link
Contributor Author

@andy-trimble hmm, this is actually strange cause I used their docker environment for testing and variable resolves to true there. The prism is running, you can see it from the output in travis. I also added the lsof command that checks that its running on port as intended. I still believe its due to the issue I pointed above as the docker environment is exactly the same as the real environment, the only thing that is different is that you need to run all your before scripts yourself. I can print the env variables.

@dmitraver
Copy link
Contributor Author

@andy-trimble also I tried to set mock host variable in the last change and I started getting different exceptions on travis which is now that it can't connect with https connection to localhost so I guess this variable is not set at all.

@dmitraver
Copy link
Contributor Author

@andy-trimble plz check the output of my last change https://travis-ci.org/sendgrid/sendgrid-java/jobs/290320581.

0.00s$ echo TRAVIS $TRAVIS
TRAVIS true
before_script.2
0.00s$ echo MOCK_HOST $MOCK_HOST
MOCK_HOST

so the travis variable is set but mock host is not.

@dmitraver
Copy link
Contributor Author

dmitraver commented Oct 20, 2017 via email

@dmitraver
Copy link
Contributor Author

@thinkingserious hi, how are we going to proceed with this one? I think I would remove this logic that checks if the test is running on travis and simply leave the branch which uses localhost there.

@andy-trimble
Copy link
Contributor

Ah, well there you go @dmitraver 😄 . Good sleuthing. It's interesting that the MOCK_HOST isn't set. The output in Travis would indicated that it is being set. This is in the "Build system information" section of the output. I'm unsure how Travis works here.

From working on my PR, I noticed that I was having trouble keeping the Prism process running through the various Gradle steps. That's why I suggested checking for the process. I'm not seeing the output of the lsof command. Am I missing it?

@andy-trimble
Copy link
Contributor

Also, @dmitraver, in order to validate your proposed solution, you could remove the logic from one of the tests, and see if that test passes in Travis.

@dmitraver
Copy link
Contributor Author

@andy-trimble I think you've seen it there cause I added it before to test ;)
See c866a49

I will remove this logic and push the code to see if it actually builds.

@dmitraver
Copy link
Contributor Author

@andy-trimble I've commented this Travis part from the 10 tests and these tests passed fine on Travis. I'm gonna remove it from all the tests then.

@andy-trimble
Copy link
Contributor

Awesome! Sounds good @dmitraver.

@dmitraver
Copy link
Contributor Author

@andy-trimble, @thinkingserious build is passing now.

@mbernier mbernier added difficulty: very hard fix is very hard in difficulty and removed difficulty: hard fix is hard in difficulty labels Oct 21, 2017
@mbernier
Copy link
Contributor

Wowza, I just caught up on this thread... Thank you so much @dmitraver and @andy-trimble - this was awesome.

@mbernier
Copy link
Contributor

@andy-trimble if you approve your review, then we will get this merged in. I believe (and hope) it will fix the other build issues we're seeing too :)

@andy-trimble
Copy link
Contributor

LGTM

@thinkingserious thinkingserious merged commit 37dabf0 into sendgrid:master Oct 22, 2017
@thinkingserious
Copy link
Contributor

Hello @dmitraver,

Thanks again for the PR!

It's HACKTOBERFEST! We want to show our appreciation by sending you some special Hacktoberfest swag. If you have not already, could you please fill out this form so we can send it to you? Thanks!

Team SendGrid DX

@dmitraver
Copy link
Contributor Author

@thinkingserious, @andy-trimble thx, I really appreciate that, happy to help ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: very hard fix is very hard in difficulty status: code review request requesting a community code review or review from Twilio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants