tests

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BootImageFactory = factory.NewFactory(
	&model.BootImage{},
).Attr("Name", func(args factory.Args) (interface{}, error) {
	return randomdata.Alphanumeric(randomdata.Number(2, 10)), nil
}).Attr("KernelPath", func(args factory.Args) (interface{}, error) {
	return randomdata.Alphanumeric(randomdata.Number(5, 50)), nil
})
View Source
var HostFactory = factory.NewFactory(
	&model.Host{},
).Attr("Name", func(args factory.Args) (interface{}, error) {
	return randomdata.Alphanumeric(randomdata.Number(5, 50)), nil
}).OnCreate(func(args factory.Args) error {
	host := args.Instance().(*model.Host)
	host.Interfaces[0].BMC = false
	host.Interfaces[1].BMC = true
	uuid, err := ksuid.NewRandom()
	if err != nil {
		return err
	}
	host.ID = uuid
	return nil
}).SubSliceFactory("Interfaces", NetInterfaceFactory, func() int { return 2 })
View Source
var NetInterfaceFactory = factory.NewFactory(
	&model.NetInterface{},
).Attr("Name", func(args factory.Args) (interface{}, error) {
	return randomdata.Alphanumeric(randomdata.Number(2, 10)), nil
}).Attr("FQDN", func(args factory.Args) (interface{}, error) {
	return randomdata.Alphanumeric(randomdata.Number(5, 50)), nil
}).Attr("MAC", func(args factory.Args) (interface{}, error) {
	return net.ParseMAC(randomdata.MacAddress())
}).Attr("IP", func(args factory.Args) (interface{}, error) {
	return net.ParseIP(randomdata.IpV4Address()), nil
})
View Source
var TestBootImageJSON = []byte(`{
	"name": "compute",
	"kernel": "/var/grendel/images/centos7/vmlinuz",
	"initrd": [
		"/var/grendel/images/centos7/ccr-initrd.img"
	],
	"liveimg": "/var/grendel/images/compute-node/compute-node-squashfs.img",
	"cmdline": "console=tty0 console=ttyS0 BOOTIF=$mac rd.neednet=1 ip=dhcp ks=$kickstart network ksdevice=bootif ks.device=bootif inst.stage2=$repo/centos7"
}`)
View Source
var TestHostJSON = []byte(`{"firmware": "","id": "1VCnR6qevU5BbihTIvZEhX002CI","interfaces": [{"bmc": false,"fqdn": "tux01.compute.local", "ifname": "", "ip": "10.10.1.2", "mac": "d0:93:ae:e1:b5:2e" } ], "name": "tux01", "boot_image": "centos6", "provision": true }`)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL