-
Notifications
You must be signed in to change notification settings - Fork 52
Active Message Count #20
Comments
That's pretty odd. There shouldn't be any special way to run tests. I think you are running into golang/go#21710. Have you run Also, you can run |
I hadn't run dep ensure previously, but I have now with no difference. Exact same result when I run go test. Thoughts? |
Sounds like you might have the fork under your own username in your GOPATH. If that's the case, it will attempt to import the With Go, it's common to add your fork as a git remote under the official project in your GOPATH to avoid this issue. This post describes it in detail https://blog.sgmansfield.com/2016/06/working-with-forks-in-go/. |
yes I have the fork under my own username (that's how I usually do it). Can't say I've run into this issue before, but will do as you suggest. Thanks for the info! |
hmmm no luck. Hey, if I completely ignore my own fork and just wanted to clone the existing repo and run the tests... should a clone + go test work? Or would I still need to do something else? Since even that's not working for me. (but works for plenty of other repos). Admittedly they dont have "internal" |
@kpfaulkner I'll do this on a clean machine today and see if I can replicate your experience. One item of note, if you look at the TravisCI builds, those clone and run tests from a clean start each time. |
@kpfaulkner I've recruited @marstr and @t-jaelli to try to replicate your experience and provide some feedback. |
I've just finished running on my box :) cd $GOPATH/src/github.com/Azure
git clone https://github.com/Azure/azure-service-bus-go.git
cd azure-service-bus-go
dep ensure
git remote add marstr https://github.com/marstr/azure-service-bus-go.git
git fetch marstr
export SERVICEBUS_CONNECTION_STRING=[REDACTED]
go test ./... Doing this, I didn't run into build errors that you saw above. :) |
I think I was able to recreate your issue. I cloned from my fork of the azure-service-bus-go repo. cd $GOPATH/src/github.com/t-jaelli
git clone https://github.com/t-jaelli/azure-service-bus-go.git
cd azure-service-bus-go
dep ensure
go test ./... I received the same error. Having both your fork and the upstream in your gopath confuses the compiler. |
@marstr ahh that IS different to how I usually develop. So you actually do your mods within src/github.com/Azure directory? I always have mine as a subdir of src. So yes, I'd have 2 in my GOPATH, one is the original in src/github.com/azure/whatever and MINE would be src/whatever.... hmm never seen the situation where people have it set out like that. I definitely got further, but now need to gather up client, tenant, subscription ids etc for the tests to run (assuming you already had those setup?) |
I just always have to be a little different! ;) But really, it's because I hit the problem you're running into all of the time. All of my projects use
Ahh yeah, I often forget how much setup I've done for my local machine. I created myself a web application app-registration and use it's service principal in my environment variables |
By the way, it's good to hear from you again @kpfaulkner! |
Just setting up a new app for test purposes. Yes, has been a while. Am liking the new storage lib/structure.... it does everything I need (so far) so have been quiet there. Now adding in a bunch of servicebus monitoring into our infrastructure, so now poking my nose into this repo :) |
@kpfaulkner are you ok if we close this? |
I dont have it working yet, I end up getting: resources.GroupsClient#CreateOrUpdate: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Status=403 Code="AuthorizationFailed" Message="The client '3501f01e-14aa-4b54-ab95-a4391fe22eea' with object id '3501f01e-14aa-4b54-ab95-a4391fe22eea' does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourcegroups/write' over scope '/subscriptions/2573fe04-9ee8-404a-aab4-6534c25b554e/resourcegroups/test'." but assuming this is just me messing up the Azure application somehow. Am good to close for this.. but might be a little while before I'm able to run the tests. |
Well, it's progress 👍. This illustrates a need for a developer getting started page, which would walk through getting a dev / test environment running. The error you are running into right now is that the service principal you created doesn't have RBAC rights to the subscription to create a resource group. If you run this command, you should have an SP that will work for you az ad sp create-for-rbac. On the other hand, you could provide the SP RBAC rights to your subscription via Manage Service Principal Roles. Either route should get you over the current issue. |
@kpfaulkner let's leave it open til you have executing tests. I think you are pretty close. |
closer.... C:\Users\kenfa\projects\gopath\src\github.com\Azure\azure-service-bus-go>go test ./... suggestions? |
Just as a follow up, from what I can see the function func (client NamespacesClient) CreateOrUpdateSender(req *http.Request) (future NamespacesCreateOrUpdateFuture, err error) is the one that's blowing up on me. When running, I can see the resource group "test" being made, then the following request: PUT /subscriptions/2573fe04-9ee8-404a-aab4-6534c25b554e/resourceGroups/test/providers/Microsoft.ServiceBus/namespaces/?api-version=2017-04-01 HTTP/1.1 returns {"error":{"code":"UnsupportedResourceOperation","message":"The resource type 'namespaces' does not support this operation."}} |
I hadn't had enough coffee when I wrote this. I believe the above is correct, but might not address the issue described. |
@kpfaulkner it looks like the namespace name is empty when it tries to run the azure-service-bus-go/internal/test/test.go Lines 141 to 167 in 70612d6
/{name} after the /namespaces/ segment.
The namespace name is derived from the connection string via your environment var. See azure-service-bus-go/internal/test/test.go Lines 75 to 94 in 70612d6
Here's an example of what I mean. It also makes me think the connection parser should be a little more opinionated on what it thinks is an ok connection string. See the example below.
|
Just an update: Had quotes around my servicebus connection env var.... meant parsing died and didn't pick up name space. Also, I had to modify test.go since there is an assumption about region and resourcegroup name. Have modified PR #22 with a test confirming that after pushing a message the active message count is 1 (to at least confirm CountDetails is being populated). One thing I had to do and would like some advice on is I had to sleep between pushing message and retrieving queue (with CountDetails). Without the sleep it was fairly random (on my machine) if I'd get back my active message count or not (populated correctly). Although I notice another test also requires a sleep so maybe it's just a fact of life? |
@kpfaulkner check out azure-service-bus-go/queue_test.go Lines 739 to 752 in 70612d6
I experienced similar results and decided to give the active message count a chance to catch up based on the deadline of the test context. Each test has a default deadline and will wait for either the wait group to complete or the deadline to pass. This might be useful for you in this case. |
I was wondering about that. But for the cases where waitUntil is already run we've got a handler parameter that we can incorporate the waitgroup completion into. In my case I'm simply calling Get(). If we want to avoid sleeps I can use a tight loop in a goroutine that keeps calling Get(), once it's completed mark the waitgroup as done. But that seems just as messy to me. Is that what you were picturing? Or is there something I'm missing? Cheers |
Loop + sleep until success or deadline reached sounds good. No need to get too fancy. |
Ok left it at that. |
@kpfaulkner, I've merged the PR. I believe this solves your issue, so I'm going to close this. If you find this is still an issue, please reopen. |
Hi
I've created change so when listing/getting queues/topics the CountDetails are populated correctly. The code works fine but I'm trying to sort out the tests.
Currently (even without my change) if I try: "go test" I get the following error:
azure-service-bus-go
namespace_test.go:32:2: use of internal package not allowed
FAIL azure-service-bus-go [setup failed]
I see in namespace_test.go the import "github.com/Azure/azure-service-bus-go/internal/test"
Is there a special way to run tests? I want to get this PR submitted but obviously want to have tests included.
Thanks
Ken
The text was updated successfully, but these errors were encountered: