Skip to content

Conversation

@mikeharder
Copy link
Member

@mikeharder mikeharder commented Feb 27, 2020

  • In test code, all calls to Create() or Delete() were replaced by CreateIfNotExists() and DeleteIfExists(), with the exception of calls explicitly testing Create() or Delete(), and calls which require the response (since the "Exists" APIs may return a null response).

  • The non-"Exists" APIs may fail at any time if the server failed to respond to the first HTTP request and it was retried

PRs which added "Exists" APIs to product code

@mikeharder
Copy link
Member Author

/azp run net - storage - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

- In test code, all calls to ShareClient.Create() were replaced by ShareClient.CreateIfNotExists(), with the exception of calls explicitly testing Create().
- Even if the share does not exist, ShareClient.Create() can throw ShareAlreadyExists if the server failed to respond to the first HTTP request and it was retried
- In test code, all calls to ShareDirectoryClient.Create() were replaced by ShareDirectoryClient.CreateIfNotExists(), with the exception of calls explicitly testing Create().
- Even if the directory does not exist, ShareDirectoryClient.Create() can throw ResourceAlreadyExists if the server failed to respond to the first HTTP request and it was retried
@mikeharder
Copy link
Member Author

/azp run net - storage - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mikeharder
Copy link
Member Author

@tg-msft, @JoshLove-msft: Looks like this PR was forgotten. I just rebased against master and am running tests. Also happy to merge to a different branch like feature/storage if you want.

@mikeharder
Copy link
Member Author

@tg-msft, @JoshLove-msft: Recorded tests are failing. If I recall, it's because the recordings need to be updated since the Exists APIs add an If-None-Match header. I can update the recordings if you share instructions, or one of you could do it.

@mikeharder mikeharder added EngSys This issue is impacting the engineering system. Storage Storage Service (Queues, Blobs, Files) Client This issue is related to a non-management package labels Apr 22, 2020
@mikeharder
Copy link
Member Author

@amishra-dev, @seanmcc-msft: Would either of you like to review this, and would you prefer I merge this to master or a different branch? These are just fixes to improve test reliability so any branch is fine with me.

@seanmcc-msft
Copy link
Member

Hi @mikeharder , could you merge this to master and feature/storage/stg73base?

@mikeharder
Copy link
Member Author

@seanmcc-msft: Sure, I will merge to both those branches once this is ready.

@Petermarcu
Copy link
Member

Is this PR still moving forward?

@mikeharder
Copy link
Member Author

@Petermarcu: Yes. @tg-msft has agreed to update the test recordings and then merge this PR.

@seanmcc-msft
Copy link
Member

@mikeharder @Petermarcu

I'm not sure if this PR is necessary. The majority of our unit tests use DisposableContainer/Share/FileSystem, which are created at the beginning of the test, and deleted in a finally loop at the end of the test.

Even if the containers were not deleted, new ones are created the next time a test is run. I'm not sure how we would ever run into a conflicting Blob/SMB File/Data Lake File.

@mikeharder
Copy link
Member Author

I'm not sure if this PR is necessary. The majority of our unit tests use DisposableContainer/Share/FileSystem, which are created at the beginning of the test, and deleted in a finally loop at the end of the test.

Even if the containers were not deleted, new ones are created the next time a test is run. I'm not sure how we would ever run into a conflicting Blob/SMB File/Data Lake File.

This PR will improve test reliability. Further, I think we should encourage customers to use the *Exists APIs by default unless they need to change behavior based on whether the resource already exists.

The non-Exists APIs always have a small chance of failing even if the resource was in the correct state before the API call, and we have seen these failures regularly in our test results. Here's the issue as I understand it:

  1. App calls API like BlobContainerClient.CreateAsync() with a name that has never existed (say a GUID)
  2. SDK calls Create Container REST API
  3. Occasionally (say 1 in 5000 requests), the REST API will return an error. Sometimes the container was actually created in the service, but sometimes it was not, and the client cannot disambiguate.
  4. SDK retries the Create Container REST API call.
  5. If the container was actually created in the service, the REST API will return an error that the container already exists, and the BlobContainerClient.CreateAsync() API will throw an exception.

The only way to avoid these occasional exceptions is to use the *Exists APIs.

@jsquire
Copy link
Member

jsquire commented Sep 15, 2020

@tg-msft - Are you still planning to update and merge or can this be closed out?

@jsquire
Copy link
Member

jsquire commented Sep 18, 2020

@mikeharder - Is this still an active work stream or should we close out the PR?

@mikeharder
Copy link
Member Author

I put a fair bit of work into this, and it's important for test reliability, so I would like to see it get merged. I believe the remaining work is for someone to update the recordings and commit them with the test changes. @tg-msft has agreed to do this when he gets time.

@JoshLove-msft
Copy link
Member

I put a fair bit of work into this, and it's important for test reliability, so I would like to see it get merged. I believe the remaining work is for someone to update the recordings and commit them with the test changes. @tg-msft has agreed to do this when he gets time.

I was planning on re-recording these in a separate PR.

@jsquire
Copy link
Member

jsquire commented Sep 18, 2020

@JoshLove-msft - Is there an issue that we can link with this for the remaining work to keep apprised of scheduling?

@mikeharder
Copy link
Member Author

My changes were made a long time ago, so whomever takes over this PR should also see if any new tests were added since my changes, and update them in the same way (always use an "Exists" API, unless you are explicitly testing the non-Exists API).

@tg-msft
Copy link
Member

tg-msft commented Oct 26, 2020

Fixed with #15638

@tg-msft tg-msft closed this Oct 26, 2020
@mikeharder mikeharder deleted the storage-tests-if-exists branch November 11, 2020 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Client This issue is related to a non-management package EngSys This issue is impacting the engineering system. Storage Storage Service (Queues, Blobs, Files)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants