Commit 9c4d1dd6 authored by Jérome Perrin's avatar Jérome Perrin

fixup! software/jstestnode: add json for instance parameters

This json schema was not finished ...
parent 69593b36
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Parameters to instantiate JSTestNode",
"additionalProperties": false,
"properties": {
"additionalProperties": true,
"common": {
"test-suite": {
"description": "The test suite to run",
"type": "string",
......@@ -17,69 +17,100 @@
"format": "uri",
"default": "(the web server started by this instance)",
"example": "https://softinst1234.host.vifib.net/"
},
"oneOf": [
{
"title": "selenium server",
"description": "Configuration for running tests on selenium server",
"properties": {
"target": {
"description": "Target system",
"const": "selenium-server"
},
"server-url": {
"description": "URL of the selenium server",
"type": "string"
},
"verify-server-certificate": {
"description": "Verify the SSL/TLS Certificats of the selenium server when using HTTPS",
"type": "boolean",
"default": true
},
"server-ca-certificate": {
"description": "PEM encoded bundle of CA Certificates to verify the SSL/TLS Certificate of the selenium server when using HTTPS",
"type": "string",
"default": "root certificates from http://certifi.io/en/latest/"
},
"desired-capabilities": {
"description": "Desired browser capabilities",
"type": "object",
"properties": {
"browserName": {
"description": "Name of the browser being used, for example firefox, chrome",
"type": "string",
"required": true
},
"version": {
"description": "The browser version",
"type": "string"
}
}
},
"oneOf": [
{
"description": "Configuration for Selenium server",
"type": "object",
"additionalProperties": false,
"required": [
"desired-capabilities",
"server-url",
"target"
],
"properties": {
"target": {
"description": "Target system",
"type": "string",
"const": "selenium-server"
},
"test-suite": {
"$ref": "#/common/test-suite"
},
"remote-access-url": {
"$ref": "#/common/remote-access-url"
},
"server-url": {
"description": "URL of the selenium server",
"type": "string",
"format": "uri"
},
"verify-server-certificate": {
"description": "Verify the SSL/TLS Certificats of the selenium server when using HTTPS",
"type": "boolean",
"default": true
},
"server-ca-certificate": {
"description": "PEM encoded bundle of CA Certificates to verify the SSL/TLS Certificate of the selenium server when using HTTPS",
"type": "string",
"default": "root certificates from http://certifi.io/en/latest/"
},
"desired-capabilities": {
"description": "Desired browser capabilities",
"required": [
"browserName"
],
"type": "object",
"properties": {
"browserName": {
"description": "Name of the browser being used, for example firefox, chrome",
"type": "string"
},
"additionalProperties": true
"version": {
"description": "The browser version",
"type": "string"
}
}
}
},
{
"title": "firefox",
"description": "Configuration for running tests on local firefox process",
"properties": {
"target": {
"description": "Target system",
"const": "firefox",
"default": "firefox"
}
}
},
{
"description": "Configuration for Firefox",
"type": "object",
"additionalProperties": false,
"properties": {
"target": {
"description": "Target system",
"const": "firefox",
"type": "string",
"default": "firefox"
},
"test-suite": {
"$ref": "#/common/test-suite"
},
"remote-access-url": {
"$ref": "#/common/remote-access-url"
}
},
{
"title": "node",
"description": "Configuration for running tests on local nodejs",
"properties": {
"target": {
"description": "Target system",
"const": "node"
}
}
},
{
"description": "Configuration for NodeJS",
"type": "object",
"additionalProperties": false,
"properties": {
"target": {
"description": "Target system",
"const": "node",
"type": "string"
},
"test-suite": {
"$ref": "#/common/test-suite"
},
"remote-access-url": {
"$ref": "#/common/remote-access-url"
}
}
]
}
}
]
}
  • before i looked at this schema i had thought no schema could have oneOf/anyOf at the top level, that's why rjs_json_form renders only the first variant of oneOf/anyOf at the top level. Do i correctly understand:

    • that the properties indicated in oneOf are the target entity properties?
    • target, testsuit are the property of jstestnode entity?

    If both of the above statements are correct, then the choice of Firefox/Selenium/Nodejs is the choice of target type, isn't it? If this is true, then placing this choice at the same level as jstestnode is not logical.

    As i see the schema can be rewritten:

    • at the top level there are 2 properties - target and test-suite.
    • target has 3 oneOf items, every item has constant type

    @jerome , what do you think?

    Also I wonder if there's a way not to repeat the

    "test-suite": {
       "$ref": "#/common/test-suite"
    }, 

    i think the repetition can be avoided by:

    {
      "allOf": [
        {
          "properties": {
            "test-suite": {
              "description": "The test suite to run",
              "type": "string",
              "enum": [
                "jio",
                "renderjs"
              ]
            }
          }
        },
        {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "type": {
                  "type": "string",
                  "const": "selenium-server"
                }
              }
            }
          ]
        }
      ]
    }

    rjs_json_form supports any order and quantity of anyOf/oneOf/allOf enclosed in each other.

    [edit: fix misprint in example]

    Edited by Boris Kocherov
  • Thanks @bk . I'll try this again soon. I remember trying something similar but could not find the correct syntax. I also feel this is the correct approach.

    Sorry for not replying earlier. I really appreciated your feedback, I could not find the time to look into this seriously yet.

    PS I assume you meant allOf and not andOf. Or is it a recent json schema feature ?

  • PS I assume you meant allOf and not andOf. Or is it a recent json schema feature ?

    Sorry. Of couse i meant allOf.

  • @jerome , the fact that i didn't implement the anyOf/oneOf at the top level doesn't correspond to the specs. I did this on purpose because i think such schemes don't fit for visualization as forms. I think an user is accustomed to see the static set of fields on the top level and that fields can have arrays or properties with variable ('oneOf/anyOf') items, values. For example i think when user opens the Person for edit he expects to see the properties of Person, not a choice "edit Person or Organisation".

    Before rendering schema in form generator any quantity of anyOf/oneOf situated on the same level will be simplified to one anyOf even if some of anyOf/oneOf are inside of allOf. That's why the schema

    {
      "allOf": [
        {
          "properties": {
            "test-suite": {
              "description": "The test suite to run",
              "type": "string",
              "enum": [
                "jio",
                "renderjs"
              ]
            }
          }
        },
        {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "type": {
                  "type": "string",
                  "const": "selenium-server"
                }
              }
            },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "type": {
                  "type": "string",
                  "const": "firefox"
                }
              }
            }
          ]
        }
      ]
    }

    will be simplified to:

    {
      "anyOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "test-suite": {
              "description": "The test suite to run",
              "type": "string",
              "enum": [
                "jio",
                "renderjs"
              ]
            },
            "type": {
              "type": "string",
              "const": "selenium-server"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "test-suite": {
              "description": "The test suite to run",
              "type": "string",
              "enum": [
                "jio",
                "renderjs"
              ]
            },
            "type": {
              "type": "string",
              "const": "firefox"
            }
          }
        }
      ]
    }

    So, there are 2 variants

    • make changes in your schema (this will invoke changes in the backend):
    • at the top level there are 2 properties - target and test-suite.
    • target has 3 oneOf items, every item has constant type
    • make changes in form generator, so it can render anyOf/oneOf at the top level.

    @jerome , what is your opinion?

  • Thanks @bk

    That's true that a "oneOf" at top level is a bit strange, for ERP5 we would first choose adding a person or organisation, for SlapOS we could use different "software types" for this (but we don't use much of this, I think that with testnode we can only request the default software).

    For other reasons (so that it uses the same test-runner key as ERP5), I was also considering at moving the oneOf to select the target down one level. If we have test-runner, instead of:

    {
        "remote-access-url": "http://localhost",
        "test-suite": "jio",
        "target": "firefox"
    }

    We would use

    {
        "remote-access-url": "http://localhost",
        "test-suite": "jio",
        "test-runner": {
            "target": "firefox"
        }
    }

    or

     {
        "remote-access-url": "http://localhost",
        "test-suite": "jio",
        "test-runner": {
            "target": "selenium-server",
            "server-url": "http://localhost",
            "verify-server-certificate": false,
            "desired-capabilities": {
                "browserName": "Firefox",
                "version": "52"
            }
        }
    }

    I tried quickly ( jerome/slapos@3ed2e7fe / https://codepen.io/perrinjerome/pen/RqGOWj ), but I could not get rjs_json_form show a list field for target type. I might be doing something wrong.

    At this point I can't say if we need to support top level oneOf/allOf, I still need to understand how to get it working at "non top level".

  • Hello @jerome , could you have a look at: https://codepen.io/bkrocherov/pen/MzbeRx There i changed the schema:

    • added titles for each of oneOf item
    • changed test-runner property - it's required
    • switched additionalProperties to False.

    The view of the schema at https://codepen.io/bkrocherov/pen/MzbeRx is one i expected. I don't find yet why we have differences in css, which broke the view and why clicking on empty space rises the exception.

  • Hello @jerome,

    i've found the cause why clicking on empty space rises the exception and have fixed it: bk/rjs_json_form@0c9057b2 .

    About css: it looks like this css is broken by template engine. Correct css can be :

  • Hello @bk

    A big "thank you" for all this !

    I don't think I ran grunt less this might be the issue with my CSS.

  • mentioned in merge request !425 (merged)

    Toggle commit list
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment