-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Golang E2E in Openshift API-CI #1384
Changes from 17 commits
f7e24f8
c32dbe0
5b758c4
5880b15
0ef1599
5962cf4
65a8f92
2070197
6f56b96
7eb299a
00ba830
66bf196
3d3bb7a
6b8d72b
5615d9f
0ad1613
435cdfc
455ab76
25d9d05
e3cc22e
71206b2
1232663
6a4226a
206eb96
a6a8bf2
0cabce7
1a307bc
8041d49
06ea958
c3f69b6
7a0dd70
7927677
1bb44c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM openshift/origin-release:golang-1.12 | ||
|
||
WORKDIR /go/src/github.com/operator-framework/operator-sdk | ||
# Set gopath before build and include build destination in PATH | ||
ENV GOPATH=/go PATH=/go/src/github.com/operator-framework/operator-sdk/build:$PATH | ||
|
||
COPY . . | ||
|
||
RUN make ci-build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM osdk-builder as builder | ||
|
||
RUN ci/tests/e2e-go-scaffold.sh | ||
|
||
ENV GO111MODULE=on | ||
RUN touch /go/src/github.com/operator-framework/operator-sdk/go.mod | ||
RUN cd /go/src/$(cat /project_path.tmp)/memcached-operator && go build -gcflags "all=-trimpath=${GOPATH}" -asmflags "all=-trimpath=${GOPATH}" -o /memcached-operator $(cat /project_path.tmp)/memcached-operator/cmd/manager | ||
|
||
FROM registry.access.redhat.com/ubi7/ubi-minimal:latest | ||
|
||
ENV OPERATOR=/usr/local/bin/memcached-operator \ | ||
USER_UID=1001 \ | ||
USER_NAME=memcached-operator | ||
|
||
# install operator binary | ||
COPY --from=builder /memcached-operator ${OPERATOR} | ||
COPY test/test-framework/build/bin /usr/local/bin | ||
|
||
RUN /usr/local/bin/user_setup | ||
|
||
ENTRYPOINT ["/usr/local/bin/entrypoint"] | ||
|
||
USER ${USER_UID} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
go test ./test/e2e/... -root=. -globalMan=testdata/empty.yaml -generate-only $1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
make install | ||
# this configures the image correctly for memcached-operator | ||
component="memcached-operator" | ||
eval IMAGE=$IMAGE_FORMAT | ||
go test ./test/e2e/... -root=. -globalMan=testdata/empty.yaml -v -no-image-build -image $IMAGE $1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2019 The Operator-SDK Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package test | ||
|
||
// This file allows us to share a variable between the test framework and our | ||
// internal tests without exposing variables | ||
|
||
var OnlyGenerate *bool |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ func Become(ctx context.Context, lockName string) error { | |
|
||
ns, err := k8sutil.GetOperatorNamespace() | ||
if err != nil { | ||
if err == k8sutil.ErrNoNamespace { | ||
if err == k8sutil.ErrNoNamespace || err == k8sutil.ErrRunLocal { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One question: At this point is there ever a case where Looking at the errors returned by cluster specific functions such as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a user is using our commands, |
||
log.Info("Skipping leader election; not running in a cluster.") | ||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no other way around this? Just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could add the variable to
pkg/test
, but I didn't want to expose that as part of the public API, so I decided it would be better to keep that in a separate internal package. If we feel that it's fine having that variable exposed, we could put it inpkg/test
instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an okay tradeoff, thanks for the explanation!