package integration import ( "context" "os" "testing" "github.com/stretchr/testify/require" ctrl "sigs.k8s.io/controller-runtime" "edge-infra.dev/pkg/lib/fog" metricScopes "edge-infra.dev/pkg/lib/gcp/metricsscopes" "edge-infra.dev/test/f2" "edge-infra.dev/test/f2/integration" ) var ( f f2.Framework // `name:"monitored-project-id" description:"gcp account to set up as monitored project"` monitoredProjectID = "test-project-id" ) func TestMain(m *testing.M) { // framework.HandleFlags() ctrl.SetLogger(fog.New()) f = f2.New( context.Background(), ) code := f.Run(m) os.Exit(code) } func TestMetricsScopes(t *testing.T) { integration.SkipIfNot(t, integration.L2) var ( client *metricScopes.Client ) feature := f2.NewFeature("MetricsScopes"). Setup("Create Metric Scope Client", func(ctx f2.Context, _ *testing.T) f2.Context { client = metricScopes.New(monitoredProjectID) return ctx }). Test("adding monitored project", func(ctx f2.Context, t *testing.T) f2.Context { add, err := client.AddMonitoredProject(ctx, monitoredProjectID) require.NoError(t, err) require.NotEmpty(t, add) return ctx }). Test("querying monitored project", func(ctx f2.Context, t *testing.T) f2.Context { query, err := client.QueryMetricsScope(ctx) require.NoError(t, err) require.NotEmpty(t, query) return ctx }). Test("listing projects that are monitoring the monitored project", func(ctx f2.Context, t *testing.T) f2.Context { list, err := client.ListMetricsScope(ctx, monitoredProjectID) require.NoError(t, err) require.NotEmpty(t, list) return ctx }). Test("removing monitored project from scoping project", func(ctx f2.Context, t *testing.T) f2.Context { del, err := client.RemoveMetricsScope(ctx, monitoredProjectID) require.NoError(t, err) require.NotEmpty(t, del) return ctx }).Feature() f.Test(t, feature) }