-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp_integration_test.go
60 lines (48 loc) · 1.93 KB
/
app_integration_test.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//go:build integration
package main
import (
"context"
"os"
"testing"
"github.com/stretchr/testify/require"
ytcontainer "github.com/tractoai/testcontainers-ytsaurus"
)
const (
// If runLocalYtsaurus false — it is up to you to run local_yt manually.
// For example: yt/docker/local/run_local_cluster.sh --proxy-port 10110
runLocalYtsaurus = false
)
// TestAppIntegration checks sync with real Azure API and local yt
// It requires AZURE_CLIENT_SECRET to be set.
func TestAppIntegration(t *testing.T) {
require.NoError(t, os.Setenv(defaultYtsaurusSecretEnvVar, ytDevToken))
cfg, err := loadConfig("config.local.yaml")
require.NoError(t, err)
ctx := context.Background()
var ytLocal *ytcontainer.YTsaurusContainer
if runLocalYtsaurus {
ytLocal, err = ytcontainer.RunContainer(ctx)
require.NoError(t, err)
defer func() { require.NoError(t, ytLocal.Terminate(ctx)) }()
}
logger, err := configureLogger(&cfg.Logging)
require.NoError(t, err)
app, err := NewApp(cfg, logger)
require.NoError(t, err)
ytClient, err := ytLocal.NewClient(ctx)
usersBefore, err := doGetAllYtsaurusUsers(context.Background(), ytClient, cfg.Ytsaurus.SourceAttributeName)
require.NoError(t, err)
t.Log("usersBefore", len(usersBefore), usersBefore)
groupsBefore, err := doGetAllYtsaurusGroupsWithMembers(context.Background(), ytClient, cfg.Ytsaurus.SourceAttributeName)
t.Log("groupsBefore", len(groupsBefore), groupsBefore)
require.NoError(t, err)
app.syncOnce()
usersAfter, err := doGetAllYtsaurusUsers(context.Background(), ytClient, cfg.Ytsaurus.SourceAttributeName)
require.NoError(t, err)
t.Log("usersAfter", len(usersAfter), usersAfter)
groupsAfter, err := doGetAllYtsaurusGroupsWithMembers(context.Background(), ytClient, cfg.Ytsaurus.SourceAttributeName)
t.Log("groupsAfter", len(groupsAfter), groupsAfter)
require.NoError(t, err)
require.LessOrEqual(t, len(usersBefore), len(usersAfter))
require.LessOrEqual(t, len(groupsBefore), len(groupsAfter))
}