Skip to contentSkip to conversation

Add Fuego Functional.fuegotest

PATCH In review Guilherme Campos Camargo 2 participants 17 messages Mar 7, 2018 – Mar 9, 2018

lore
Share & tools
lore
#0 lore raw

cover Add Fuego Functional.fuegotest

Hello, Tim

Please see a few more commits that have been added to Functional.fuegotest. They include bug-fixes and some new tests (Shell and Selenium).

Not sure if you had the chance to take a look at my previous patches yet, but if not, please consider using these one instead.

There are many commits, but most of them are pretty small. Please feel free to ask me to squash some of them if you prefer.

To run these, you will need to checkout the fuego-test branch from Profusion's fuego and fuego-core forks and then simply use fuego as usual to add the fuego-test board and the Functional.fuegotest test.

In summary:

On host:
git clone --branch fuego-test https://bitbucket.org/profusionmobi/fuego-core.git
git clone --branch fuego-test https://bitbucket.org/profusionmobi/fuego.git
cd fuego
./install.sh
./fuego-host-scripts/docker-remove-container.sh ./fuego-host-scripts/docker-create-container.sh ./fuego-host-scripts/docker-start-container.sh

In fuego:
ftc add-nodes fuego-test
ftc add-jobs -b fuego-test -t Functional.fuegotest

Then you will be able to start the test through Jenkins and see the results.

Please let us know if you have any questions.

Guilherme Campos Camargo (11):
Add fuego-release Functional test
Mount fuego-rw/ro/core into the fuego-under-test container Use fuego-test branch to avoid install problems Increase wait_for_jenkins timeout from 10 to 60s Print fuego repo/branch information during test build Properly check install return code and abort in case of failure Allow the user to keep the container running after the test Add Back() Selenium Command
Add ClickLink selenium command
Include add-jobs, add-views and build-jobs tests Write ok/fail on test report

 engine/tests/Functional.fuegotest/fuego_test.sh |  36 ++
 engine/tests/Functional.fuegotest/spec.json     |  11 +
 engine/tests/Functional.fuegotest/test_run.py   | 552 ++++++++++++++++++++++++
 3 files changed, 599 insertions(+)
 create mode 100755 engine/tests/Functional.fuegotest/fuego_test.sh
 create mode 100644 engine/tests/Functional.fuegotest/spec.json
 create mode 100755 engine/tests/Functional.fuegotest/test_run.py
Signature · 1 line
2.16.2
#1 lore raw

PATCH 1/11 Add fuego-release Functional test

Allows Fuego to test new Fuego releases

---
 engine/tests/Functional.fuegotest/fuego_test.sh |  29 ++
 engine/tests/Functional.fuegotest/spec.json     |  11 +
 engine/tests/Functional.fuegotest/test_run.py   | 427 ++++++++++++++++++++++++
 3 files changed, 467 insertions(+)
 create mode 100755 engine/tests/Functional.fuegotest/fuego_test.sh
 create mode 100644 engine/tests/Functional.fuegotest/spec.json
 create mode 100755 engine/tests/Functional.fuegotest/test_run.py
engine/tests/Functional.fuegotest/fuego_test.sh new file +29 -0
new file mode 100755
index 0000000..192c15b
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+set -e
+
+readonly fuego_release_dir=fuego-release
+
+function test_build {
+    if [ -d ${fuego_release_dir} ]; then
+        rm -r ${fuego_release_dir}
+    fi
+    git clone --quiet --depth 1 --single-branch \
+        --branch "${FUNCTIONAL_FUEGOTEST_FUEGOBRANCH}" \
+        "${FUNCTIONAL_FUEGOTEST_FUEGOREPO}" \
+        "${fuego_release_dir}/fuego"
+    git clone --quiet --depth 1 --single-branch \
+        --branch "${FUNCTIONAL_FUEGOTEST_FUEGOCOREBRANCH}" \
+        "${FUNCTIONAL_FUEGOTEST_FUEGOCOREREPO}" \
+        "${fuego_release_dir}/fuego-core"
+    cd -
+}
+
+function test_run {
+    sudo -n ${TEST_HOME}/test_run.py "${fuego_release_dir}/fuego"
+    report "echo ok 1 minimal test on target"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "1" "^ok" "p"
+}
engine/tests/Functional.fuegotest/spec.json new file +11 -0
new file mode 100644
index 0000000..42e8ac1
@@ -0,0 +1,11 @@
+{
+    "testName": "Functional.fuegotest",
+    "specs": {
+        "default": {
+            "FUEGOREPO":"https://bitbucket.org/profusionmobi/fuego",
+            "FUEGOBRANCH":"next",
+            "FUEGOCOREREPO":"https://bitbucket.org/profusionmobi/fuego-core",
+            "FUEGOCOREBRANCH":"next"
+        }
+    }
+}
engine/tests/Functional.fuegotest/test_run.py new file +427 -0

427 lines not on this page · raw message

Signature · 1 line
2.16.2
#2 lore raw

PATCH 2/11 Mount fuego-rw/ro/core into the fuego-under-test container

In reply to Guilherme Campos Camargo

This patch implements the necessary logic for mounting fuego-rw, fuego-ro and fuego-core into fuego.

Given that the dockerd socket is shared between the host and the fuego container, the mountpoints that are passed to the docker create call need to be provided as full paths relative to the *host* (and not relative to fuego, as would be expected if the docker daemons were independent)

---
 engine/tests/Functional.fuegotest/test_run.py | 63 +++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
engine/tests/Functional.fuegotest/test_run.py +63 -0
index 96fcfb7..7eae056 100755
@@ -173,12 +173,43 @@ class FuegoContainer:
         self.container = None
 
     def setup_docker(self):
+        def this_container_id():
+            with open('/proc/self/cgroup', 'rt') as f:
+                f_text = f.read()
+
+                if 'docker' not in f_text:
+                    return None
+
+                for c in self.docker_client.containers(quiet=True):
+                    if c['Id'] in f_text:
+                        return c['Id']
+
+                return None
+
+        def map_to_host(mounts, container_id):
+            host_mounts = self.docker_client.\
+                inspect_container(container_id)['Mounts']
+
+            for mount in mounts:
+                LOGGER.debug('  Trying to find %s mountpoint in the host', mount['source'])
+                for host_mount in host_mounts:
+                    if mount['source'].startswith(host_mount['Destination']):
+                        mount['source'] = mount['source'].\
+                            replace(host_mount['Destination'],
+                                    host_mount['Source'], 1)
+                        LOGGER.debug('    Found: %s', mount['source'])
+                        break
+                else:
+                    LOGGER.debug('    Not Found')
+                    mount['source'] = None
+
         cmd = './{} {}'.format(self.install_script, self.image_name)
         LOGGER.debug('Running \'%s\' to install the docker image. '
                      'This may take a while....', cmd)
         status = subprocess.call(cmd, shell=True)
         if status != 0:
             return None
+
         docker_client = docker.from_env()
         containers = docker_client.containers.list(
             all=True, filters={'name': self.container_name})
@@ -188,10 +219,42 @@ class FuegoContainer:
                 self.container_name)
             containers[0].remove(force=True)
 
+        mounts = [
+            {'source': os.path.abspath('./fuego-rw'),
+             'destination':  '/fuego-rw',
+             'readonly': False,
+             },
+            {'source': os.path.abspath('./fuego-ro'),
+             'destination':  '/fuego-ro',
+             'readonly': True,
+             },
+            {'source': os.path.abspath('../fuego-core'),
+             'destination':  '/fuego-core',
+             'readonly': True,
+             },
+        ]
+
+        our_id = this_container_id()
+
+        if our_id:
+            LOGGER.debug('Running inside the Docker container %s', our_id)
+            map_to_host(mounts, our_id)
+        else:
+            LOGGER.debug('Not running inside a Docker container')
+
+        LOGGER.debug('Creating container with the following mountpoints:')
+        LOGGER.debug('  %s', mounts)
+
         container = docker_client.containers.create(
             self.image_name,
             stdin_open=True, tty=True, network_mode='bridge',
+            mounts=[docker.types.Mount(m['destination'],
+                                       m['source'],
+                                       type='bind',
+                                       read_only=m['readonly'])
+                    for m in mounts],
             name=self.container_name, command='/bin/bash')
+
         LOGGER.debug('Container \'%s\' created', self.container_name)
         return container
 
Signature · 1 line
2.16.2
#3 lore raw

PATCH 3/11 Use fuego-test branch to avoid install problems

In reply to Guilherme Campos Camargo

fuego:master/next are still using some debian apt-mirrors that seem to be currently offline.

This commit should be reverted/changed in the future when we make sure that the official fuego branches can be used with the test.

---
 engine/tests/Functional.fuegotest/spec.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
engine/tests/Functional.fuegotest/spec.json +2 -2
index 42e8ac1..e026f6f 100644
@@ -3,9 +3,9 @@
     "specs": {
         "default": {
             "FUEGOREPO":"https://bitbucket.org/profusionmobi/fuego",
-            "FUEGOBRANCH":"next",
+            "FUEGOBRANCH":"fuego-test",
             "FUEGOCOREREPO":"https://bitbucket.org/profusionmobi/fuego-core",
-            "FUEGOCOREBRANCH":"next"
+            "FUEGOCOREBRANCH":"fuego-test"
         }
     }
 }
Signature · 1 line
2.16.2
#4 lore raw

PATCH 4/11 Increase wait_for_jenkins timeout from 10 to 60s

In reply to Guilherme Campos Camargo

Jenkins may take a little longer to be ready to receive commands in some machines.

---
 engine/tests/Functional.fuegotest/test_run.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
engine/tests/Functional.fuegotest/test_run.py +1 -1
index 7eae056..e3fcb68 100755
@@ -357,7 +357,7 @@ class PexpectContainerSession():
                      'the container\'s IP \'%s\' at port \'%d\'',
                      self.container.container_name,
                      container_addr, self.container.jenkins_port)
-        if not loop_until_timeout(ping_jenkins, 10):
+        if not loop_until_timeout(ping_jenkins, timeout=60):
             LOGGER.error('Could not connect to jenkins')
             return False
 
Signature · 1 line
2.16.2
#5 lore raw

PATCH 5/11 Print fuego repo/branch information during test build

In reply to Guilherme Campos Camargo

Also remove --quiet from git clone

---
 engine/tests/Functional.fuegotest/fuego_test.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
engine/tests/Functional.fuegotest/fuego_test.sh +7 -2
index 192c15b..b4755bc 100755
@@ -8,11 +8,16 @@ function test_build {
     if [ -d ${fuego_release_dir} ]; then
         rm -r ${fuego_release_dir}
     fi
-    git clone --quiet --depth 1 --single-branch \
+    echo "Cloning fuego from \
+        ${FUNCTIONAL_FUEGOTEST_FUEGOREPO}:${FUNCTIONAL_FUEGOTEST_FUEGOBRANCH}"
+    git clone --depth 1 --single-branch \
         --branch "${FUNCTIONAL_FUEGOTEST_FUEGOBRANCH}" \
         "${FUNCTIONAL_FUEGOTEST_FUEGOREPO}" \
         "${fuego_release_dir}/fuego"
-    git clone --quiet --depth 1 --single-branch \
+
+    echo "Cloning fuego-core from \
+        ${FUNCTIONAL_FUEGOTEST_FUEGOCOREREPO}:${FUNCTIONAL_FUEGOTEST_FUEGOCOREBRANCH}"
+    git clone --depth 1 --single-branch \
         --branch "${FUNCTIONAL_FUEGOTEST_FUEGOCOREBRANCH}" \
         "${FUNCTIONAL_FUEGOTEST_FUEGOCOREREPO}" \
         "${fuego_release_dir}/fuego-core"
Signature · 1 line
2.16.2
#6 lore raw

PATCH 6/11 Properly check install return code and abort in case of failure

In reply to Guilherme Campos Camargo

A new method 'install()' has been added to 'FuegoContainer' and the all the docker_setup steps have been moved from the class __init__() to this new method.

This will allow the 'main' function to check if install has failed simply by inspecting its return.

---
 engine/tests/Functional.fuegotest/test_run.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
engine/tests/Functional.fuegotest/test_run.py +13 -4
index e3fcb68..d6bec0c 100755
@@ -160,14 +160,17 @@ class FuegoContainer:
         self.container_name = container_name
         self.jenkins_port = jenkins_port
 
-        self.docker_client = docker.APIClient()
-        self.container = self.setup_docker()
-
     def __del__(self):
         if self.container:
             LOGGER.debug('Removing Container')
             self.container.remove(force=True)
 
+    def install(self):
+        self.docker_client = docker.APIClient()
+        self.container = self.setup_docker()
+
+        return self.container
+
     def stop(self):
         self.container.remove(force=True)
         self.container = None
@@ -191,7 +194,8 @@ class FuegoContainer:
                 inspect_container(container_id)['Mounts']
 
             for mount in mounts:
-                LOGGER.debug('  Trying to find %s mountpoint in the host', mount['source'])
+                LOGGER.debug('  Trying to find %s mountpoint in the host',
+                             mount['source'])
                 for host_mount in host_mounts:
                     if mount['source'].startswith(host_mount['Destination']):
                         mount['source'] = mount['source'].\
@@ -207,6 +211,9 @@ class FuegoContainer:
         LOGGER.debug('Running \'%s\' to install the docker image. '
                      'This may take a while....', cmd)
         status = subprocess.call(cmd, shell=True)
+
+        LOGGER.debug('Install output code: %s', status)
+
         if status != 0:
             return None
 
@@ -453,6 +460,8 @@ def main():
 
     container = FuegoContainer(args.install_script, args.image_name,
                                args.container_name, args.jenkins_port)
+    if not container.install():
+        return 1
 
     pexpect_session = PexpectContainerSession(container, args.start_script,
                                               args.timeout)
Signature · 1 line
2.16.2
#7 lore raw

PATCH 7/11 Allow the user to keep the container running after the test

In reply to Guilherme Campos Camargo

Through the --remove-test-container command line argument.

---
 engine/tests/Functional.fuegotest/test_run.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
engine/tests/Functional.fuegotest/test_run.py +13 -4
index d6bec0c..fa68858 100755
@@ -154,16 +154,20 @@ class ShExpect():
 
 class FuegoContainer:
     def __init__(self, install_script, image_name, container_name,
-                 jenkins_port):
+                 jenkins_port, rm_after_test=True):
         self.install_script = install_script
         self.image_name = image_name
         self.container_name = container_name
         self.jenkins_port = jenkins_port
+        self.rm_after_test = rm_after_test
 
     def __del__(self):
         if self.container:
-            LOGGER.debug('Removing Container')
-            self.container.remove(force=True)
+            if self.rm_after_test:
+                LOGGER.debug('Removing Container')
+                self.container.remove(force=True)
+            else:
+                LOGGER.debug('Not Removing the test container')
 
     def install(self):
         self.docker_client = docker.APIClient()
@@ -453,13 +457,18 @@ def main():
                         'test container. Defaults to {}'
                         .format(DEFAULT_JENKINS_PORT),
                         default=DEFAULT_JENKINS_PORT, type=int)
+    parser.add_argument('--no-rm-container',
+                        help='Do not remove the container after tests are '
+                        'complete.',
+                        dest='rm_test_container', default=True, action='store_false')
     args = parser.parse_args()
 
     LOGGER.debug('Changing working dir to \'%s\'', args.working_dir)
     os.chdir(args.working_dir)
 
     container = FuegoContainer(args.install_script, args.image_name,
-                               args.container_name, args.jenkins_port)
+                               args.container_name, args.jenkins_port,
+                               rm_after_test=args.rm_test_container)
     if not container.install():
         return 1
 
Signature · 1 line
2.16.2
#8 lore raw

PATCH 8/11 Add Back() Selenium Command

In reply to Guilherme Campos Camargo

That will go one level back in the browser history.

---
 engine/tests/Functional.fuegotest/test_run.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
engine/tests/Functional.fuegotest/test_run.py +10 -0
index fa68858..851074f 100755
@@ -97,6 +97,16 @@ class CheckText(SeleniumCommand):
         return result == self.expected_result
 
 
+class Back(SeleniumCommand):
+    def exec(self, selenium_ctx):
+        super().exec(selenium_ctx)
+
+        LOGGER.debug('  Going back')
+        self.driver.back()
+
+        return True
+
+
 class ShExpect():
     BASH_PATTERN = 'test_run_pr1:#'
     COMMAND_RESULT_PATTERN = re.compile('^([0-9]+)', re.M)
Signature · 1 line
2.16.2
#9 lore raw

PATCH 9/11 Add ClickLink selenium command

In reply to Guilherme Campos Camargo

Clicks in the link that has the text passed in the argument linktext. Returns False if no link containing linktext is found.

---
 engine/tests/Functional.fuegotest/test_run.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
engine/tests/Functional.fuegotest/test_run.py +24 -0
index 851074f..e03853b 100755
@@ -13,6 +13,7 @@ import docker
 import pexpect
 import requests
 from selenium import webdriver
+import selenium.common.exceptions as selenium_exceptions
 
 LOGGER = logging.getLogger('test_run')
 STREAM_HANDLER = logging.StreamHandler()
@@ -97,6 +98,29 @@ class CheckText(SeleniumCommand):
         return result == self.expected_result
 
 
+class ClickLink(SeleniumCommand):
+    def __init__(self, linktext, expected_result=True):
+        self.linktext = linktext
+        self.expected_result = expected_result
+
+    def exec(self, selenium_ctx):
+        super().exec(selenium_ctx)
+
+        LOGGER.debug(
+            '  Searching for a link with the text \'%s\'', self.linktext)
+
+        try:
+            link = self.driver.find_element_by_partial_link_text(self.linktext)
+            link.click()
+            LOGGER.debug('  Link found and clicked')
+            result = True
+        except selenium_exceptions.NoSuchElementException:
+            LOGGER.error('  Link not found')
+            result = False
+
+        return result == self.expected_result
+
+
 class Back(SeleniumCommand):
     def exec(self, selenium_ctx):
         super().exec(selenium_ctx)
Signature · 1 line
2.16.2
#10 lore raw

PATCH 10/11 Include add-jobs, add-views and build-jobs tests

In reply to Guilherme Campos Camargo

Those tests are using a combination of ShExpect and SeleniumHQ for executing the command and checking if the website has responded properly.

For now, SeleniumHQ is just being used for viewing the results on the website, and not for sending commands. In other words, build-jobs is being triggered through the command-line only, and not through the Jenkins UI.

---
 engine/tests/Functional.fuegotest/test_run.py | 34 +++++++++++++++++----------
 1 file changed, 22 insertions(+), 12 deletions(-)
engine/tests/Functional.fuegotest/test_run.py +22 -12
index e03853b..09b3a95 100755
@@ -516,20 +516,30 @@ def main():
         return 1
 
     COMMANDS_TO_TEST = [
-        ShExpect(
-            'echo $\'hello\n\n\nfrom\n\n\ncontainer\'',
-            r'hello\s+from\s+container'),
-        ShExpect(
-            'cat -ThisOptionDoesNotExists', expected_result=1),
-        ShExpect('ftc add-nodes docker'),
-        ShExpect(
-            'ftc list-nodes', r'Jenkins nodes in this system:\s*docker\s*.*'),
-        ShExpect('ftc add-jobs -b docker -p testplan_docker'),
-        ShExpect(
-            'ftc list-jobs', r'Jenkins jobs in this system:(\s*docker\..*)+'),
+        # Set Selenium Browser root
         Visit(url=container.get_url()),
+
+        # Add Nodes
+        ShExpect('ftc add-nodes docker'),
+        ShExpect('ftc list-nodes -q', r'.*docker.*'),
+        CheckText(_id='executors', text='master'),
         CheckText(_id='executors', text='docker'),
-        CheckText(_id='executors', text='master')
+
+        # Add Fuego TestPlan
+        ShExpect('ftc add-jobs -b docker -p testplan_fuego_tests'),
+        ShExpect('ftc list-jobs', r'.*docker\.testplan_fuego_tests\.batch.*'),
+
+        ClickLink(linktext='docker'),
+        CheckText(_id='projectstatus', text='docker.testplan_fuego_tests.batch'),
+        Back(),
+
+        # Install Views
+        ShExpect('ftc add-view batch .*.batch'),
+        CheckText(_id='projectstatus-tabBar', text='batch'),
+
+        # Start Tests
+        ShExpect('ftc build-jobs *.*.Functional.fuego_board_check'),
+        CheckText(_id='buildQueue', text='Functional.fuego_board_check'),
     ]
 
     if not execute_tests(args.timeout):
Signature · 1 line
2.16.2
#11 lore raw

PATCH 11/11 Write ok/fail on test report

In reply to Guilherme Campos Camargo

Remove the 'minimal test' that had been copied from an example test.

---
 engine/tests/Functional.fuegotest/fuego_test.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
engine/tests/Functional.fuegotest/fuego_test.sh +6 -4
index b4755bc..ee60c81 100755
@@ -1,7 +1,5 @@
 #!/bin/bash
 
-set -e
-
 readonly fuego_release_dir=fuego-release
 
 function test_build {
@@ -26,9 +24,13 @@ function test_build {
 
 function test_run {
     sudo -n ${TEST_HOME}/test_run.py "${fuego_release_dir}/fuego"
-    report "echo ok 1 minimal test on target"
+    if [ "${?}" = 0 ]; then
+        report "echo fuego-test: ok"
+    else
+        report "echo fuego-test: fail"
+    fi
 }
 
 function test_processing {
-    log_compare "$TESTDIR" "1" "^ok" "p"
+    log_compare "$TESTDIR" "1" "ok$" "p"
 }
Signature · 1 line
2.16.2
#12 lore raw
In reply to Guilherme Campos Camargo
Quoted 28 lines

-----Original Message-----
From: [email protected] [mailto:fuego- [email protected]] On Behalf Of Guilherme Campos Camargo
Sent: Wednesday, March 07, 2018 11:55 AM
To: [email protected]
Subject: [Fuego] [PATCH 00/11] Add Fuego Functional.fuegotest

Hello, Tim

Please see a few more commits that have been added to Functional.fuegotest.
They include bug-fixes and some new tests (Shell and Selenium).

Not sure if you had the chance to take a look at my previous patches yet, but if not, please consider using these one instead.

There are many commits, but most of them are pretty small. Please feel free to ask me to squash some of them if you prefer.

To run these, you will need to checkout the fuego-test branch from Profusion's fuego and fuego-core forks and then simply use fuego as usual to add the fuego-test board and the Functional.fuegotest test.

In summary:

Quoted 10 lines

On host:
git clone --branch fuego-test https://bitbucket.org/profusionmobi/fuego-
core.git
git clone --branch fuego-test https://bitbucket.org/profusionmobi/fuego.git
cd fuego
./install.sh
./fuego-host-scripts/docker-remove-container.sh ./fuego-host-scripts/docker-create-container.sh ./fuego-host-scripts/docker-start-container.sh

The build worked.

Quoted 3 lines

In fuego:
ftc add-nodes fuego-test
ftc add-jobs -b fuego-test -t Functional.fuegotest

these worked.

Quoted 1 line

Then you will be able to start the test through Jenkins and see the results.

Running the test in jenkins resulted in the log that's attached.

-- Tim

Started by user ha:AAAAlh+LCAAAAAAAAP9b85aBtbiIQTGjNKU4P08vOT+vOD8nVc83PyU1x6OyILUoJzMv2y+/JJUBAhiZGBgqihhk0NSjKDWzXb3RdlLBUSYGJk8GtpzUvPSSDB8G5tKinBIGIZ+sxLJE/ZzEvHT94JKizLx0a6BxUmjGOUNodHsLgAzOEgYu/dLi1CL9vNKcHACFIKlWvwAAAA==anonymous
Building remotely on ha:AAAAoB+LCAAAAAAAAP9b85aBtbiIQTGjNKU4P08vOT+vOD8nVc83PyU1x6OyILUoJzMv2y+/JJUBAhiZGBgqihhk0NSjKDWzXb3RdlLBUSYGJk8GtpzUvPSSDB8G5tKinBIGIZ+sxLJE/ZzEvHT94JKizLx0a6BxUmjGOUNodHsLgAyuEgYR/eT83ILSktQi/bTS1PR83ZLU4hIADoGZQ8kAAAA=fuego-testFATAL: Failed to load the key: hudson.model.Job.serverCookie ha:AAAAWB+LCAAAAAAAAP9b85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=java.lang.Error: Failed to load the key: hudson.model.Job.serverCookie

	at jenkins.security.HexStringConfidentialKey.get(HexStringConfidentialKey.java:62)
	at hudson.model.Job.getCharacteristicEnvVars(Job.java:367)
	at hudson.model.Job.getEnvironment(Job.java:395)
	at hudson.model.AbstractProject.getEnvironment(AbstractProject.java:353)
	at hudson.model.Run.getEnvironment(Run.java:2264)
	at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:922)
	at hudson.model.AbstractBuild$AbstractBuildExecution.decideWorkspace(AbstractBuild.java:478)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:518)
	at hudson.model.Run.execute(Run.java:1728)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:404)
Caused by: java.io.FileNotFoundException: /var/lib/jenkins/secrets/hudson.model.Job.serverCookie (Permission denied)
	at java.io.FileOutputStream.open(Native Method)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
	at jenkins.security.DefaultConfidentialStore.store(DefaultConfidentialStore.java:79)
	at jenkins.security.ConfidentialKey.store(ConfidentialKey.java:50)
	at jenkins.security.HexStringConfidentialKey.get(HexStringConfidentialKey.java:54)
	... 11 more
FATAL: Failed to load the key: hudson.model.Job.serverCookie
ha:AAAAWB+LCAAAAAAAAP9b85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=java.lang.Error: Failed to load the key: hudson.model.Job.serverCookie
	at jenkins.security.HexStringConfidentialKey.get(HexStringConfidentialKey.java:62)
	at hudson.model.Job.getCharacteristicEnvVars(Job.java:367)
	at hudson.model.Job.getEnvironment(Job.java:395)
	at hudson.model.AbstractProject.getEnvironment(AbstractProject.java:353)
	at hudson.model.Run.getEnvironment(Run.java:2264)
	at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:922)
	at hudson.plugins.descriptionsetter.DescriptionSetterHelper.setDescription(DescriptionSetterHelper.java:53)
	at hudson.plugins.descriptionsetter.DescriptionSetterPublisher.perform(DescriptionSetterPublisher.java:70)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
	at hudson.model.Build$BuildExecution.post2(Build.java:185)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
	at hudson.model.Run.execute(Run.java:1753)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:404)
Caused by: java.io.FileNotFoundException: /var/lib/jenkins/secrets/hudson.model.Job.serverCookie (Permission denied)
	at java.io.FileOutputStream.open(Native Method)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
	at jenkins.security.DefaultConfidentialStore.store(DefaultConfidentialStore.java:79)
	at jenkins.security.ConfidentialKey.store(ConfidentialKey.java:50)
	at jenkins.security.HexStringConfidentialKey.get(HexStringConfidentialKey.java:54)
	... 16 more

Finished: FAILURE

#13 lore raw

​Tim, can you please try to add --privileged to the docker create​ call on fuego-host-scripts/docker-create-container.sh ? This should not be the final fix, it's just for testing.

```

sudo docker create -it --name ${DOCKERCONTAINER} \
    --privileged \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /boot:/boot:ro \
    -v $DIR/../fuego-rw:/fuego-rw \
    -v $DIR/../fuego-ro:/fuego-ro:ro \
    -v $DIR/../../fuego-core:/fuego-core:ro \
    -e http_proxy=${http_proxy} \
    -e https_proxy=${https_proxy:-$http_proxy} \
    --net="host" ${DOCKERIMAGE} || \
    echo "Could not create fuego-container. See error messages."

```

Thanks

Quoted 56 lines · On Thu, Mar 8, 2018 at 6:32 PM, <[email protected]> wrote:
Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:fuego- [email protected]] On Behalf Of Guilherme Campos Camargo
Sent: Wednesday, March 07, 2018 11:55 AM
To: [email protected]
Subject: [Fuego] [PATCH 00/11] Add Fuego Functional.fuegotest

Quoted 7 lines

Hello, Tim

Please see a few more commits that have been added to Functional.fuegotest.
They include bug-fixes and some new tests (Shell and Selenium).

Not sure if you had the chance to take a look at my previous patches

yet, but

Quoted 7 lines

if not, please consider using these one instead.

There are many commits, but most of them are pretty small. Please feel free to ask me to squash some of them if you prefer.

To run these, you will need to checkout the fuego-test branch from Profusion's fuego and fuego-core forks and then simply use fuego as

usual to

Quoted 8 lines

add the fuego-test board and the Functional.fuegotest test.

In summary:

On host:
git clone --branch fuego-test https://bitbucket.org/profusionmobi/fuego-
core.git
git clone --branch fuego-test https://bitbucket.org/

profusionmobi/fuego.git

Quoted 6 lines

cd fuego
./install.sh
./fuego-host-scripts/docker-remove-container.sh
./fuego-host-scripts/docker-create-container.sh
./fuego-host-scripts/docker-start-container.sh

The build worked.

Quoted 3 lines

In fuego:
ftc add-nodes fuego-test
ftc add-jobs -b fuego-test -t Functional.fuegotest

these worked.

Quoted 1 line

Then you will be able to start the test through Jenkins and see the

results.
Running the test in jenkins resulted in the log that's attached.

-- Tim

#14 lore raw

Same behavior.
-- Tim

Quoted 103 lines

-----Original Message-----
From: [email protected] [mailto:fuego- [email protected]] On Behalf Of Guilherme Camargo
Sent: Thursday, March 08, 2018 2:20 PM
To: Bird, Timothy <[email protected]>
Cc: [email protected]
Subject: Re: [Fuego] [PATCH 00/11] Add Fuego Functional.fuegotest

​Tim, can you please try to add --privileged to the docker create​ call on fuego-host-scripts/docker-create-container.sh ? This should not be the final fix, it's just for testing.

```

sudo docker create -it --name ${DOCKERCONTAINER} \
    --privileged \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /boot:/boot:ro \
    -v $DIR/../fuego-rw:/fuego-rw \
    -v $DIR/../fuego-ro:/fuego-ro:ro \
    -v $DIR/../../fuego-core:/fuego-core:ro \
    -e http_proxy=${http_proxy} \
    -e https_proxy=${https_proxy:-$http_proxy} \
    --net="host" ${DOCKERIMAGE} || \
    echo "Could not create fuego-container. See error messages."

```

Thanks

On Thu, Mar 8, 2018 at 6:32 PM, <[email protected] <mailto:[email protected]> > wrote:

	> -----Original Message-----
	> From: [email protected] <mailto:fuego-

[email protected]> [mailto:fuego- <mailto:fuego->
> [email protected]
<mailto:[email protected]> ] On Behalf Of Guilherme Campos

	> Camargo
	> Sent: Wednesday, March 07, 2018 11:55 AM
	> To: [email protected]

<mailto:[email protected]>
> Subject: [Fuego] [PATCH 00/11] Add Fuego Functional.fuegotest >
> Hello, Tim
>
> Please see a few more commits that have been added to > Functional.fuegotest.
> They include bug-fixes and some new tests (Shell and Selenium). >
> Not sure if you had the chance to take a look at my previous
patches yet, but
> if not, please consider using these one instead.
>
> There are many commits, but most of them are pretty small. Please
feel
> free to ask me to squash some of them if you prefer. >
> To run these, you will need to checkout the fuego-test branch
from
> Profusion's fuego and fuego-core forks and then simply use fuego
as usual to

	> add the fuego-test board and the Functional.fuegotest test.
	>
	> In summary:
	>
	> On host:
	> git clone --branch fuego-test
https://bitbucket.org/profusionmobi/fuego-
<https://bitbucket.org/profusionmobi/fuego->
	> core.git
	> git clone --branch fuego-test

https://bitbucket.org/profusionmobi/fuego.git
<https://bitbucket.org/profusionmobi/fuego.git>
> cd fuego
> ./install.sh
> ./fuego-host-scripts/docker-remove-container.sh > ./fuego-host-scripts/docker-create-container.sh > ./fuego-host-scripts/docker-start-container.sh >

The build worked.

> In fuego:
> ftc add-nodes fuego-test
> ftc add-jobs -b fuego-test -t Functional.fuegotest

these worked.

> Then you will be able to start the test through Jenkins and see the
results.

	Running the test in jenkins resulted in the log that's attached.

	 -- Tim
#15 lore raw

I just tried to everything on Ubuntu 16.04, using docker version 1.13.1, and I get the same problem.

When I exit the container, and try to restart it, Jenkins fails to start, and the log says:
java.io.FileNotFoundException: /var/cache/jenkins/war/META-INF/MANIFEST.MF

The file is there, owned by jenkins.jenkins.

Here is more information:

jenkins@timdesk:/var/cache/jenkins$ ls -la
ls: cannot access war: Permission denied
total 8
drwxr-x---  4 jenkins jenkins 4096 Mar  9 00:37 .
drwxr-xr-x 20 root   root    4096 Mar  9 00:37 ..
d?????????  ? ?        ?           ?                ? war
jenkins@timdesk:/var/cache/jenkins$l id
uid=1000(jenkins) gid=1000(jenkins) groups=1000(jenkins)
------

So, we've still got a permission problem in here somewhere.
-- Tim

Quoted 116 lines

-----Original Message-----
From: [email protected]

Same behavior.
-- Tim

Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:fuego- [email protected]] On Behalf Of Guilherme Camargo
Sent: Thursday, March 08, 2018 2:20 PM
To: Bird, Timothy <[email protected]>
Cc: [email protected]
Subject: Re: [Fuego] [PATCH 00/11] Add Fuego Functional.fuegotest

​Tim, can you please try to add --privileged to the docker create​ call on fuego-host-scripts/docker-create-container.sh ? This should not be the

final

Quoted 84 lines

fix, it's just for testing.

```

sudo docker create -it --name ${DOCKERCONTAINER} \
    --privileged \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /boot:/boot:ro \
    -v $DIR/../fuego-rw:/fuego-rw \
    -v $DIR/../fuego-ro:/fuego-ro:ro \
    -v $DIR/../../fuego-core:/fuego-core:ro \
    -e http_proxy=${http_proxy} \
    -e https_proxy=${https_proxy:-$http_proxy} \
    --net="host" ${DOCKERIMAGE} || \
    echo "Could not create fuego-container. See error messages."

```

Thanks

On Thu, Mar 8, 2018 at 6:32 PM, <[email protected] <mailto:[email protected]> > wrote:

	> -----Original Message-----
	> From: [email protected] <mailto:fuego-

[email protected]> [mailto:fuego- <mailto:fuego->
> [email protected]
<mailto:[email protected]> ] On Behalf Of Guilherme Campos

	> Camargo
	> Sent: Wednesday, March 07, 2018 11:55 AM
	> To: [email protected]

<mailto:[email protected]>
> Subject: [Fuego] [PATCH 00/11] Add Fuego Functional.fuegotest >
> Hello, Tim
>
> Please see a few more commits that have been added to > Functional.fuegotest.
> They include bug-fixes and some new tests (Shell and Selenium). >
> Not sure if you had the chance to take a look at my previous
patches yet, but
> if not, please consider using these one instead.
>
> There are many commits, but most of them are pretty small. Please
feel
> free to ask me to squash some of them if you prefer. >
> To run these, you will need to checkout the fuego-test branch
from
> Profusion's fuego and fuego-core forks and then simply use fuego
as usual to

	> add the fuego-test board and the Functional.fuegotest test.
	>
	> In summary:
	>
	> On host:
	> git clone --branch fuego-test
https://bitbucket.org/profusionmobi/fuego-
<https://bitbucket.org/profusionmobi/fuego->
	> core.git
	> git clone --branch fuego-test

https://bitbucket.org/profusionmobi/fuego.git
<https://bitbucket.org/profusionmobi/fuego.git>
> cd fuego
> ./install.sh
> ./fuego-host-scripts/docker-remove-container.sh > ./fuego-host-scripts/docker-create-container.sh > ./fuego-host-scripts/docker-start-container.sh >

The build worked.

> In fuego:
> ftc add-nodes fuego-test
> ftc add-jobs -b fuego-test -t Functional.fuegotest

Quoted 9 lines

these worked.

> Then you will be able to start the test through Jenkins and see the
results.

	Running the test in jenkins resulted in the log that's attached.

	 -- Tim

_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego

#16 lore raw

​Hello, Tim, hope everything is going well.

Can you please give it a couple more tries by checking out the two new branches that I've just pushed to our fuego repo?

You can just fetch them, checkout and run, because we haven't force pushed anything since yesterday.

They have one commit each (above fuego-test branch), with a potential fix to the problem.

The repo/branches are these ones:

* https://bitbucket.org/profusionmobi/fuego/branch/chown-all?dest=fuego-test

  git fetch && git checkout chown-all

On this patch we're just using chown -R --from to chown all jenkins files that may still exist outside of the directories that we were
chowning
so far.

Please Try This One First. And if it works, great. If not, please try the next branch (below).

*
https://bitbucket.org/profusionmobi/fuego/branch/jenkins-user-on-build?dest=fuego-test

  git fetch && git checkout jenkins-user-on-build

This patch is almost a 'clean revert' of the patch that moved the jenkins
uid
mapping to the entrypoint. We're just setting the correct jenkins id
during
docker build, by passing uid/gid through the docker-build-image.sh script
and
reading them through the Dockerfile.

This one should probably solve the issue, given that no ownership will
need to
be changed, since Jenkins starts for the first time with the correct user
already.

Please just make sure to run a git clean -dxf in the repo before running, to remove anything that jenkins might have written to fuego-rw.

I'm also attaching the patches, for you to apply them directly if you prefer.

Thank you very much

Quoted 123 lines · On Thu, Mar 8, 2018 at 9:51 PM, <[email protected]> wrote:

I just tried to everything on Ubuntu 16.04, using docker version 1.13.1, and I get the same problem.

When I exit the container, and try to restart it, Jenkins fails to start, and the
log says:
java.io.FileNotFoundException: /var/cache/jenkins/war/META-INF/MANIFEST.MF

The file is there, owned by jenkins.jenkins.

Here is more information:

jenkins@timdesk:/var/cache/jenkins$ ls -la
ls: cannot access war: Permission denied
total 8
drwxr-x---  4 jenkins jenkins 4096 Mar  9 00:37 .
drwxr-xr-x 20 root   root    4096 Mar  9 00:37 ..
d?????????  ? ?        ?           ?                ? war
jenkins@timdesk:/var/cache/jenkins$l id
uid=1000(jenkins) gid=1000(jenkins) groups=1000(jenkins)
------

So, we've still got a permission problem in here somewhere.
-- Tim

Quoted 16 lines

-----Original Message-----
From: [email protected]

Same behavior.
-- Tim

Quoted 9 lines

-----Original Message-----
From: [email protected] [mailto:fuego- [email protected]] On Behalf Of Guilherme Camargo
Sent: Thursday, March 08, 2018 2:20 PM
To: Bird, Timothy <[email protected]>
Cc: [email protected]
Subject: Re: [Fuego] [PATCH 00/11] Add Fuego Functional.fuegotest

​Tim, can you please try to add --privileged to the docker create​

call on

Quoted 82 lines
Quoted 1 line

fuego-host-scripts/docker-create-container.sh ? This should not be the

final

Quoted 80 lines

fix, it's just for testing.

```

sudo docker create -it --name ${DOCKERCONTAINER} \
    --privileged \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /boot:/boot:ro \
    -v $DIR/../fuego-rw:/fuego-rw \
    -v $DIR/../fuego-ro:/fuego-ro:ro \
    -v $DIR/../../fuego-core:/fuego-core:ro \
    -e http_proxy=${http_proxy} \
    -e https_proxy=${https_proxy:-$http_proxy} \
    --net="host" ${DOCKERIMAGE} || \
    echo "Could not create fuego-container. See error messages."

```

Thanks

Quoted 2 lines · On Thu, Mar 8, 2018 at 6:32 PM, <[email protected] <mailto:[email protected]>…

-----Original Message-----
From: [email protected] <mailto:fuego-

[email protected]> [mailto:fuego- <mailto:fuego->

Quoted 1 line

[email protected]

<mailto:[email protected]> ] On Behalf Of Guilherme Campos

Quoted 3 lines

Camargo
Sent: Wednesday, March 07, 2018 11:55 AM
To: [email protected]

<mailto:[email protected]>

Quoted 9 lines

Subject: [Fuego] [PATCH 00/11] Add Fuego Functional.fuegotest

Hello, Tim

Please see a few more commits that have been added to Functional.fuegotest.
They include bug-fixes and some new tests (Shell and Selenium).

Not sure if you had the chance to take a look at my previous

patches yet, but

Quoted 3 lines

if not, please consider using these one instead.

There are many commits, but most of them are pretty small. Please

feel

Quoted 3 lines

free to ask me to squash some of them if you prefer.

To run these, you will need to checkout the fuego-test branch

from

Quoted 1 line

Profusion's fuego and fuego-core forks and then simply use fuego

as usual to

Quoted 6 lines

add the fuego-test board and the Functional.fuegotest test.

In summary:

On host:
git clone --branch fuego-test

https://bitbucket.org/profusionmobi/fuego-
<https://bitbucket.org/profusionmobi/fuego->

Quoted 2 lines

core.git
git clone --branch fuego-test

https://bitbucket.org/profusionmobi/fuego.git
<https://bitbucket.org/profusionmobi/fuego.git>

Quoted 6 lines

cd fuego
./install.sh
./fuego-host-scripts/docker-remove-container.sh
./fuego-host-scripts/docker-create-container.sh
./fuego-host-scripts/docker-start-container.sh

The build worked.

Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

In fuego:
ftc add-nodes fuego-test
ftc add-jobs -b fuego-test -t Functional.fuegotest

these worked.

> Then you will be able to start the test through Jenkins and see

the

Quoted 11 lines
Quoted 6 lines

results.
Running the test in jenkins resulted in the log that's attached.

-- Tim

_______________________________________________
Fuego mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/fuego

setup/entrypoint.sh +14 -6
index 21017db..1e25769 100755
@@ -19,18 +19,26 @@ function map_jenkins_uid_to_host() {
         return 0
     fi
 
-    DJUID=${docker_jenkins_uid}
-    DJGID=${docker_jenkins_gid}
+    old_jenkins_uid=$(id -u jenkins)
+    old_jenkins_gid=$(id -g jenkins)
+    new_jenkins_uid=${docker_jenkins_uid}
+    new_jenkins_gid=${docker_jenkins_gid}
 
-    echo "Remapping Fuego's jenkins uid=$(id -u jenkins) to uid=${DJUID}..."
+    echo "Remapping Fuego's jenkins uid=$(id -u jenkins) to uid=${new_jenkins_uid}..."
+    usermod -u "${new_jenkins_uid}" jenkins
 
-    usermod -u "${DJUID}" jenkins
-    groupmod -g "${DJGID}" jenkins
-    chown -R "${DJUID}":"${DJGID}" \
+    echo "Remapping Fuego's jenkins gid=$(id -g jenkins) to gid=${new_jenkins_gid}..."
+    groupmod -g "${new_jenkins_gid}" jenkins
+
+    echo "Reowning jenkins' files"
+    chown -R --silent jenkins:jenkins \
         /var/lib/jenkins /var/cache/jenkins /var/log/jenkins /fuego-rw
+    chown -R --silent --from ${old_jenkins_uid} jenkins /
+    chown -R --silent --from :${old_jenkins_gid} :jenkins /
 }
 
 service jenkins stop >> /dev/null
+sleep 5
 map_jenkins_uid_to_host
 set_jenkins_port
 service jenkins start
setup/jenkins/plugins/install.sh +2 -0
index 37e8948..944ce7b 100755
@@ -41,3 +41,5 @@ ln -s /fuego-rw/logs "$JENKINS_HOME/userContent/fuego.logs"
 ln -s /fuego-core/engine/scripts/ftc /usr/local/bin/
 
 chown -R jenkins:jenkins "$JENKINS_HOME/"
+
+service jenkins stop
Dockerfile +8 -1
index 42b2fc8..3334a54 100644
@@ -101,7 +101,14 @@ ARG JENKINS_SHA=bfc226aabe2bb089623772950c4cc13aee613af1
 ARG JENKINS_URL=https://pkg.jenkins.io/debian-stable/binary/jenkins_${JENKINS_VERSION}_all.deb
 ENV JENKINS_HOME=/var/lib/jenkins
 
-RUN curl -L -O ${JENKINS_URL} && \
+ARG uid=1009
+ARG gid=${uid}
+
+RUN echo "Creating Jenkins user/group with uid:gid ${uid}:${gid}"
+
+RUN groupadd -g ${gid} jenkins && \
+    useradd -l -m -d "${JENKINS_HOME}" -u ${uid} -g ${gid} -G sudo -s /bin/bash jenkins && \
+    curl -L -O ${JENKINS_URL} && \
     echo "${JENKINS_SHA} jenkins_${JENKINS_VERSION}_all.deb" | sha1sum -c - && \
     dpkg -i jenkins_${JENKINS_VERSION}_all.deb && \
     rm jenkins_${JENKINS_VERSION}_all.deb
fuego-host-scripts/docker-build-image.sh +10 -0
index d276ee0..02a4069 100755
@@ -2,6 +2,16 @@
 # $1 - name for the docker image (default: fuego)
 DOCKERIMAGE=${1:-fuego}
 
+if [ "${UID}" == "0" ]; then
+	uid=$(id -u "${SUDO_USER}")
+	gid=$(id -g "${SUDO_USER}")
+else
+	uid="${UID}"
+	gid=$(id -g "${USER}")
+fi
+
 sudo docker build -t ${DOCKERIMAGE} \
+    --build-arg uid=${uid} \
+    --build-arg gid=${gid} \
     --build-arg http_proxy=${http_proxy} \
     --build-arg https_proxy=${https_proxy} .