Skip to content

[CI] Port in use causes panic in unit tests #3661

Description

@mandre

As seen here, we can get a panic while running the unit tests when the port is already in use:

[701](https://github.com/gophercloud/gophercloud/actions/runs/23549763309/job/68560162724?pr=3659#step:5:2719)
=== FAIL: openstack/objectstorage/v1/objects/testing TestCreateTempURL (0.00s)
    http_responses.go:53: Failed to listen to 127.0.0.1:33200: listen tcp 127.0.0.1:33200: bind: address already in use
panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x6f8556]

goroutine 64 [running]:
testing.tRunner.func1.2({0x7a6620, 0xb2a990})
	/opt/hostedtoolcache/go/1.25.0/x64/src/testing/testing.go:1872 +0x237
testing.tRunner.func1()
	/opt/hostedtoolcache/go/1.25.0/x64/src/testing/testing.go:1875 +0x35b
panic({0x7a6620?, 0xb2a990?})
	/opt/hostedtoolcache/go/1.25.0/x64/src/runtime/panic.go:783 +0x132
net/http/httptest.(*Server).Start(0xc00024a690)
	/opt/hostedtoolcache/go/1.25.0/x64/src/net/http/httptest/server.go:132 +0x96
github.com/gophercloud/gophercloud/v2/testhelper.SetupPersistentPortHTTP(0xc00020e700, 0x81b0)
	/home/runner/work/gophercloud/gophercloud/testhelper/http_responses.go:56 +0x212
github.com/gophercloud/gophercloud/v2/openstack/objectstorage/v1/objects/testing.TestCreateTempURL(0xc00020e700)
	/home/runner/work/gophercloud/gophercloud/openstack/objectstorage/v1/objects/testing/requests_test.go:507 +0x45
testing.tRunner(0xc00020e700, 0x83a100)
	/opt/hostedtoolcache/go/1.25.0/x64/src/testing/testing.go:1934 +0xea
created by testing.(*T).Run in goroutine 1
	/opt/hostedtoolcache/go/1.25.0/x64/src/testing/testing.go:1997 +0x465
exit status 1

Activity

  1. added a commit that references this issue on Mar 26, 2026
    69bf30c
  2. added a commit that references this issue on Apr 7, 2026
    e82c6cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions