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

Elasticsearch Version Resolve Capabilities #21

Merged
merged 10 commits into from
Nov 6, 2017
Merged

Conversation

Mozcatel
Copy link
Contributor

@Mozcatel Mozcatel commented Oct 31, 2017

Main features:

  • Added ElasticsearchVersionResolver;
  • Added a GetHttpWebRequest method on ConnectedVersionResolver that returns an HttpWebRequest object;
  • ServiceVersionResolver now uses the GetHttpWebRequest method on ConnectedVersionResolver
  • Added Elasticsearch type to name.dependencies.v1.jschema
  • Added unit and integration testing to the implementations above

Copy link
Contributor

@Symbianx Symbianx left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request, I have reviewed the code.

The integration tests are failing, because you have a typo in the connection string.

Also, you should add both elasticsearch services to the docker_init.sh script, which waits for the services initialization.

Fix these things and I'll merge, good job 👍

@@ -17,6 +17,11 @@ public static class Constants {
public static string SpecificRabbitVersion;
public static string SpecificServiceVersion;

// Elasticsearch variables
public static string LatestElasticHostname;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use the full name of Elasticsearch, should be LatestElasticsearchHostname

@@ -17,6 +17,11 @@ public static class Constants {
public static string SpecificRabbitVersion;
public static string SpecificServiceVersion;

// Elasticsearch variables
public static string LatestElasticHostname;
public static string SpecificElasticHostname;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

// Elasticsearch variables
public static string LatestElasticHostname;
public static string SpecificElasticHostname;
public static string SpecificElasticVersion;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

@@ -31,5 +36,9 @@ public static class Constants {
SpecificMongoVersion = Environment.GetEnvironmentVariable("SPECIFIC_MONGO_VERSION") ?? "3.0.0";
SpecificRabbitVersion = Environment.GetEnvironmentVariable("SPECIFIC_RABBIT_VERSION") ?? "3.6.5";
SpecificServiceVersion = Environment.GetEnvironmentVariable("SPECIFIC_SERVICE_VERSION") ?? "1.0.0";

LatestElasticHostname = Environment.GetEnvironmentVariable("LATEST_ELASTIC_HOSTNAME") ?? "localhost";
Copy link
Contributor

Choose a reason for hiding this comment

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

The Environment Variables should also contain the full name of Elasticsearch, should be LATEST_ELASTICSEARCH_HOSTNAME

@@ -31,5 +36,9 @@ public static class Constants {
SpecificMongoVersion = Environment.GetEnvironmentVariable("SPECIFIC_MONGO_VERSION") ?? "3.0.0";
SpecificRabbitVersion = Environment.GetEnvironmentVariable("SPECIFIC_RABBIT_VERSION") ?? "3.6.5";
SpecificServiceVersion = Environment.GetEnvironmentVariable("SPECIFIC_SERVICE_VERSION") ?? "1.0.0";

LatestElasticHostname = Environment.GetEnvironmentVariable("LATEST_ELASTIC_HOSTNAME") ?? "localhost";
SpecificElasticHostname = Environment.GetEnvironmentVariable("SPECIFIC_ELASTIC_HOSTNAME") ?? "localhost";
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

[Trait("TestCategory", "Integration")]
public async Task GetVersions_SpecificVersion()
{
ElasticsearchVersionResolver resolver = new ElasticsearchVersionResolver(new StaticConnectionStringProvider($"http://{ Constants.SpecificMongoHostname }:9200"), 10000, 10000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo, should be SpecificElasticsearchHostname instead of SpecificMongoHostname

[Trait("TestCategory", "Integration")]
public async Task GetVersions_LatestVersion()
{
ElasticsearchVersionResolver resolver = new ElasticsearchVersionResolver(new StaticConnectionStringProvider($"http://{ Constants.LatestMongoHostname }:9200"), 10000, 10000);
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

@@ -9,6 +9,8 @@ services:
- specific-mongo
- specific-rabbitmq
- dummy-service
- elastic
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, use the full name of elasticsearch, to keep things consistent.
The same for the rest of the file.

HttpWebResponse response;
try
{
var request = this.GetHttpWebRequest(connectionString, SupportedDependencies.Elasticsearch.ToString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Although you set the ContinueTimeout in the GetHttpWebRequest, it is not enough, because the Elasticsearch HTTP server may accept the connection and not send the response, so we need a read write timeout here, take a look at the ServiceVersionResolver for clues on how to do that.

var request = this.GetHttpWebRequest(connectionString, SupportedDependencies.Elasticsearch.ToString());
response = await request.GetResponseAsync() as HttpWebResponse;
}
catch (Exception e)
Copy link
Contributor

Choose a reason for hiding this comment

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

You should catch the most relevant exception instead of the base Exception, in this case it is System.Net.WebException.

{
using (response = await getResponseTask.ConfigureAwait(false) as HttpWebResponse)
{
using (var reader = new StreamReader(response.GetResponseStream()))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should handle the StatusCode before reading the response stream.

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 don't view it as necessary in this case of Elasticsearch though, as the request is to the root of the server itself.. if it doesn't return you the expected value, it's because the server isn't up, thus being a server-side error resulting in a WebException.

@suvl
Copy link
Member

suvl commented Nov 2, 2017

@Mozcatel you're just missing the change on the json schema.

Please add it to the recently introduced schema file.

After that, I believe we're ready to merge.

@@ -73,6 +73,7 @@
"RabbitMq",
"MongoDb",
"SqlServer"
"Elasticsearch"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please maintain consistency and use spaces instead of tabs. After that i will merge

@Symbianx Symbianx merged commit a90a391 into nosinovacao:dev Nov 6, 2017
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.

None yet

3 participants