// TestDatabaseServerStart validates that started database server updates its
// dynamic labels and heartbeats its presence to the auth server.
TestDatabaseServerStart validates that started database server updates its
dynamic labels and heartbeats its presence to the auth server.
// TestDatabaseServerStart validates that started database server updates its // dynamic labels and heartbeats its presence to the auth server .
func TestDatabaseServerStart(t *testing.T) {
	ctx := context.Background()
	testCtx := setupTestContext(ctx, t)
	t.Cleanup(func() { testCtx.Close() })
	err := testCtx.server.Start()
	require.NoError(t, err)
	t.Cleanup(func() { testCtx.server.Close() })
	labels, ok := testCtx.server.dynamicLabels[testCtx.dbServer.GetName()]
	require.True(t, ok)
	require.Equal(t, "test", labels.Get()["echo"].GetResult())
	heartbeat, ok := testCtx.server.heartbeats[testCtx.dbServer.GetName()]
	require.True(t, ok)
	err = heartbeat.ForceSend(time.Second)
	require.NoError(t, err)
	servers, err := testCtx.authClient.GetDatabaseServers(ctx, defaults.Namespace)
	require.NoError(t, err)
	require.EqualValues(t, testCtx.server.getServers(), servers)
	testCtx.dbServer.SetStaticLabels(map[string]string{"a": "b"})
	err = heartbeat.ForceSend(time.Second)
	require.NoError(t, err)
	servers, err = testCtx.authClient.GetDatabaseServers(ctx, defaults.Namespace)
	require.NoError(t, err)
	require.EqualValues(t, testCtx.server.getServers(), servers)
}
func TestDatabaseServerStart ( t * testing . T ) { ctx := context . Background ( ) testCtx := setupTestContext ( ctx , t ) t . Cleanup ( func ( ) { testCtx . Close ( ) } ) err := testCtx . server . Start ( ) require . NoError ( t , err ) t . Cleanup ( func ( ) { testCtx . server . Close ( ) } ) labels , ok := testCtx . server . dynamicLabels [ testCtx . dbServer . GetName ( ) ] require . True ( t , ok ) require . Equal ( t , " " , labels . Get ( ) [ " " ] . GetResult ( ) ) heartbeat , ok := testCtx . server . heartbeats [ testCtx . dbServer . GetName ( ) ] require . True ( t , ok ) err = heartbeat . ForceSend ( time . Second ) require . NoError ( t , err ) servers , err := testCtx . authClient . GetDatabaseServers ( ctx , defaults . Namespace ) require . NoError ( t , err ) require . EqualValues ( t , testCtx . server . getServers ( ) , servers ) testCtx . dbServer . SetStaticLabels ( map [ string ] string { " " : " " } ) err = heartbeat . ForceSend ( time . Second ) require . NoError ( t , err ) servers , err = testCtx . authClient . GetDatabaseServers ( ctx , defaults . Namespace ) require . NoError ( t , err ) require . EqualValues ( t , testCtx . server . getServers ( ) , servers ) }
TestDatabaseServerStart validates that started database server updates its
dynamic labels and heartbeats its presence to the auth server.
TestDatabaseServerStart validates that started database server updates its dynamic labels and heartbeats its presence to the auth server .
// Update the server, force the heartbeat and make sure it was re-announced.