@@ -43,7 +43,9 @@ func TestRuntime(t *testing.T) {
4343}
4444
4545const  (
46- 	startupTimeout  =  2  *  time .Second 
46+ 	startupTimeout         =  2  *  time .Second 
47+ 	defaultRuntimeName     =  "default-runtime-name" 
48+ 	defaultRuntimeVersion  =  "0.1.2" 
4749)
4850
4951// A test suite consist of a runtime and a set of plugins. 
@@ -70,6 +72,13 @@ func (s *Suite) Prepare(runtime *mockRuntime, plugins ...*mockPlugin) string {
7072
7173	Expect (os .MkdirAll (etc , 0o755 )).To (Succeed ())
7274
75+ 	if  runtime .name  ==  ""  {
76+ 		runtime .name  =  defaultRuntimeName 
77+ 	}
78+ 	if  runtime .version  ==  ""  {
79+ 		runtime .version  =  defaultRuntimeVersion 
80+ 	}
81+ 
7382	s .dir  =  dir 
7483	s .runtime  =  runtime 
7584	s .plugins  =  plugins 
@@ -107,6 +116,11 @@ func (s *Suite) WaitForPluginsToSync() {
107116	for  _ , plugin  :=  range  s .plugins  {
108117		Expect (plugin .Wait (PluginSynchronized , timeout )).To (Succeed ())
109118	}
119+ 
120+ 	// TODO(klihub): We lack the means to wait for synchronized plugins 
121+ 	// to get fully registered by mockRuntime. However, the tests still 
122+ 	// expect WaitForPluginsToSync to do that... 
123+ 	time .Sleep (25  *  time .Millisecond )
110124}
111125
112126// Cleanup the test suite. 
@@ -126,6 +140,8 @@ func Log(format string, args ...interface{}) {
126140}
127141
128142type  mockRuntime  struct  {
143+ 	name     string 
144+ 	version  string 
129145	options  []nri.Option 
130146	runtime  * nri.Adaptation 
131147	pods     map [string ]* api.PodSandbox 
@@ -149,7 +165,7 @@ func (m *mockRuntime) Start(dir string) error {
149165	}
150166
151167	options  =  append (options , m .options ... )
152- 	m .runtime , err  =  nri .New ("mockRuntime" ,  "0.0.1" , m .synchronize , m .update , options ... )
168+ 	m .runtime , err  =  nri .New (m . name ,  m . version , m .synchronize , m .update , options ... )
153169	if  err  !=  nil  {
154170		return  err 
155171	}
@@ -305,6 +321,9 @@ type mockPlugin struct {
305321	stub  stub.Stub 
306322	mask  stub.EventMask 
307323
324+ 	runtime  string 
325+ 	version  string 
326+ 
308327	q     * EventQ 
309328	pods  map [string ]* api.PodSandbox 
310329	ctrs  map [string ]* api.Container 
@@ -459,6 +478,14 @@ func (m *mockPlugin) Stop() {
459478	m .q .Add (PluginStopped )
460479}
461480
481+ func  (m  * mockPlugin ) RuntimeName () string  {
482+ 	return  m .runtime 
483+ }
484+ 
485+ func  (m  * mockPlugin ) RuntimeVersion () string  {
486+ 	return  m .version 
487+ }
488+ 
462489func  (m  * mockPlugin ) onClose () {
463490	if  m .stub  !=  nil  {
464491		m .stub .Stop ()
@@ -470,9 +497,12 @@ func (m *mockPlugin) onClose() {
470497	}
471498}
472499
473- func  (m  * mockPlugin ) Configure (_  context.Context , _ , _ ,  _  string ) (stub.EventMask , error ) {
500+ func  (m  * mockPlugin ) Configure (_  context.Context , _ , runtime ,  version  string ) (stub.EventMask , error ) {
474501	m .q .Add (PluginConfigured )
475502
503+ 	m .runtime  =  runtime 
504+ 	m .version  =  version 
505+ 
476506	return  m .mask , nil 
477507}
478508
0 commit comments