Bug 12842

Summary: TEST_TARGET = "SimpleRemoteTarget" doesn't work
Product: [QA/Testing] Runtime Testing Reporter: Paul Eggleton <bluelightning>
Component: generalAssignee: yeoh ee peng <ee.peng.yeoh>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: akuster, ee.peng.yeoh
Version: 0.0.0   
Target Milestone: Future   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: Regression (Used to work)
Verified: Documentation change: Don't know

Description Paul Eggleton 2018-07-03 04:53:42 UTC
It seems that in the oeqa refactoring, setting TEST_TARGET = "SimpleRemoteTarget" results in the following error:

-------------- snip --------------
ERROR: core-image-minimal-1.0-r0 do_testimage: Error executing a python function in exec_python_func() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
[... trimmed huge backtrace ...]
File: '/data/poky/meta/lib/oeqa/runtime/context.py', lineno: 169, function: _loadControllerFromName
     0165:        for name in modulenames:
     0166:            obj = OERuntimeTestContextExecutor._loadControllerFromModule(target, name)
     0167:            if obj:
     0168:                return obj
 *** 0169:        raise AttributeError("Unable to load {0} from available modules: {1}".format(target, str(modulenames)))
     0170:
     0171:    # Search for and return a controller or None from given module name
     0172:    @staticmethod
     0173:    def _loadControllerFromModule(target, modulename):
Exception: AttributeError: Unable to load SimpleRemoteTarget from available modules: ['oeqa.controllers.masterimage', 'oeqa.controllers.testtargetloader', 'oeqa.controllers.beaglebonetarget', 'oeqa.controllers.edgeroutertarget', 'oeqa.controllers.grubtarget']
-------------- snip --------------

I found it wasn't even looking at targetcontrol.py where SimpleRemoteTarget is defined; I tried adding controllerslist.append('oeqa.targetcontrol') to the end of _getControllerModulenames() in meta/lib/oeqa/runtime/context.py however the old and new controller classes are not compatible so it still fails to initialise. As a workaround specifically for SimpleRemoteTarget I found you can use "simpleremote" instead though.

There are two main problems with all of this:

1) Our manuals (notably the reference manual) still talk about SimpleRemoteTarget and a bunch of other values as being valid, but at least SimpleRemoteTarget isn't anymore and I suspect it's not the only one. Either the code needs to be fixed so that these targets all work, or the documentation needs to be updated to remove *all* references to TEST_TARGET values that no longer work.

2) The error shown includes a huge backtrace and doesn't even describe what the valid values are - instead it tells you what modules it looked in. That might be useful for diagnostic purposes if you're prepared to dig into the code but it doesn't help the average user.
Comment 1 Apoorv 2018-09-27 03:13:36 UTC
QemuTarget is used to start a qemu instance (as it's currently done in testimage.bbclass).
SimpleRemoteTarget is meant for a remote machine (by setting TEST_TARGET_IP) that's already up and running with network and ssh. It allows to select one implementation or another by setting TEST_TARGET (currently to: "qemu" and "simpleremote").

Earlier, in poky (old version), when input (TEST_TARGET = "simpleremote") is provided through local.conf file, then corresponding controller class implementation "SimpleRemoteTarget" got called. 
The "SimpleRemoteTarget" is class implementation for input "simpleremote".

poky commit id: 17e3dc2cb5e7c060647a29a508d43a622ba53b80

+def get_target_controller(d):
+    if d.getVar("TEST_TARGET", True) == "qemu":
+        return QemuTarget(d)
+    elif d.getVar("TEST_TARGET", True) == "simpleremote":
+        return SimpleRemoteTarget(d)
+    else:
+        bb.fatal("Please set a valid TEST_TARGET")

Now, in latest poky release, this class "SimpleRemoteTarget" implementation has been replaced by class "OESSHTarget" (meta/lib/oeqa/core/target/ssh.py:class OESSHTarget(OETarget):)

file name : poky/meta/lib/oeqa/runtime/context.py

if target_type == 'simpleremote':
    target = OESSHTarget(logger, target_ip, server_ip, **kwargs)
elif target_type == 'qemu':
    target = OEQemuTarget(logger, target_ip, server_ip, **kwargs)
else:

This class "SimpleRemoteTarget"  is present in file ./meta/lib/oeqa/targetcontrol.py but its instance/object is not being created anywhere.

Based on the analysis, class "SimpleRemoteTarget" is obsolete now. So, we need to update the document.
Comment 2 yeoh ee peng 2019-09-27 02:12:49 UTC
Based on git grep on master (commit: 81f9e815d36848761a9dfa94b00ad998bb39a4a6)

meta/classes/testexport.bbclass:TEST_TARGET ?= "simpleremote"
meta/classes/testimage.bbclass:TEST_TARGET ?= "qemu"
meta/classes/testimage.bbclass:    if (d.getVar('TEST_TARGET') == 'simpleremote'
meta/classes/testimage.bbclass:    if d.getVar("TEST_TARGET") == "qemu":

It was clear that TEST_TARGET = "SimpleRemoteTarget" was obsolete, it shall be replaced by TEST_TARGET = "simpleremote".

We are contacting Scott Rifenbark for document update.
Comment 3 Armin Kuster 2019-09-27 02:34:16 UTC
(In reply to comment #2)
> Based on git grep on master (commit:
> 81f9e815d36848761a9dfa94b00ad998bb39a4a6)
> 
> meta/classes/testexport.bbclass:TEST_TARGET ?= "simpleremote"
> meta/classes/testimage.bbclass:TEST_TARGET ?= "qemu"
> meta/classes/testimage.bbclass:    if (d.getVar('TEST_TARGET') ==
> 'simpleremote'
> meta/classes/testimage.bbclass:    if d.getVar("TEST_TARGET") == "qemu":
> 
> It was clear that TEST_TARGET = "SimpleRemoteTarget" was obsolete, it shall
> be replaced by TEST_TARGET = "simpleremote".
> 
> We are contacting Scott Rifenbark for document update.

Thank you for the information. 

We need to create a doc patch. I can help in that area if you don't want to send a patch. Scott is out for a bit.  Let me know how you want to proceed.
Comment 4 yeoh ee peng 2019-10-03 09:38:06 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > Based on git grep on master (commit:
> > 81f9e815d36848761a9dfa94b00ad998bb39a4a6)
> > 
> > meta/classes/testexport.bbclass:TEST_TARGET ?= "simpleremote"
> > meta/classes/testimage.bbclass:TEST_TARGET ?= "qemu"
> > meta/classes/testimage.bbclass:    if (d.getVar('TEST_TARGET') ==
> > 'simpleremote'
> > meta/classes/testimage.bbclass:    if d.getVar("TEST_TARGET") == "qemu":
> > 
> > It was clear that TEST_TARGET = "SimpleRemoteTarget" was obsolete, it shall
> > be replaced by TEST_TARGET = "simpleremote".
> > 
> > We are contacting Scott Rifenbark for document update.
> 
> Thank you for the information. 
> 
> We need to create a doc patch. I can help in that area if you don't want to
> send a patch. Scott is out for a bit.  Let me know how you want to proceed.

I am new to yocto document patch. 
I found http://git.yoctoproject.org/cgit/cgit.cgi/yocto-docs/ this repository, I am guessing that I shall make the changes to mega-manual and create a patch. 
May I know which mailing list to send the doc patch? Thanks!