public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH pve-common v1 11/23] tests: sectionconfig: add case for required default props opt. for all
Date: Thu, 15 Jan 2026 13:47:10 +0100	[thread overview]
Message-ID: <1768474063.s2c03xsdn6.astroid@yuna.none> (raw)
In-Reply-To: <20251219194511.840583-12-m.carrara@proxmox.com>

On December 19, 2025 8:44 pm, Max R. Carrara wrote:
> Add a PVE::SectionConfig test case for plugin systems that declare a
> default property as required (in `private()->{propertyList}`), but
> mark it as optional in all child plugins (i.e. in their `options()`
> methods).
> 
> In unified mode, such properties remain marked as *required* in both
> create and update schema.

should those be optional as well?

> 
> In isolated mode, such properties are marked as *optional* in both
> create and update schema.
> 
> Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
> ---
>  test/SectionConfig/schema_comparison_test.pl | 204 +++++++++++++++++++
>  1 file changed, 204 insertions(+)
> 
> diff --git a/test/SectionConfig/schema_comparison_test.pl b/test/SectionConfig/schema_comparison_test.pl
> index 97f4820..3ae8551 100755
> --- a/test/SectionConfig/schema_comparison_test.pl
> +++ b/test/SectionConfig/schema_comparison_test.pl
> @@ -1746,6 +1746,210 @@ package RequiredCommonRequiredByAll {
>      }
>  }
>  
> +package RequiredCommonOptionalForAll {
> +    use base qw(TestPackage);
> +
> +    sub desc($class) {
> +        return
> +            "in unified mode, required default properties remain required in"
> +            . " both schemas, even if declared as optional"
> +            . " - in isolated mode, these properties are optional in both schemas";
> +    }
> +
> +    package RequiredCommonOptionalForAll::PluginBase {
> +        use base qw(PVE::SectionConfig);
> +
> +        my $DEFAULT_DATA = {
> +            propertyList => {
> +                common => {
> +                    type => 'string',
> +                    optional => 0,
> +                },
> +            },
> +        };
> +
> +        sub private($class) {
> +            return $DEFAULT_DATA;
> +        }
> +    };
> +
> +    package RequiredCommonOptionalForAll::PluginOne {
> +        use base qw(RequiredCommonOptionalForAll::PluginBase);
> +
> +        sub type($class) {
> +            return 'one';
> +        }
> +
> +        sub properties($class) {
> +            return {
> +                'prop-one' => {
> +                    type => 'string',
> +                    optional => 1,
> +                },
> +            };
> +        }
> +
> +        sub options($class) {
> +            return {
> +                common => {
> +                    optional => 1,
> +                },
> +                'prop-one' => {
> +                    optional => 1,
> +                },
> +            };
> +        }
> +    };
> +
> +    package RequiredCommonOptionalForAll::PluginTwo {
> +        use base qw(RequiredCommonOptionalForAll::PluginBase);
> +
> +        sub type($class) {
> +            return 'two';
> +        }
> +
> +        sub properties($class) {
> +            return {
> +                'prop-two' => {
> +                    type => 'string',
> +                    optional => 1,
> +                },
> +            };
> +        }
> +
> +        sub options($class) {
> +            return {
> +                common => {
> +                    optional => 1,
> +                },
> +                'prop-two' => {
> +                    optional => 1,
> +                },
> +            };
> +        }
> +    };
> +
> +    sub expected_unified_createSchema($class) {
> +        return {
> +            type => 'object',
> +            additionalProperties => 0,
> +            properties => {
> +                type => {
> +                    type => 'string',
> +                    enum => [
> +                        "one", "two",
> +                    ],
> +                },
> +                'prop-one' => {
> +                    type => 'string',
> +                    optional => 1,
> +                },
> +                'prop-two' => {
> +                    type => 'string',
> +                    optional => 1,
> +                },
> +                'common' => {
> +                    type => 'string',
> +                    optional => 0,
> +                },
> +            },
> +        };
> +    }
> +
> +    sub expected_unified_updateSchema($class) {
> +        return {
> +            type => 'object',
> +            additionalProperties => 0,
> +            properties => {
> +                'prop-one' => {
> +                    type => 'string',
> +                    optional => 1,
> +                },
> +                'prop-two' => {
> +                    type => 'string',
> +                    optional => 1,
> +                },
> +                common => {
> +                    type => 'string',
> +                    optional => 0,
> +                },
> +                $SectionConfig::Helpers::UPDATE_SCHEMA_DEFAULT_PROPERTIES->%*,
> +            },
> +        };
> +    }
> +
> +    sub expected_isolated_createSchema($class) {
> +        return {
> +            type => 'object',
> +            additionalProperties => 0,
> +            properties => {
> +                type => {
> +                    type => 'string',
> +                    enum => [
> +                        "one", "two",
> +                    ],
> +                },
> +                'prop-one' => {
> +                    'instance-types' => [
> +                        "one",
> +                    ],
> +                    'type-property' => 'type',
> +                    type => 'string',
> +                    optional => 1,
> +                },
> +                'prop-two' => {
> +                    'instance-types' => [
> +                        "two",
> +                    ],
> +                    'type-property' => 'type',
> +                    type => 'string',
> +                    optional => 1,
> +                },
> +                'common' => {
> +                    type => 'string',
> +                    optional => 1,
> +                },
> +            },
> +        };
> +    }
> +
> +    sub expected_isolated_updateSchema($class) {
> +        return {
> +            type => 'object',
> +            additionalProperties => 0,
> +            properties => {
> +                type => {
> +                    type => 'string',
> +                    enum => [
> +                        "one", "two",
> +                    ],
> +                },
> +                'prop-one' => {
> +                    'instance-types' => [
> +                        "one",
> +                    ],
> +                    'type-property' => 'type',
> +                    type => 'string',
> +                    optional => 1,
> +                },
> +                'prop-two' => {
> +                    'instance-types' => [
> +                        "two",
> +                    ],
> +                    'type-property' => 'type',
> +                    type => 'string',
> +                    optional => 1,
> +                },
> +                common => {
> +                    type => 'string',
> +                    optional => 1,
> +                },
> +                $SectionConfig::Helpers::UPDATE_SCHEMA_DEFAULT_PROPERTIES->%*,
> +            },
> +        };
> +    }
> +}
> +
>  sub test_compare_deeply($got, $expected, $test_name, $test_package) {
>      $test_name = "$test_package - $test_name";
>      my $description = $test_package->desc();
> -- 
> 2.47.3
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  reply	other threads:[~2026-01-15 12:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-19 19:44 [pve-devel] [PATCH pve-common v1 00/23] Document PVE::SectionConfig Peculiarities Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 01/23] sectionconfig: remove unused variable in get_property_schema() Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 02/23] tests: sectionconfig: add comparison test structure Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 03/23] tests: sectionconfig: add test case for fixed props in updateSchema Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 04/23] tests: sectionconfig: add case for unused properties Max R. Carrara
2026-01-15 12:47   ` Fabian Grünbichler
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 05/23] tests: sectionconfig: add case for unused optional default properties Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 06/23] tests: sectionconfig: add case for opt. default prop being req. once Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 07/23] tests: sectionconfig: add case for opt. default prop requirde by all Max R. Carrara
2026-01-15 12:47   ` Fabian Grünbichler
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 08/23] tests: sectionconfig: add case for unused required default properties Max R. Carrara
2026-01-15 12:47   ` Fabian Grünbichler
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 09/23] tests: sectionconfig: add case for req. default prop being req. once Max R. Carrara
2026-01-15 12:47   ` Fabian Grünbichler
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 10/23] tests: sectionconfig: add case for required default prop req. by all Max R. Carrara
2026-01-15 12:47   ` Fabian Grünbichler
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 11/23] tests: sectionconfig: add case for required default props opt. for all Max R. Carrara
2026-01-15 12:47   ` Fabian Grünbichler [this message]
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 12/23] tests: sectionconfig: add isolated mode test structure Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 13/23] tests: sectionconfig: add case for an ident. prop on two plugins Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 14/23] tests: sectionconfig: add case for same prop. w/ different optionality Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 15/23] tests: sectionconfig: add case for differing opt. default prop uses Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 16/23] tests: sectionconfig: add case for differing req. " Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 17/23] sectionconfig: correct docs regarding global props in unified mode Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 18/23] sectionconfig: reword docs regarding property usage in isolated mode Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 19/23] sectionconfig: extend / correct docstring of `private()` method Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 20/23] sectionconfig: note that a prop must be defined through a JSONSchema Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 21/23] sectionconfig: note that props added by plugins are always optional Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 22/23] sectionconfig: note that `createSchema()` is universal for all plugins Max R. Carrara
2025-12-19 19:44 ` [pve-devel] [PATCH pve-common v1 23/23] sectionconfig: correct example in docstring of `updateSchema()` Max R. Carrara
2026-01-15 12:44 ` [pve-devel] applied-series: [PATCH pve-common v1 00/23] Document PVE::SectionConfig Peculiarities Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1768474063.s2c03xsdn6.astroid@yuna.none \
    --to=f.gruenbichler@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal