Skip to content

Conversation

@Alirexaa
Copy link
Contributor

@Alirexaa Alirexaa commented Aug 8, 2024

Description

In this PR, I Added Redis Insight, a Developer GUI for Redis, by Redis.

by using WithRedisInsight the RedisInsight instance starts and imports the Redis connection to this instance via HTTP call.

only some unit tests need to include this PR.

Fixes #5165

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
Microsoft Reviewers: Open in CodeFlow

@ghost ghost added the area-integrations Issues pertaining to Aspire Integrations packages label Aug 8, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Aug 8, 2024
@Alirexaa
Copy link
Contributor Author

Alirexaa commented Aug 8, 2024

To pass all tests we need to import docker.io/redis/redisinsight:2.54 to netaspireci.azurecr.io

@Alirexaa
Copy link
Contributor Author

Alirexaa commented Aug 9, 2024

@eerhardt could you please import docker.io/redis/redisinsight:2.54 to make ci green?


await pipeline.ExecuteAsync(async (ctx) =>
{
var response = await client.PostAsync(apiUrl, content, ctx)
Copy link
Member

Choose a reason for hiding this comment

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

Is this the only way we can configure Redis Insight? I'm a bit concerned about sending HTTP requests from the AppHost. Can we instead write a file to a bind mount, like other places?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFIK there is no way to configure Redis Insight from file. There is some open issue about this redis/RedisInsight#2785.
I could'nt find any better way.

Comment on lines 118 to 120
var testConnectionResponse = await client.GetAsync(getDatabasesApiUrl, cts.Token)
.ConfigureAwait(false);
response.EnsureSuccessStatusCode();
Copy link
Member

Choose a reason for hiding this comment

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

If this fails then it would be useful to throw an exception with the url that failed.

@radical
Copy link
Member

radical commented Aug 15, 2024

Should this be added to the TestShop playground app too like RedisCommander?

basketCache.WithRedisCommander(c =>
{
c.WithHostPort(33801);
});

@Alirexaa
Copy link
Contributor Author

@eerhardt could you please import docker.io/redis/redisinsight:2.54 to make ci green?

@eerhardt

@eerhardt
Copy link
Member

@eerhardt could you please import docker.io/redis/redisinsight:2.54 to make ci green?

I have pushed the image to the netaspireci.azurecr.io registry, but I don't believe the test will pass because we don't have Docker Desktop installed on the CI machines.

}
var connectionFilePath = Path.Combine(connectionFileDirectoryPath, "RedisInsight_connections.json");

using (var stream = new FileStream(connectionFilePath, FileMode.OpenOrCreate))
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to write this out to a file? Can't we just keep it in memory and then send it via HTTP?

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 did that first and it did not work but I'm not sure that I did that right

Copy link
Member

@davidfowl davidfowl Sep 9, 2024

Choose a reason for hiding this comment

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

Agree with @eerhardt. Not sure why this needs to be a file. You just need a MemoryStream.

@Alirexaa
Copy link
Contributor Author

@eerhardt could you please import docker.io/redis/redisinsight:2.54 to make ci green?

I have pushed the image to the netaspireci.azurecr.io registry, but I don't believe the test will pass because we don't have Docker Desktop installed on the CI machines.

What can I do for that?

@radical
Copy link
Member

radical commented Aug 16, 2024

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Alirexaa
Copy link
Contributor Author

@Alirexaa are you going to get back to this one?

Yes. I will work on this.

MaxRetryAttempts = 10,
}).Build();

await pipeline.ExecuteAsync(async (ct) =>
Copy link
Member

Choose a reason for hiding this comment

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

You should be able to remove this now right?

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 so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For removing this i think we should use waitfor for Redis Insight

Copy link
Contributor Author

@Alirexaa Alirexaa Sep 15, 2024

Choose a reason for hiding this comment

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

@davidfowl Redis Insight doesn't log anything useful for using WaitForText so I just used ResourceNotificationService to ensure the resource is running.

@davidfowl
Copy link
Member

I cloned and played with this a bit:

These logs show up when you use redis insight since you're using the HttpClient factory.

info: System.Net.Http.HttpClient.Default.LogicalHandler[100]
      Start processing HTTP request POST http://localhost:33802/api/databases/import
info: System.Net.Http.HttpClient.Default.ClientHandler[100]
      Sending HTTP request POST http://localhost:33802/api/databases/import

Another thing that's kind of annoying is accepting the eula on every launch:

image

@Alirexaa
Copy link
Contributor Author

I cloned and played with this a bit:

These logs show up when you use redis insight since you're using the HttpClient factory.

info: System.Net.Http.HttpClient.Default.LogicalHandler[100]
      Start processing HTTP request POST http://localhost:33802/api/databases/import
info: System.Net.Http.HttpClient.Default.ClientHandler[100]
      Sending HTTP request POST http://localhost:33802/api/databases/import

Do you want us to use WaitForText for these logs?

Another thing that's kind of annoying is accepting the eula on every launch:

image

There is another API to accept the eula:
redis/RedisInsight#3267 (comment)

curl -XPATCH 'http://localhost:5540/api/settings' \
  -H 'Content-Type: application/json' \
  --data-raw '{"agreements":{"eula":true,"analytics":true,"notifications":true,"encryption":false}}

I will use this API to accept the eula.

@davidfowl davidfowl merged commit e8b6e5f into dotnet:main Sep 17, 2024
Comment on lines +255 to +274
using (var stream = new MemoryStream())
{
using var writer = new Utf8JsonWriter(stream);

writer.WriteStartObject();

writer.WritePropertyName("agreements");
writer.WriteStartObject();
writer.WriteBoolean("eula", true);
writer.WriteBoolean("analytics", false);
writer.WriteBoolean("notifications", false);
writer.WriteBoolean("encryption", false);
writer.WriteEndObject();

writer.WriteEndObject();

await writer.FlushAsync(ct).ConfigureAwait(false);
stream.Seek(0, SeekOrigin.Begin);
string json = Encoding.UTF8.GetString(stream.ToArray());
var content = new StringContent(json, Encoding.UTF8, "application/json");
Copy link
Member

Choose a reason for hiding this comment

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

If you want to write a follow up @Alirexaa, this can be simplified using JsonContent and JsonObject.

@Alirexaa Alirexaa deleted the WithRedisInsight branch September 17, 2024 18:19
@github-actions github-actions bot locked and limited conversation to collaborators Oct 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider adding support for Redis Insight as an alternative to RedisCommander

4 participants