Skip to content

Commit a475177

Browse files
rl-gitpodroboquat
authored andcommitted
[integration-test] Add support for new IDE config and sanity checks
1 parent 2847ef3 commit a475177

File tree

4 files changed

+48
-8
lines changed

4 files changed

+48
-8
lines changed

components/registry-facade/pkg/registry/manifest.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ func (mh *manifestHandler) getManifest(w http.ResponseWriter, r *http.Request) {
137137

138138
_, desc, err := mh.Resolver.Resolve(ctx, ref)
139139
if err != nil {
140+
log.WithError(err).WithField("ref", ref).WithFields(logFields).Error("cannot resolve")
140141
// ErrInvalidAuthorization
141142
return err
142143
}
@@ -155,6 +156,7 @@ func (mh *manifestHandler) getManifest(w http.ResponseWriter, r *http.Request) {
155156

156157
manifest, ndesc, err := DownloadManifest(ctx, fetcher, desc, WithStore(mh.Store))
157158
if err != nil {
159+
log.WithError(err).WithField("desc", desc).WithFields(logFields).Error("cannot download manifest")
158160
return distv2.ErrorCodeManifestUnknown.WithDetail(err)
159161
}
160162
desc = *ndesc
@@ -165,19 +167,22 @@ func (mh *manifestHandler) getManifest(w http.ResponseWriter, r *http.Request) {
165167
// download config
166168
cfg, err := DownloadConfig(ctx, fetcher, manifest.Config)
167169
if err != nil {
170+
log.WithError(err).WithFields(logFields).Error("cannot download config")
168171
return err
169172
}
170173

171174
// modify config
172175
addonLayer, err := mh.ConfigModifier(ctx, mh.Spec, cfg)
173176
if err != nil {
177+
log.WithError(err).WithFields(logFields).Error("cannot modify config")
174178
return err
175179
}
176180
manifest.Layers = append(manifest.Layers, addonLayer...)
177181

178182
// place config in store
179183
rawCfg, err := json.Marshal(cfg)
180184
if err != nil {
185+
log.WithError(err).WithFields(logFields).Error("cannot marshal config")
181186
return err
182187
}
183188
cfgDgst := digest.FromBytes(rawCfg)

components/ws-proxy/pkg/proxy/infoprovider.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ func (c *workspaceInfoCache) Delete(workspaceID string, instanceID string) {
458458
}
459459

460460
if _, ok := activePublicPorts[instanceIDEPublicPort]; !ok {
461-
log.WithField("workspaceID", workspaceID).WithField("instanceID", instanceID).WithField("port", instanceIDEPublicPort).Debug("deleting port for workspace")
462461
delete(c.coordsByPublicPort, instanceIDEPublicPort)
463462
}
464463
}

test/pkg/integration/integration.go

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,12 +600,11 @@ func (t *Test) selectPod(component ComponentType, options selectPodOptions) (pod
600600

601601
// ServerConfigPartial is the subset of server config we're using for integration tests.
602602
// Ideally we're using a definition derived from the config interface, someday...
603+
// NOTE: keep in sync with chart/templates/server-configmap.yaml
603604
type ServerConfigPartial struct {
604605
HostURL string `json:"hostUrl"`
605606
WorkspaceDefaults struct {
606-
IDEImageAliases struct {
607-
Code string `json:"code"`
608-
} `json:"ideImageAliases"`
607+
WorkspaceImage string `json:"workspaceImage"`
609608
} `json:"workspaceDefaults"`
610609
}
611610

@@ -624,7 +623,38 @@ func (t *Test) GetServerConfig() (*ServerConfigPartial, error) {
624623
var config ServerConfigPartial
625624
err = json.Unmarshal([]byte(configJson), &config)
626625
if err != nil {
627-
return nil, fmt.Errorf("error unmarshalling config: %v", err)
626+
return nil, fmt.Errorf("error unmarshalling server config: %v", err)
627+
}
628+
return &config, nil
629+
}
630+
631+
// ServerIDEConfigPartial is the subset of server IDE config we're using for integration tests.
632+
// NOTE: keep in sync with chart/templates/server-ide-configmap.yaml
633+
type ServerIDEConfigPartial struct {
634+
IDEVersion string `json:"ideVersion"`
635+
IDEImageRepo string `json:"ideImageRepo"`
636+
IDEImageAliases struct {
637+
Code string `json:"code"`
638+
CodeLatest string `json:"code-latest"`
639+
} `json:"ideImageAliases"`
640+
}
641+
642+
func (t *Test) GetServerIDEConfig() (*ServerIDEConfigPartial, error) {
643+
cm, err := t.clientset.CoreV1().ConfigMaps(t.namespace).Get(context.Background(), "server-ide-config", metav1.GetOptions{})
644+
if err != nil {
645+
return nil, err
646+
}
647+
648+
key := "config.json"
649+
configJson, ok := cm.Data[key]
650+
if !ok {
651+
return nil, fmt.Errorf("key %s not found", key)
652+
}
653+
654+
var config ServerIDEConfigPartial
655+
err = json.Unmarshal([]byte(configJson), &config)
656+
if err != nil {
657+
return nil, fmt.Errorf("error unmarshalling server IDE config: %v", err)
628658
}
629659
return &config, nil
630660
}

test/pkg/integration/workspace.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,20 @@ func LaunchWorkspaceDirectly(it *Test, opts ...LaunchWorkspaceDirectlyOpt) (res
128128
return
129129
}
130130
}
131+
if workspaceImage == "" {
132+
it.t.Fatalf("cannot start workspaces without a workspace image (required by registry-facade resolver)")
133+
}
131134

132135
ideImage := options.IdeImage
133136
if ideImage == "" {
134-
cfg, err := it.GetServerConfig()
137+
cfg, err := it.GetServerIDEConfig()
135138
if err != nil {
136-
it.t.Fatalf("cannot find server config: %q", err)
139+
it.t.Fatalf("cannot find server IDE config: %q", err)
140+
}
141+
ideImage = cfg.IDEImageAliases.Code
142+
if ideImage == "" {
143+
it.t.Fatalf("cannot start workspaces without an IDE image (required by registry-facade resolver)")
137144
}
138-
ideImage = cfg.WorkspaceDefaults.IDEImageAliases.Code
139145
}
140146

141147
req := &wsmanapi.StartWorkspaceRequest{

0 commit comments

Comments
 (0)