-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
There was a problem hiding this 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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
integration-tests/docker-compose.yml
Outdated
@@ -9,6 +9,8 @@ services: | |||
- specific-mongo | |||
- specific-rabbitmq | |||
- dummy-service | |||
- elastic |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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())) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@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. |
name.dependencies.v1.jschema
Outdated
@@ -73,6 +73,7 @@ | |||
"RabbitMq", | |||
"MongoDb", | |||
"SqlServer" | |||
"Elasticsearch" |
There was a problem hiding this comment.
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
Main features: