-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
495 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# How to run tests | ||
|
||
Tests are using [AzureCliCredential](https://learn.microsoft.com/en-us/java/api/com.azure.identity.azureclicredential?view=azure-java-stable). | ||
Make sure to be assigned with the [Azure Service Bus Data Owner](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/integration#azure-service-bus-data-owner) role. | ||
|
||
Steps: | ||
- `az login` | ||
- `export AZURE_SERVICEBUS_HOSTNAME=<your-servicebus-hostname>` | ||
- `sbt "project azureServiceBusIt" test` |
37 changes: 37 additions & 0 deletions
37
...integration/src/test/scala/com/commercetools/queue/servicebus/ServiceBusClientSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2024 Commercetools GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.commercetools.queue.servicebus | ||
|
||
import cats.effect.{IO, Resource} | ||
import com.azure.identity.AzureCliCredentialBuilder | ||
import com.commercetools.queue.QueueClient | ||
import com.commercetools.queue.azure.servicebus.ServiceBusClient | ||
import com.commercetools.queue.testkit.QueueClientSuite | ||
|
||
class ServiceBusClientSuite extends QueueClientSuite { | ||
|
||
private def config = string("AZURE_SERVICEBUS_HOSTNAME") | ||
override val inFlightMessagesStatsSupported: Boolean = false | ||
|
||
override def client: Resource[IO, QueueClient[IO]] = | ||
config.toResource.flatMap { namespace => | ||
ServiceBusClient[IO]( | ||
namespace = namespace, | ||
credentials = new AzureCliCredentialBuilder().build() | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
testkit/src/main/scala/com/commercetools/queue/testkit/QueueAdministrationSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.commercetools.queue.testkit | ||
|
||
import com.commercetools.queue.QueueConfiguration | ||
import munit.CatsEffectSuite | ||
|
||
import scala.concurrent.duration._ | ||
|
||
/** | ||
* This suite tests that the features of a [[com.commercetools.queue.QueueAdministration QueueAdministration]] are properly | ||
* implemented for a concrete client. | ||
*/ | ||
trait QueueAdministrationSuite extends CatsEffectSuite { self: QueueClientSuite => | ||
|
||
withQueue.test("existing queue should be indicated as such") { queueName => | ||
val client = clientFixture() | ||
assertIO(client.administration.exists(queueName), true) | ||
} | ||
|
||
test("non existing queue should be indicated as such") { | ||
val client = clientFixture() | ||
assertIO(client.administration.exists("not-existing"), false) | ||
} | ||
|
||
withQueue.test("get configuration") { queueName => | ||
val admin = clientFixture().administration | ||
assertIO(admin.configuration(queueName), QueueConfiguration(originalMessageTTL, originalLockTTL)) | ||
} | ||
|
||
withQueue.test("configuration can be updated") { queueName => | ||
assume(queueUpdateSupported, "The test environment does not support queue update") | ||
val admin = clientFixture().administration | ||
for { | ||
_ <- admin.update(queueName, Some(originalMessageTTL + 1.minute), Some(originalLockTTL + 10.seconds)) | ||
_ <- assertIO( | ||
admin.configuration(queueName), | ||
QueueConfiguration(originalMessageTTL + 1.minute, originalLockTTL + 10.seconds)) | ||
} yield () | ||
} | ||
|
||
} |
Oops, something went wrong.