|
7 | 7 | "os/exec" |
8 | 8 | "path/filepath" |
9 | 9 | "runtime" |
| 10 | + "slices" |
10 | 11 | "strings" |
11 | 12 |
|
12 | 13 | "github.com/pelletier/go-toml" |
@@ -258,9 +259,134 @@ Be aware that any TODO requires your attention before your run the final test! |
258 | 259 | }, |
259 | 260 | }, |
260 | 261 | { |
261 | | - Name: "config", |
| 262 | + Name: "compat", |
262 | 263 | Aliases: []string{"c"}, |
263 | | - Usage: "Shapes your test config, removes outputs, formatting ,etc", |
| 264 | + Usage: "Performs cluster compatibility testing", |
| 265 | + Subcommands: []*cli.Command{ |
| 266 | + { |
| 267 | + Name: "restore", |
| 268 | + Aliases: []string{"r"}, |
| 269 | + Flags: []cli.Flag{ |
| 270 | + &cli.StringFlag{ |
| 271 | + Name: "base_branch", |
| 272 | + Usage: "Base branch on which to restore", |
| 273 | + Value: "develop", |
| 274 | + }, |
| 275 | + }, |
| 276 | + Usage: "Restores back to develop", |
| 277 | + Action: func(c *cli.Context) error { |
| 278 | + return framework.RestoreToBranch(c.String("base_branch")) |
| 279 | + }, |
| 280 | + }, |
| 281 | + { |
| 282 | + Name: "backward", |
| 283 | + Aliases: []string{"b"}, |
| 284 | + Flags: []cli.Flag{ |
| 285 | + &cli.IntFlag{ |
| 286 | + Name: "versions_back", |
| 287 | + Aliases: []string{"v"}, |
| 288 | + Usage: "How many versions back to test", |
| 289 | + Value: 1, |
| 290 | + }, |
| 291 | + &cli.IntFlag{ |
| 292 | + Name: "nodes", |
| 293 | + Aliases: []string{"n"}, |
| 294 | + Usage: "How many nodes to upgrade", |
| 295 | + Value: 3, |
| 296 | + }, |
| 297 | + &cli.StringFlag{ |
| 298 | + Name: "registry", |
| 299 | + Aliases: []string{"r"}, |
| 300 | + Usage: "Docker Image registry for Chainlink node", |
| 301 | + Value: "smartcontract/chainlink", |
| 302 | + }, |
| 303 | + &cli.StringFlag{ |
| 304 | + Name: "buildcmd", |
| 305 | + Aliases: []string{"b"}, |
| 306 | + Usage: "Environment build command", |
| 307 | + Value: "just cli", |
| 308 | + }, |
| 309 | + &cli.StringFlag{ |
| 310 | + Name: "envcmd", |
| 311 | + Aliases: []string{"e"}, |
| 312 | + Usage: "Environment bootstrap command", |
| 313 | + }, |
| 314 | + &cli.StringFlag{ |
| 315 | + Name: "testcmd", |
| 316 | + Aliases: []string{"t"}, |
| 317 | + Usage: "Test verification command", |
| 318 | + }, |
| 319 | + &cli.StringSliceFlag{ |
| 320 | + Name: "include_tags", |
| 321 | + Usage: "Patterns to include specific tags (e.g., beta,rc,v0,v1)", |
| 322 | + }, |
| 323 | + &cli.StringSliceFlag{ |
| 324 | + Name: "exclude_tags", |
| 325 | + Usage: "Patterns to exclude specific tags (e.g., beta,rc,v0,v1)", |
| 326 | + Value: cli.NewStringSlice("beta", "rc", "v0", "ccip", "cre", "datastreams"), |
| 327 | + }, |
| 328 | + }, |
| 329 | + Usage: "Rollbacks N versions back, runs the test the upgrades CL nodes with new versions", |
| 330 | + Action: func(c *cli.Context) error { |
| 331 | + versionsBack := c.Int("versions_back") |
| 332 | + registry := c.String("registry") |
| 333 | + include := c.StringSlice("include_tags") |
| 334 | + exclude := c.StringSlice("exclude_tags") |
| 335 | + |
| 336 | + buildcmd := c.String("buildcmd") |
| 337 | + envcmd := c.String("envcmd") |
| 338 | + testcmd := c.String("testcmd") |
| 339 | + nodes := c.Int("nodes") |
| 340 | + // test logic is: |
| 341 | + // - rollback to selected tag |
| 342 | + // - spin up the env and perform the initial smoke test |
| 343 | + // - upgrade N CL nodes with preversing DB volume (shared database) |
| 344 | + // - perform the test again |
| 345 | + // - repeat until all the new versions are validated |
| 346 | + tags, err := framework.RollbackToEarliestSemverTag(versionsBack, include, exclude) |
| 347 | + if err != nil { |
| 348 | + return err |
| 349 | + } |
| 350 | + if envcmd == "" || testcmd == "" { |
| 351 | + framework.L.Info().Msg("No envcmd or testcmd provided, skipping") |
| 352 | + return nil |
| 353 | + } |
| 354 | + if _, err := framework.ExecCmdWithContext(c.Context, buildcmd); err != nil { |
| 355 | + return err |
| 356 | + } |
| 357 | + if _, err := framework.ExecCmdWithContext(c.Context, envcmd); err != nil { |
| 358 | + return err |
| 359 | + } |
| 360 | + if _, err := framework.ExecCmdWithContext(c.Context, testcmd); err != nil { |
| 361 | + return err |
| 362 | + } |
| 363 | + // reverse and skip current version |
| 364 | + slices.Reverse(tags) |
| 365 | + tags = tags[1:] |
| 366 | + // TODO: remove it with real tags when they match |
| 367 | + for _, tag := range tags { |
| 368 | + tagToPull := strings.ReplaceAll(tag, "+compat", "") |
| 369 | + for i := range nodes { |
| 370 | + err := framework.UpgradeContainer( |
| 371 | + c.Context, |
| 372 | + fmt.Sprintf("don-node%d", i), |
| 373 | + fmt.Sprintf("%s:%s", registry, tagToPull)) |
| 374 | + if err != nil { |
| 375 | + return err |
| 376 | + } |
| 377 | + } |
| 378 | + if _, err := framework.ExecCmd(testcmd); err != nil { |
| 379 | + return err |
| 380 | + } |
| 381 | + } |
| 382 | + return nil |
| 383 | + }, |
| 384 | + }, |
| 385 | + }, |
| 386 | + }, |
| 387 | + { |
| 388 | + Name: "config", |
| 389 | + Usage: "Shapes your test config, removes outputs, formatting ,etc", |
264 | 390 | Subcommands: []*cli.Command{ |
265 | 391 | { |
266 | 392 | Name: "fmt", |
|
0 commit comments