-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Added spock test framework and tests for queue service #4940
Conversation
sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/APISpec.groovy
Outdated
Show resolved
Hide resolved
sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/APISpec.groovy
Outdated
Show resolved
Hide resolved
sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/APISpec.groovy
Show resolved
Hide resolved
sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/APISpec.groovy
Outdated
Show resolved
Hide resolved
...e-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueServiceAsyncAPITests.groovy
Show resolved
Hide resolved
...e-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueServiceAsyncAPITests.groovy
Outdated
Show resolved
Hide resolved
...e-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueServiceAsyncAPITests.groovy
Outdated
Show resolved
Hide resolved
Make sure to delete out the old test files and playback records |
Will have another PR for deletion work. |
sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/APISpec.groovy
Outdated
Show resolved
Hide resolved
...storage/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueAPITests.groovy
Outdated
Show resolved
Hide resolved
...storage/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueAPITests.groovy
Outdated
Show resolved
Hide resolved
then: | ||
QueueTestHelper.assertResponseStatusCode(createQueueResponse1, 201) | ||
def e = thrown(StorageErrorException) | ||
QueueTestHelper.assertExceptionStatusCodeAndMessage(e, 409, "QueueAlreadyExists") |
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.
This test is mostly exercising the service. Though we do need at least one test per api that returns a failed status code to validate that the Exceptions are successfully translated to a StorageException. This test can be repurposed for that.
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.
Removed. Did not have exception case for create from queue client since all error will be caught from builder.
...storage/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueAPITests.groovy
Outdated
Show resolved
Hide resolved
primaryQueueServiceClient = queueServiceBuilderHelper(interceptorManager).buildClient() | ||
} | ||
|
||
def "Get queue client from queue service client"() { |
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 can remove this test. I'm not really sure what it's covering.
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.
After a second thought, I think this one can be used to test if it can return the right class in case it uses a wrong sync and async class. Also have a high code coverage.
then:
queueClient instanceOf QueueClient
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.
Added one more assertion for better code coverage
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 haven't found it yet, so correct me if I'm wrong, but there used to be a similar test as this one but it would make a service call to the queue it got to show that getQueueClient
/getQueueAsyncClient
doesn't create the queue in the service. If that test doesn't exist could we change this test to do that?
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'm ok with having some validation that getQueueClient does not make a service request.
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 getClient did nothing but to initialize a new client class.
I don't think the service checking is needed as there is no logic within the service.
I have checked the class type.
QueueTestHelper.assertResponseStatusCode(enqueueMessageResponse, 201) | ||
} | ||
|
||
def "Create queues with duplicate name from queue service client"() { |
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 can remove this test
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.
Done.
"a_b" | 400 | StorageErrorCode.INVALID_RESOURCE_NAME | ||
"-ab" | 400 | StorageErrorCode.INVALID_RESOURCE_NAME | ||
"a--b" | 400 | StorageErrorCode.INVALID_RESOURCE_NAME | ||
// null | 400 | "InvalidResourceName" TODO: Need to fix the RestProxy before having null parameter |
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.
We should probably be asserting not null in the builder, no?
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.
Not for API layer. There is checking inside of builder.
I think it makes sense to check null in API as well.
I have updated the API
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 have made changes about checking null for the resource name
.../azure-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueServiceAPITests.groovy
Show resolved
Hide resolved
.../azure-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueServiceAPITests.groovy
Show resolved
Hide resolved
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.
Let's try to remove as much JUnit as we can and make sure we don't have collisions during concurrent live test runs. Overall it is looking good.
sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/APISpec.groovy
Outdated
Show resolved
Hide resolved
...orage/azure-storage-queue/src/main/java/com/azure/storage/queue/models/StorageErrorCode.java
Show resolved
Hide resolved
@@ -62,6 +63,7 @@ | |||
* @param queueName Name of the queue | |||
*/ | |||
QueueAsyncClient(AzureQueueStorageImpl client, String queueName) { | |||
Objects.requireNonNull(queueName); |
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.
This check should be in QueueServiceClient
as it allows for a null queue name to be passed, the builders should already be checking for this.
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.
All the entries which asked the queueName will fall into this constructor.
I think it is better to have null checking here and remove the one in buildAsyncClient.
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.
While that is true, having it remain in each individually will offer a closer indication to what went wrong and in the case of the client builder it will early out much sooner.
sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java
Show resolved
Hide resolved
primaryQueueServiceClient = queueServiceBuilderHelper(interceptorManager).buildClient() | ||
} | ||
|
||
def "Get queue client from queue service client"() { |
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 haven't found it yet, so correct me if I'm wrong, but there used to be a similar test as this one but it would make a service call to the queue it got to show that getQueueClient
/getQueueAsyncClient
doesn't create the queue in the service. If that test doesn't exist could we change this test to do that?
...ge/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueAysncAPITests.groovy
Show resolved
Hide resolved
...ge/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueAysncAPITests.groovy
Outdated
Show resolved
Hide resolved
...ge/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueAysncAPITests.groovy
Outdated
Show resolved
Hide resolved
.../azure-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueServiceAPITests.groovy
Outdated
Show resolved
Hide resolved
...orage/azure-storage-queue/src/test/java/com/azure/storage/queue/spock/QueueTestHelper.groovy
Show resolved
Hide resolved
Valid point on live test collisions. |
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.
LGTM
Just make sure to give the tests one more run for validation before merging in.
* Migrate queue to spock test framework * Remove all Junit tests and dependencies
* Migrate queue to spock test framework * Remove all Junit tests and dependencies
* Migrate queue to spock test framework * Remove all Junit tests and dependencies
No description provided.