Skip to content

Conversation

costinm
Copy link
Contributor

@costinm costinm commented Dec 18, 2017

Multiple changes to improve build and testing with the go toolchain.

  • presubmit changes to use go tools.

  • stop using the k8s config linked from the user home to some dir that gets picked by bazel.
    It is pretty dangerous and flaky - unit tests are actually run against whatever cluster the
    developer has set, may affect a live cluster. It also pollutes the source tree and is not standard
    go. Refactored the files using config to use a common method.

  • script equivalent with the circleci local unit test env, consisting of etcd+apiserver.

  • checkin few missing files, pending Dougz full move to make/shell generation for automation.
    Current circleci build simply excludes the tests.

- istio builds using go toolchain instead of bazel. 

Moved the local k8s apiserver testing env from circleci scripts.
For go build/test, use the local k8s for unit tests - not only avoids
poluting the source tree, but it was dangerous to run unit test against
a user real k8s config.

Envoy is also tested from the output directory instead of source tree.
The circleci scripts were excluding those tests.
Doug's script will automate generation - this PR doesn't include the
bazel generate and copy since it's going away.
Doug's change for standalone generation should generate all files, this
PR doesn't add back the bazel gen.
The GOPATH is mapped on the same location in the container, and the
build runs as the current user.
The bazel part (with the user's real cluster linked and used by unit
tests) will go away when we stop using bazel.
First use KUBECONFIG, then the kube/platform/config which might be a
safe config. Last use the users' .kube/config - with a warning.
@codecov
Copy link

codecov bot commented Dec 18, 2017

Codecov Report

Merging #2220 into master will decrease coverage by 0.18%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2220      +/-   ##
==========================================
- Coverage   78.24%   78.05%   -0.19%     
==========================================
  Files         205      206       +1     
  Lines       18342    18251      -91     
==========================================
- Hits        14351    14246     -105     
- Misses       3242     3258      +16     
+ Partials      749      747       -2
Flag Coverage Δ
#broker 47.27% <ø> (+1.17%) ⬆️
#mixer 77.77% <ø> (-0.3%) ⬇️
#pilot 79.15% <ø> (-0.06%) ⬇️
#security 87.24% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pilot/cmd/pilot-discovery/server/monitoring.go 64% <0%> (-16%) ⬇️
mixer/adapter/prometheus/server.go 92% <0%> (-3.84%) ⬇️
mixer/adapter/denier/denier.go 88.88% <0%> (-3.22%) ⬇️
mixer/adapter/servicecontrol/testhelper.go 68.75% <0%> (-2.31%) ⬇️
mixer/adapter/list/list.go 94.21% <0%> (-1%) ⬇️
mixer/adapter/list/stringList.go 100% <0%> (ø) ⬆️
mixer/adapter/servicecontrol/client.go 0% <0%> (ø) ⬆️
mixer/adapter/memquota/keys.go 100% <0%> (ø) ⬆️
broker/pkg/version/version.go 100% <0%> (ø)
mixer/adapter/stackdriver/metric/bufferedClient.go 93.54% <0%> (+3.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c05f70...9eece2a. Read the comment docs.

costinm and others added 3 commits December 17, 2017 19:44
This is only needed for the transition.
Bazel is failing again for me with an obscure message - the build files are
written blindly, it appears prow still works.
export OUT=${TOP}/out

# components used in the test (starting with circleci for consistency, eventually ci will use this)
export K8S_VER=v1.7.4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very old. 1.9 just got released.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using same version that circleci is using, and I believe it's the min. version of k8s we support.

We can run test envs with 1.9 as well.

}

return f
return k8s.Kubeconfig("/../../../../../pilot/platform/kube/config")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where's the file being symlinked?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the old bazel - I'm not changing anything, I assume scripts will do it.

For go/make: it is no longer used. Once bazel is out I'll also remove this line, and only use
KUBECONFIG and the localhost/standalone apiserver conf for unit tests, and whatever the new
testing framework uses for integration ( most tests can be run in multiple environments ).

@@ -1,11 +1,11 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: bazel-out/local-fastbuild/genfiles/mixer/tools/codegen/pkg/interfacegen/testdata/apa_tmpl.proto
// source: bazel-out/k8-fastbuild/genfiles/mixer/tools/codegen/pkg/interfacegen/testdata/apa_tmpl.proto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated scripts... Will try to remove it, but once Doug has his PR in I assume all those will
be replaced.

@kyessenov
Copy link
Contributor

Looks reasonable. I'd like to keep a check on the bash scripting that will be happening with the Makefile approach. I think what you have here for spinning up local apiserver is OK, but if there's a third party project that can do that (even if it's minikube), I'd prefer that.

Also, I see a lot of go install. Should we be using go build -i instead? That way we don't mess with other projects in the same $GOROOT (which I'm sure many developers have).

@costinm
Copy link
Contributor Author

costinm commented Dec 18, 2017

On the shell script: it's replicating what circleci has been doing for now, but eventually this will be migrated into the new test framework, as one of the environments.

For 'unit test' having the etcd/apiserver is a reasonable option, but the goal is to be able to run
one test in multiple environments - however this PR is only focusing on the short term
migration to go and consistency with the ci.

@costinm
Copy link
Contributor Author

costinm commented Dec 18, 2017

/retest

--tls-cert-file ${CERTDIR}/apiserver.crt \
--tls-private-key-file ${CERTDIR}/apiserver.key \
--service-cluster-ip-range 10.99.0.0/16 \
--port 8080 -v 2 --insecure-bind-address 0.0.0.0 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define 8080 and ranges as constants before the command?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The port - yes, I'm planning to do this - current code is cut&pasted from circleci, but for running on
local machine it probably needs more customization. However not top priority, after it works we can
fine tune it... (and better yet - this can be moved into the new test framework !)

Need to keep bazel default until everythign else is in.
@costinm
Copy link
Contributor Author

costinm commented Dec 19, 2017

/retest

Copy link
Contributor

@douglas-reid douglas-reid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, this looks reasonable to me. Most important thing is to get it all passing, then we can come back and clean up.

Makefile Outdated
go install istio.io/istio/pilot/cmd/sidecar-initializer

.PHONY: mixs
mixs: vendor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not clear where this belongs, but at some point we need to add a generate target that can call go generate istio.io/istio/... before it does a full build.

echo "updating autogen files..."
bin/regenerate_files.py
#echo "updating autogen files..."
#bin/regenerate_files.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above, we need something to do proper generation somewhere. i don't have strong informed opinions on where, however.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if people are more likely to install the pre-submit hook (I forget sometimes), or to
run make / test.

But it's clear make will need to have the target - so maybe we can start with having it in the makefile.

# Predefined:
# - minikube: will start a regular minikube in a VM
#
function lunch() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this written around midday 😜 ?

s/lunch/launch (here and in the comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, 8 years of android ( envsetup and lunch are the first 2 commands android devs type every day).
https://source.android.com/setup/building

@@ -177,7 +177,8 @@ spec:
`
)

func TestServer(t *testing.T) {
//https://github.com/istio/istio/issues/2300
func xTestServer(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is an outstanding PR to fix this. Should we merge that first and then drop this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way - if it gets merged before I finish (likely), I'll drop.

@costinm
Copy link
Contributor Author

costinm commented Dec 22, 2017

And finally prow is happy !!!

Still missing (separate PRs):

  • integrate Doug's generate scripts
  • deb/rpm builds using .fpm
  • lots of cleanup and consistency improvements !

@douglas-reid
Copy link
Contributor

/lgtm

@istio-merge-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: douglas-reid

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@istio-merge-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@istio-merge-robot
Copy link

Automatic merge from submit-queue.

@istio-merge-robot istio-merge-robot merged commit 2786139 into master Dec 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants