github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/cmn/tests/api_test.go (about) 1 // Package test provides tests for common low-level types and utilities for all aistore projects 2 /* 3 * Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved. 4 */ 5 package tests_test 6 7 import ( 8 "github.com/NVIDIA/aistore/api/apc" 9 "github.com/NVIDIA/aistore/cmn" 10 . "github.com/onsi/ginkgo/v2" 11 . "github.com/onsi/gomega" 12 ) 13 14 var _ = Describe("API", func() { 15 Describe("Apply", func() { 16 DescribeTable("should successfully apply all the props", 17 func(src cmn.Bprops, props cmn.BpropsToSet, expect cmn.Bprops) { 18 src.Apply(&props) 19 Expect(src).To(Equal(expect)) 20 }, 21 Entry("non-nested field", 22 cmn.Bprops{}, 23 cmn.BpropsToSet{ 24 Access: apc.Ptr[apc.AccessAttrs](1024), 25 }, 26 cmn.Bprops{ 27 Access: 1024, 28 }, 29 ), 30 Entry("non-nested field and non-empty initial struct", 31 cmn.Bprops{ 32 Provider: apc.AWS, 33 }, 34 cmn.BpropsToSet{ 35 Access: apc.Ptr[apc.AccessAttrs](1024), 36 }, 37 cmn.Bprops{ 38 Provider: apc.AWS, 39 Access: 1024, 40 }, 41 ), 42 Entry("nested field", 43 cmn.Bprops{}, 44 cmn.BpropsToSet{ 45 Cksum: &cmn.CksumConfToSet{ 46 Type: apc.Ptr("value"), 47 }, 48 }, 49 cmn.Bprops{ 50 Cksum: cmn.CksumConf{ 51 Type: "value", 52 }, 53 }, 54 ), 55 Entry("multiple nested fields", 56 cmn.Bprops{}, 57 cmn.BpropsToSet{ 58 Cksum: &cmn.CksumConfToSet{ 59 Type: apc.Ptr("value"), 60 ValidateColdGet: apc.Ptr(true), 61 }, 62 EC: &cmn.ECConfToSet{ 63 Enabled: apc.Ptr(true), 64 ObjSizeLimit: apc.Ptr[int64](1024), 65 }, 66 }, 67 cmn.Bprops{ 68 Cksum: cmn.CksumConf{ 69 Type: "value", 70 ValidateColdGet: true, 71 ValidateWarmGet: false, // check default value didn't change 72 }, 73 EC: cmn.ECConf{ 74 Enabled: true, 75 ObjSizeLimit: 1024, 76 DataSlices: 0, // check default value didn't change 77 ParitySlices: 0, // check default value didn't change 78 }, 79 }, 80 ), 81 Entry("multiple nested fields and non-empty initial struct", 82 cmn.Bprops{ 83 Provider: apc.AWS, 84 Cksum: cmn.CksumConf{ 85 ValidateColdGet: true, 86 ValidateWarmGet: false, 87 }, 88 Mirror: cmn.MirrorConf{ 89 Enabled: true, 90 Copies: 3, 91 }, 92 LRU: cmn.LRUConf{ 93 Enabled: true, 94 }, 95 }, 96 cmn.BpropsToSet{ 97 Cksum: &cmn.CksumConfToSet{ 98 Type: apc.Ptr("value"), 99 }, 100 Mirror: &cmn.MirrorConfToSet{ 101 Enabled: apc.Ptr(true), 102 Copies: apc.Ptr[int64](3), 103 }, 104 Access: apc.Ptr[apc.AccessAttrs](10), 105 }, 106 cmn.Bprops{ 107 Provider: apc.AWS, 108 Cksum: cmn.CksumConf{ 109 Type: "value", 110 ValidateColdGet: true, 111 ValidateWarmGet: false, 112 }, 113 Mirror: cmn.MirrorConf{ 114 Enabled: true, 115 Copies: 3, 116 }, 117 LRU: cmn.LRUConf{ 118 Enabled: true, 119 }, 120 Access: 10, 121 }, 122 ), 123 Entry("all fields", 124 cmn.Bprops{}, 125 cmn.BpropsToSet{ 126 Versioning: &cmn.VersionConfToSet{ 127 Enabled: apc.Ptr(true), 128 ValidateWarmGet: apc.Ptr(true), 129 }, 130 Cksum: &cmn.CksumConfToSet{ 131 Type: apc.Ptr("value"), 132 ValidateColdGet: apc.Ptr(true), 133 ValidateWarmGet: apc.Ptr(false), 134 ValidateObjMove: apc.Ptr(true), 135 EnableReadRange: apc.Ptr(false), 136 }, 137 Mirror: &cmn.MirrorConfToSet{ 138 Copies: apc.Ptr[int64](10), 139 Burst: apc.Ptr(32), 140 Enabled: apc.Ptr(false), 141 }, 142 EC: &cmn.ECConfToSet{ 143 Enabled: apc.Ptr(true), 144 ObjSizeLimit: apc.Ptr[int64](1024), 145 DataSlices: apc.Ptr(1024), 146 ParitySlices: apc.Ptr(1024), 147 Compression: apc.Ptr("false"), 148 }, 149 Access: apc.Ptr[apc.AccessAttrs](1024), 150 WritePolicy: &cmn.WritePolicyConfToSet{ 151 MD: apc.Ptr(apc.WriteDelayed), 152 }, 153 }, 154 cmn.Bprops{ 155 Versioning: cmn.VersionConf{ 156 Enabled: true, 157 ValidateWarmGet: true, 158 }, 159 Cksum: cmn.CksumConf{ 160 Type: "value", 161 ValidateColdGet: true, 162 ValidateWarmGet: false, 163 ValidateObjMove: true, 164 EnableReadRange: false, 165 }, 166 Mirror: cmn.MirrorConf{ 167 Copies: 10, 168 Burst: 32, 169 Enabled: false, 170 }, 171 EC: cmn.ECConf{ 172 Enabled: true, 173 ObjSizeLimit: 1024, 174 DataSlices: 1024, 175 ParitySlices: 1024, 176 Compression: "false", 177 }, 178 Access: 1024, 179 WritePolicy: cmn.WritePolicyConf{ 180 Data: "", 181 MD: apc.WriteDelayed, 182 }, 183 }, 184 ), 185 ) 186 }) 187 })