setup prepares the test environment, connects all NRI plugins.
()
| 680 | |
| 681 | // setup prepares the test environment, connects all NRI plugins. |
| 682 | func (tc *nriTest) setup() { |
| 683 | if tc.name == "" { |
| 684 | tc.name = tc.t.Name() |
| 685 | } |
| 686 | if tc.prefix == "" { |
| 687 | tc.prefix = strings.ToLower(tc.name) |
| 688 | } |
| 689 | if tc.namespace == "" { |
| 690 | tc.namespace = tc.prefix + "-" + strconv.Itoa(os.Getpid()) |
| 691 | } |
| 692 | |
| 693 | tc.sbCfg = make(map[string]*runtime.PodSandboxConfig) |
| 694 | tc.runtime = runtimeService |
| 695 | |
| 696 | for idx, p := range tc.plugins { |
| 697 | p.namespace = tc.namespace |
| 698 | |
| 699 | if p.logf == nil { |
| 700 | p.logf = tc.t.Logf |
| 701 | } |
| 702 | if p.idx == "" { |
| 703 | p.idx = fmt.Sprintf("%02d", idx) |
| 704 | } |
| 705 | |
| 706 | err := p.Start() |
| 707 | require.NoError(tc.t, err, "start plugin") |
| 708 | |
| 709 | err = p.Wait(PluginSynchronized, time.After(pluginSyncTimeout)) |
| 710 | require.NoError(tc.t, err, "wait for plugin setup") |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | // Connect a new NRI plugin to the runtime. |
| 715 | func (tc *nriTest) connectNewPlugin(p *mockPlugin) { |
no test coverage detected