File: cluster_test.go

package info (click to toggle)
incus 6.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 24,428 kB
  • sloc: sh: 16,313; ansic: 3,121; python: 457; makefile: 337; ruby: 51; sql: 50; lisp: 6
file content (37 lines) | stat: -rw-r--r-- 1,129 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package endpoints_test

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

// If both a network and a cluster address are set, and they differ, a new
// network TCP socket will be created.
func TestEndpoints_ClusterCreateTCPSocket(t *testing.T) {
	endpoints, config, cleanup := newEndpoints(t)
	defer cleanup()

	config.NetworkAddress = "127.0.0.1:12345"
	config.ClusterAddress = "127.0.0.1:54321"
	require.NoError(t, endpoints.Up(config))

	assert.NoError(t, httpGetOverTLSSocket(endpoints.NetworkAddressAndCert()))
	assert.NoError(t, httpGetOverTLSSocket(endpoints.ClusterAddressAndCert()))
}

// When the cluster address is actually covered by the network one, no new port
// is opened.
func TestEndpoints_ClusterUpdateAddressIsCovered(t *testing.T) {
	endpoints, config, cleanup := newEndpoints(t)
	defer cleanup()

	config.NetworkAddress = "[::]:12345"
	config.ClusterAddress = ""
	require.NoError(t, endpoints.Up(config))

	require.NoError(t, endpoints.ClusterUpdateAddress("127.0.0.1:12345"))

	assert.NoError(t, httpGetOverTLSSocket(endpoints.NetworkAddressAndCert()))
}