Skip to content

Commit

Permalink
wip: stretch time
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-zededa committed Jun 25, 2024
1 parent 33fb0fb commit f96c305
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 148 deletions.
20 changes: 11 additions & 9 deletions pkg/openevec/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ type ImagesConfig struct {
}

type EdenConfig struct {
Download bool `mapstructure:"download" cobraflag:"download"`
BinDir string `mapstructure:"bin-dist" cobraflag:"bin-dist" resolvepath:""`
CertsDir string `mapstructure:"certs-dist" cobraflag:"certs-dist" resolvepath:""`
Dist string `mapstructure:"dist"`
Root string `mapstructure:"root"`
SSHKey string `mapstructure:"ssh-key" cobraflag:"ssh-key" resolvepath:""`
EdenBin string `mapstructure:"eden-bin"`
TestBin string `mapstructure:"test-bin"`
TestScenario string `mapstructure:"test-scenario"`
Download bool `mapstructure:"download" cobraflag:"download"`
BinDir string `mapstructure:"bin-dist" cobraflag:"bin-dist" resolvepath:""`
CertsDir string `mapstructure:"certs-dist" cobraflag:"certs-dist" resolvepath:""`
Dist string `mapstructure:"dist"`
Root string `mapstructure:"root"`
SSHKey string `mapstructure:"ssh-key" cobraflag:"ssh-key" resolvepath:""`
EdenBin string `mapstructure:"eden-bin"`

TestBin string `mapstructure:"test-bin"`
TestScenario string `mapstructure:"test-scenario"`
TestTimeDilation float32 `mapstructure:"test-time-dilation"`

EServer EServerConfig `mapstructure:"eserver"`

Expand Down
1 change: 1 addition & 0 deletions pkg/openevec/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func GetDefaultConfig() *EdenSetupArgs {
Force: false,
Tag: defaults.DefaultEServerTag,
},
TestTimeDilation: 1.0,
},

Adam: AdamConfig{
Expand Down
1 change: 1 addition & 0 deletions pkg/openevec/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func InitVarsFromConfig(cfg *EdenSetupArgs) (*utils.ConfigVars, error) {
cv.EServerImageDist = utils.ResolveAbsPath(cfg.Eden.Images.EServerImageDist)
cv.EServerPort = strconv.Itoa(cfg.Eden.EServer.Port)
cv.EServerIP = cfg.Eden.EServer.IP
cv.ExecCmdTimeDilation = cfg.Eden.TestTimeDilation

cv.EveCert = utils.ResolveAbsPath(cfg.Eve.Cert)
cv.EveDeviceCert = utils.ResolveAbsPath(cfg.Eve.DeviceCert)
Expand Down
157 changes: 80 additions & 77 deletions pkg/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,46 @@ var viperAccessMutex sync.RWMutex

// ConfigVars struct with parameters from config file
type ConfigVars struct {
AdamIP string
AdamPort string
AdamDomain string
AdamDir string
AdamCA string
AdamRemote bool
AdamCaching bool
AdamCachingRedis bool
AdamCachingPrefix string
AdamRemoteRedis bool
AdamRedisURLEden string
AdamRedisURLAdam string
EveHV string
EveSSID string
EveUUID string
EveName string
EveRemote bool
EveRemoteAddr string
EveQemuPorts map[string]string
EveQemuConfig string
EveDist string
SSHKey string
EveCert string
EveDeviceCert string
EveSerial string
ZArch string
DevModel string
DevModelFIle string
EdenBinDir string
EdenProg string
TestProg string
TestScenario string
EServerImageDist string
EServerPort string
EServerIP string
RegistryIP string
RegistryPort string
LogLevel string
AdamLogLevel string
AdamIP string
AdamPort string
AdamDomain string
AdamDir string
AdamCA string
AdamRemote bool
AdamCaching bool
AdamCachingRedis bool
AdamCachingPrefix string
AdamRemoteRedis bool
AdamRedisURLEden string
AdamRedisURLAdam string
EveHV string
EveSSID string
EveUUID string
EveName string
EveRemote bool
EveRemoteAddr string
EveQemuPorts map[string]string
EveQemuConfig string
EveDist string
SSHKey string
EveCert string
EveDeviceCert string
EveSerial string
ZArch string
DevModel string
DevModelFIle string
EdenBinDir string
EdenProg string
TestProg string
TestScenario string
EServerImageDist string
EServerPort string
EServerIP string
RegistryIP string
RegistryPort string
LogLevel string
AdamLogLevel string
ExecCmdTimeDilation float32
}

// InitVars loads vars from viper
Expand Down Expand Up @@ -91,44 +92,46 @@ func InitVars() (*ConfigVars, error) {
caCertPath := filepath.Join(globalCertsDir, "root-certificate.pem")
viperAccessMutex.RLock()
var vars = &ConfigVars{
AdamIP: viper.GetString("adam.ip"),
AdamPort: viper.GetString("adam.port"),
AdamDomain: viper.GetString("adam.domain"),
AdamDir: ResolveAbsPath(viper.GetString("adam.dist")),
AdamCA: caCertPath,
AdamRedisURLEden: viper.GetString("adam.redis.eden"),
SSHKey: ResolveAbsPath(viper.GetString("eden.ssh-key")),
EveCert: ResolveAbsPath(viper.GetString("eve.cert")),
EveDeviceCert: ResolveAbsPath(viper.GetString("eve.device-cert")),
EveSerial: viper.GetString("eve.serial"),
EveDist: viper.GetString("eve.dist"),
EveQemuConfig: viper.GetString("eve.qemu-config"),
ZArch: viper.GetString("eve.arch"),
EveSSID: viper.GetString("eve.ssid"),
EveHV: viper.GetString("eve.hv"),
DevModel: viper.GetString("eve.devmodel"),
DevModelFIle: viper.GetString("eve.devmodelfile"),
EveName: viper.GetString("eve.name"),
EveUUID: viper.GetString("eve.uuid"),
EveRemote: viper.GetBool("eve.remote"),
EveRemoteAddr: viper.GetString("eve.remote-addr"),
EveQemuPorts: viper.GetStringMapString("eve.hostfwd"),
AdamRemote: viper.GetBool("adam.remote.enabled"),
AdamRemoteRedis: viper.GetBool("adam.remote.redis"),
AdamCaching: viper.GetBool("adam.caching.enabled"),
AdamCachingPrefix: viper.GetString("adam.caching.prefix"),
AdamCachingRedis: viper.GetBool("adam.caching.redis"),
EdenBinDir: viper.GetString("eden.bin-dist"),
EdenProg: viper.GetString("eden.eden-bin"),
TestProg: viper.GetString("eden.test-bin"),
TestScenario: viper.GetString("eden.test-scenario"),
EServerImageDist: ResolveAbsPath(viper.GetString("eden.images.dist")),
EServerPort: viper.GetString("eden.eserver.port"),
EServerIP: viper.GetString("eden.eserver.ip"),
RegistryIP: viper.GetString("registry.ip"),
RegistryPort: viper.GetString("registry.port"),
LogLevel: viper.GetString("eve.log-level"),
AdamLogLevel: viper.GetString("eve.adam-log-level"),
AdamIP: viper.GetString("adam.ip"),
AdamPort: viper.GetString("adam.port"),
AdamDomain: viper.GetString("adam.domain"),
AdamDir: ResolveAbsPath(viper.GetString("adam.dist")),
AdamCA: caCertPath,
AdamRemote: viper.GetBool("adam.remote.enabled"),
AdamCaching: viper.GetBool("adam.caching.enabled"),
AdamCachingRedis: viper.GetBool("adam.caching.redis"),
AdamCachingPrefix: viper.GetString("adam.caching.prefix"),
AdamRemoteRedis: viper.GetBool("adam.remote.redis"),
AdamRedisURLEden: viper.GetString("adam.redis.eden"),
AdamRedisURLAdam: "",
EveHV: viper.GetString("eve.hv"),
EveSSID: viper.GetString("eve.ssid"),
EveUUID: viper.GetString("eve.uuid"),
EveName: viper.GetString("eve.name"),
EveRemote: viper.GetBool("eve.remote"),
EveRemoteAddr: viper.GetString("eve.remote-addr"),
EveQemuPorts: viper.GetStringMapString("eve.hostfwd"),
EveQemuConfig: viper.GetString("eve.qemu-config"),
EveDist: viper.GetString("eve.dist"),
SSHKey: ResolveAbsPath(viper.GetString("eden.ssh-key")),
EveCert: ResolveAbsPath(viper.GetString("eve.cert")),
EveDeviceCert: ResolveAbsPath(viper.GetString("eve.device-cert")),
EveSerial: viper.GetString("eve.serial"),
ZArch: viper.GetString("eve.arch"),
DevModel: viper.GetString("eve.devmodel"),
DevModelFIle: viper.GetString("eve.devmodelfile"),
EdenBinDir: viper.GetString("eden.bin-dist"),
EdenProg: viper.GetString("eden.eden-bin"),
TestProg: viper.GetString("eden.test-bin"),
TestScenario: viper.GetString("eden.test-scenario"),
EServerImageDist: ResolveAbsPath(viper.GetString("eden.images.dist")),
EServerPort: viper.GetString("eden.eserver.port"),
EServerIP: viper.GetString("eden.eserver.ip"),
RegistryIP: viper.GetString("registry.ip"),
RegistryPort: viper.GetString("registry.port"),
LogLevel: viper.GetString("eve.log-level"),
AdamLogLevel: viper.GetString("eve.adam-log-level"),
ExecCmdTimeDilation: float32(viper.GetFloat64("eden.exec-dilation")),
}
viperAccessMutex.RUnlock()
redisPasswordFile := filepath.Join(globalCertsDir, defaults.DefaultRedisPasswordFile)
Expand Down
100 changes: 50 additions & 50 deletions tests/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,67 +139,67 @@ func TestAppStatus(t *testing.T) {
args := flag.Args()
if len(args) == 0 {
t.Fatalf("Usage: %s [options] state app_name...\n", os.Args[0])
} else {
secs := int(timewait.Seconds())
state := args[0]
fmt.Printf("apps: '%s' state: '%s' secs: %d\n",
args[1:], state, secs)

apps := args[1:]
if apps[len(apps)-1] == "&" {
apps = apps[:len(apps)-1]
}
states = make(map[string][]appState)
for _, el := range apps {
states[el] = []appState{{
state: "no info from controller",
timestamp: time.Now()}}
}
return
}
secs := int(timewait.Seconds())
state := args[0]
fmt.Printf("apps: '%s' state: '%s' secs: %d\n",
args[1:], state, secs)

apps := args[1:]
if apps[len(apps)-1] == "&" {
apps = apps[:len(apps)-1]
}
states = make(map[string][]appState)
for _, el := range apps {
states[el] = []appState{{
state: "no info from controller",
timestamp: time.Now()}}
}

if !*newitems {
// observe existing info object and feed them into eveState object
if err := tc.GetController().InfoLastCallback(edgeNode.GetID(), nil, eveState.InfoCallback()); err != nil {
t.Fatal(err)
}
if !*newitems {
// observe existing info object and feed them into eveState object
if err := tc.GetController().InfoLastCallback(edgeNode.GetID(), nil, eveState.InfoCallback()); err != nil {
t.Fatal(err)
}
}

if ready := checkState(eveState, state, apps); ready == nil {
if ready := checkState(eveState, state, apps); ready == nil {

tc.AddProcInfo(edgeNode, checkApp(state, apps))
tc.AddProcInfo(edgeNode, checkApp(state, apps))

callback := func() {
t.Errorf("ASSERTION FAILED (%s): expected apps %s in %s state", time.Now().Format(time.RFC3339Nano), apps, state)
for k, v := range states {
t.Errorf("\tactual %s: %s", k, v[len(v)-1].state)
if checkNewLastState(k, state) {
t.Errorf("\thistory of states for %s:", k)
for _, st := range v {
t.Errorf("\t\tstate: %s received in: %s", st.state, st.timestamp.Format(time.RFC3339Nano))
}
callback := func() {
t.Errorf("ASSERTION FAILED (%s): expected apps %s in %s state", time.Now().Format(time.RFC3339Nano), apps, state)
for k, v := range states {
t.Errorf("\tactual %s: %s", k, v[len(v)-1].state)
if checkNewLastState(k, state) {
t.Errorf("\thistory of states for %s:", k)
for _, st := range v {
t.Errorf("\t\tstate: %s received in: %s", st.state, st.timestamp.Format(time.RFC3339Nano))
}
for _, app := range eveState.Applications() {
if app.Name == k {
appID, err := uuid.FromString(app.UUID)
if err != nil {
t.Fatal(err)
}
fmt.Printf("--- app %s logs ---\n", app.Name)
if err = tc.GetController().LogAppsChecker(edgeNode.GetID(), appID, nil, eapps.HandleFactory(types.OutputFormatJSON, false), eapps.LogExist, 0); err != nil {
t.Fatalf("LogAppsChecker: %s", err)
}
fmt.Println("------")
}
for _, app := range eveState.Applications() {
if app.Name == k {
appID, err := uuid.FromString(app.UUID)
if err != nil {
t.Fatal(err)
}
fmt.Printf("--- app %s logs ---\n", app.Name)
if err = tc.GetController().LogAppsChecker(edgeNode.GetID(), appID, nil, eapps.HandleFactory(types.OutputFormatJSON, false), eapps.LogExist, 0); err != nil {
t.Fatalf("LogAppsChecker: %s", err)
}
fmt.Println("------")
}
}
}

tc.WaitForProcWithErrorCallback(secs, callback)

} else {
t.Log(utils.AddTimestamp(ready.Error()))
}

// sleep to reduce concurrency effects
time.Sleep(1 * time.Second)
tc.WaitForProcWithErrorCallback(secs, callback)

} else {
t.Log(utils.AddTimestamp(ready.Error()))
}

// sleep to reduce concurrency effects
time.Sleep(1 * time.Second)
}
Loading

0 comments on commit f96c305

Please sign in to comment.